-
Notifications
You must be signed in to change notification settings - Fork 356
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
fix: use importer for update object property [DHIS2-11944] #9079
Conversation
new MergeParams<>( userCredentials, persistedUserCredentials ).setMergeMode( bundle.getMergeMode() ) ); | ||
preheatService.connectReferences( persistedUserCredentials, bundle.getPreheat(), | ||
bundle.getPreheatIdentifier() ); | ||
if ( userCredentials != persistedUserCredentials ) |
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.
Not sure when or why but apparently these can be the very same instance and merging them messes up proxy collections I guess. Anyhow, only merging dissimilar instances should not be less correct.
&& (PropertyType.REFERENCE == p.getPropertyType() && schema.getKlass() != p.getKlass() | ||
|| PropertyType.REFERENCE == p.getItemPropertyType() && schema.getKlass() != p.getItemKlass()) ) |
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 is so we don't process self-referencing fields like User
in a User
like it does occur for createdBy
and lastUpdatedBy
.
@@ -269,7 +267,7 @@ private Patch diff( HttpServletRequest request ) | |||
return patchService.diff( new PatchParams( mapper.readTree( request.getInputStream() ) ) ); | |||
} | |||
|
|||
@RequestMapping( value = "/{uid}/{property}", method = { RequestMethod.PUT, RequestMethod.PATCH } ) | |||
@PatchMapping( "/{uid}/{property}" ) |
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.
We talked about PUT
being mapped twice so it got removed here. Only PATCH
ever worked and as I understood it was documented.
Kudos, SonarCloud Quality Gate passed! |
Summary
Goal of this PR was to use importer to apply single object property updates so that additional validation performed in the object bundle hooks would execute for these updates as well.
Using the importer has revealed a few issues that have been addressed. I pointed these out in comments on the line in question.
Automatic Tests
This adds a test scenario that might look overly complicated at first sight. This is because this more complex scenario would show an issue with the update so the test make sure this issue is not present. A similar scenario was added to full object update to check and make sure a similar problem does not exist there.