chore: Refactor relationship validations [DHIS2-20158]#23866
Merged
Conversation
muilpp
marked this pull request as ready for review
May 11, 2026 13:17
enricocolasante
approved these changes
May 12, 2026
| .toList(); | ||
| return canUpdate(user, event, event.getOrganisationUnit(), event.getAttributeOptionCombo()); | ||
| } | ||
| if (item.getSingleEvent() != null) return canCreate(user, item.getSingleEvent()); |
Contributor
There was a problem hiding this comment.
Why here are we using canCreate and not canUpdate?
Contributor
Author
There was a problem hiding this comment.
No reason. They are effectively the same thing, as the org unit and cat combo are not updated when validating relationships.
Anyway, I'll use canUpdate instead, just to be consistent with how we do it for tracker events.
| * @return No errors if the user has capture scope access and write access to the TET. | ||
| */ | ||
| List<ErrorMessage> canCreate(@Nonnull UserDetails user, TrackedEntity trackedEntity); | ||
| List<ErrorMessage> canCreate(UserDetails user, TrackedEntity trackedEntity); |
Contributor
There was a problem hiding this comment.
Following https://github.com/dhis2/wow-backend/blob/master/guides/code-guide.md#nullability--immutability, I would use @Nonnull annotation in all the places that makes sense in the interface (and then in the implementation)
|
teleivo
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This is the last PR of the Tracker Access Manager refactor.
This one includes:
Refactoring the Relationship methods in
TrackerAccessManagerfromList<String>toList<ErrorMessage>.Stopping
SecurityRelationshipValidatorfrom always emitting a single blanketE4020and instead forwards the actual per check error codes fromcanCreate/canDelete.Introducing
E4019(missing RelationshipType read access)Renaming
E4020’s message to correctly refer to “RelationshipType”.Fixing two test bugs (wrong user injection and duplicate word in a test name), and adds unit tests for
E4019.