derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
402 stars 141 forks source link

Auditing Support #26

Open vitolimandibhrata opened 8 years ago

vitolimandibhrata commented 8 years ago

Hi @derjust,

I am working on the auditing support for spring-data-dynamodb. https://github.com/vitolimandibhrata/spring-data-dynamodb/commits/auditing-support

Currently, it can only enable the auditing support via Java Configuration.

If you are not working on the auditing support, I can try to spend sometime to complete the code and hopefully it can be merged to your project.

Please do let me know.

Cheers,

Vito

Sample Configuration File with Auditing Support

@Configuration
@EnableDynamoDBRepositories(
        basePackages = {"com.example.repository.dynamodb"}
)
@EnableDynamoDBAuditing
public class DynamoDBConfig extends AbstractDynamoDBConfiguration {

    @Value("${aws.dynamodb.endpoint}")
    private String amazonDynamoDBEndpoint;

    @Value("${aws.accessKey}")
    private String amazonAWSAccessKey;

    @Value("${aws.secretKey}")
    private String amazonAWSSecretKey;

    @Override
    protected String getMappingBasePackage() {
        return "com.example.domain";
    }

    @Bean
    public AmazonDynamoDB amazonDynamoDB() {
        AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(
                amazonAWSCredentials());
        if (StringUtils.isNotEmpty(amazonDynamoDBEndpoint)) {
            amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint);
        }
        return amazonDynamoDB;
    }

    @Bean
    public AWSCredentials amazonAWSCredentials() {
        return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
    }

}
derjust commented 8 years ago

Hi @vitolimandibhrata!

No I'm currently not working on Auditing support - so feel free to bring it to a first usable state and open a PR. I'm less concerned at that point about unit testing (whereas each unit test is always welcome) but mostly concerned around integration tests. Please ensure that such a test exists which also explains the usage/use-case of the auditing feature.

Thanks! Sebastian

P.S.: If it is only working via annotation in a first shot that's fine. I'm happy to add the XSD/XML processing enchilada

vitolimandibhrata commented 8 years ago

Hi @derjust,

Just a short update. The code to support Auditing is working well in my own project but somehow it is not working in the spring-data-dynamodb project integration test :)

I have included the XML configuration too in my latest commit https://github.com/vitolimandibhrata/spring-data-dynamodb/commits/auditing-support

I will try to find time to complete it.

Cheers

Vito

derjust commented 8 years ago

Hi! I will def. have a look. Sometimes those integration tests are suckers :P

I’m quite under load till the end of next week. So hopefully I get it squeezed in this weekend or after next weekend.

Thanks for your work! Sebastian

foxware00 commented 8 years ago

Hi @vitolimandibhrata is there any progress on this pull request? A feature i'd love to use!

vitolimandibhrata commented 8 years ago

Hi @OllyJFox ,

I have managed to fix the integration test issue. You may try the code at https://github.com/vitolimandibhrata/spring-data-dynamodb/tree/auditing-gosling I have updated the base code to spring-data-dynamodb-4.3.1

Take a look at org.socialsignin.spring.data.dynamodb.config.AuditingViaJavaConfigRepositoriesIT as the sample code.

vitolimandibhrata commented 8 years ago

Hi @derjust ,

I have managed to fix the integration test issue.

It turns out that I need to inject the ApplicationEventPublisher into DynamoDBTemplate manually from DynamoDBRepositoryFactoryBean as DynamoDBTemplate is not invoked as a bean. Thus, I add ApplicationContextAware interface to DynamoDBRepositoryFactoryBean and inject ApplicationEventPublisher into DynamoDBTemplate on the createRepositoryFactory method.

DynamoDBTemplate dynamoDBTemplate = new DynamoDBTemplate(amazonDynamoDB,dynamoDBMapperConfig);
dynamoDBTemplate.setApplicationContext(applicationContext);
dynamoDBOperations = dynamoDBTemplate;

I have updated the base code to spring-data-dynamodb-4.3.1 https://github.com/vitolimandibhrata/spring-data-dynamodb/tree/auditing-gosling

Please take a look

Vito

foxware00 commented 8 years ago

@derjust Another small thing, i'm not seeing 4.3.0 up on maven, or anything since 4.2.3 for that matter.

@vitolimandibhrata and @derjust are we planning a pull request when we are happy with this feature. I'll hopefully get a chance to try out your changes later today.

derjust commented 8 years ago

@OllyJFox I'm sorry I missed a step. Should be fixed now in some hours.

I def. want to merge this feature after reviewing it

maksimu commented 7 years ago

Would you please push 4.2.4 to maven as well? I have some decencies that required aws library version higher than 1.9.x, ideally 1.11.x

maksimu commented 7 years ago

I was able successfully build this project with the most recent AWS library version 1.11.66 Would it be possible for you to push new version of the version 4.2.4 including new aws library to the maven repository?

derjust commented 7 years ago

The upcomming holidays will be helpful for sure to catch up here on various issues. Maybe having some time even this week to address the new AWS library