-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DMP-4381: Automatically update createdBy and lastModifiedBy when persisting entities to the database #2308
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this PR should also include removal of any code that explicitly sets the createdBy
and lastModifiedBy
values in our various services/components, such that this new mechanism gets used?
src/main/java/uk/gov/hmcts/darts/authentication/config/AuthenticationConfiguration.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/gov/hmcts/darts/common/entity/base/CreatedBaseEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/gov/hmcts/darts/audio/helper/TransformedMediaHelper.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/gov/hmcts/darts/common/repository/TransformedMediaRepository.java
Outdated
Show resolved
Hide resolved
src/test/java/uk/gov/hmcts/darts/audio/service/impl/AudioTransformationServiceImplTest.java
Outdated
Show resolved
Hide resolved
...egrationTest/java/uk/gov/hmcts/darts/common/service/TransientObjectDirectoryServiceTest.java
Show resolved
Hide resolved
src/main/java/uk/gov/hmcts/darts/audio/helper/TransformedMediaHelper.java
Outdated
Show resolved
Hide resolved
src/main/java/uk/gov/hmcts/darts/audio/helper/TransformedMediaHelper.java
Show resolved
Hide resolved
@Lazy | ||
@Autowired | ||
private UserIdentity userIdentity; | ||
|
||
@Autowired | ||
private Clock clock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency in our approach to dependency injection, can we make these final and use constructor based injection (either with a manually written constructor or @RequiredArgsConstructor
)? Should also allow you to eliminate the NoArgs and AllArgs constructor annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wont work here as UserIdentity needs to be lazy loaded to avoid circular references,
However, I have manually created the constructed with the relevant annotations to resolve this
@Lazy | ||
@Autowired | ||
private UserIdentity userIdentity; | ||
|
||
@Autowired | ||
private Clock clock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general pattern elsewhere is to inject CurrentTimeHelper
rather than Clock
, consider aligning with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline: Clock is industry standard / Java best practices, will depreciate CurrentTimeHelper and update best practice guides
Links
Change description
Git Diff Summary
This Git Diff introduces enhancements to the authentication and entity management components of the application. Key changes include the addition of auditing capabilities for tracking user account interactions in the
AuthenticationConfiguration
,CreatedBaseEntity
, andCreatedModifiedBaseEntity
classes.Highlights
AuthenticationConfiguration Updates:
AuditorAware<UserAccountEntity>
bean to provide information about the currently authenticated user.Entity Changes:
CreatedBaseEntity
, added@CreatedBy
annotation to thecreatedBy
field to track the user who created the entity.CreatedModifiedBaseEntity
, added@LastModifiedBy
annotation to thelastModifiedBy
field to track the user who last modified the entity.These modifications enhance the tracking of user interactions with entities, improving the auditing capability of the application.
Does this PR introduce a breaking change? (check one with "x")