Skip to content

Commit

Permalink
fix: Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge committed Jan 9, 2025
1 parent 22a2220 commit 66da90a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Map;
import javax.annotation.Nonnull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.common.UID;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
Expand All @@ -59,7 +58,6 @@
@Component(
"org.hisp.dhis.tracker.imports.validation.validator.enrollment.SecurityOwnershipValidator")
@RequiredArgsConstructor
@Slf4j
class SecurityOwnershipValidator implements Validator<Enrollment> {

@Nonnull private final AclService aclService;
Expand Down Expand Up @@ -170,7 +168,7 @@ public boolean needsToRun(TrackerImportStrategy strategy) {

private void checkOrgUnitInCaptureScope(
Reporter reporter, TrackerDto dto, OrganisationUnit orgUnit, UserDetails user) {
if (!user.isInUserHierarchy(orgUnit.getStoredPath())) {
if (!user.isInUserHierarchy(orgUnit.getPath())) {
reporter.addError(dto, ValidationCode.E1000, user, orgUnit);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.Map;
import javax.annotation.Nonnull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.category.CategoryOption;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.common.UID;
Expand Down Expand Up @@ -63,7 +62,6 @@
*/
@Component("org.hisp.dhis.tracker.imports.validation.validator.event.SecurityOwnershipValidator")
@RequiredArgsConstructor
@Slf4j
class SecurityOwnershipValidator implements Validator<org.hisp.dhis.tracker.imports.domain.Event> {

@Nonnull private final AclService aclService;
Expand Down Expand Up @@ -296,8 +294,8 @@ private void checkEventOrgUnitWriteAccess(
boolean isCreatableInSearchScope,
UserDetails user) {
if (isCreatableInSearchScope
? !user.isInUserEffectiveSearchOrgUnitHierarchy(eventOrgUnit.getStoredPath())
: !user.isInUserHierarchy(eventOrgUnit.getStoredPath())) {
? !user.isInUserEffectiveSearchOrgUnitHierarchy(eventOrgUnit.getPath())
: !user.isInUserHierarchy(eventOrgUnit.getPath())) {
reporter.addError(event, ValidationCode.E1000, user, eventOrgUnit);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean needsToRun(TrackerImportStrategy strategy) {

private void checkOrgUnitInCaptureScope(
Reporter reporter, TrackerDto dto, OrganisationUnit orgUnit, UserDetails user) {
if (!user.isInUserHierarchy(orgUnit.getStoredPath())) {
if (!user.isInUserHierarchy(orgUnit.getPath())) {
reporter.addError(dto, ValidationCode.E1000, user, orgUnit);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ void shouldMapOrgUnitWhenProgramProvidedAndRequestedOrgUnitInSearchScope(
OrganisationUnit searchScopeChildOrgUnit = createOrganisationUnit('B');
searchScopeOrgUnit.setChildren(Set.of(searchScopeChildOrgUnit));
searchScopeChildOrgUnit.setParent(searchScopeOrgUnit);
searchScopeOrgUnit.updatePath();
searchScopeChildOrgUnit.updatePath();

User user = new User();
user.setUid(CodeGenerator.generateUid());
Expand Down Expand Up @@ -456,6 +458,8 @@ void shouldMapOrgUnitWhenModeAllProgramProvidedAndRequestedOrgUnitInSearchScope(
OrganisationUnit searchScopeChildOrgUnit = createOrganisationUnit('B');
searchScopeOrgUnit.setChildren(Set.of(searchScopeChildOrgUnit));
searchScopeChildOrgUnit.setParent(searchScopeOrgUnit);
searchScopeOrgUnit.updatePath();
searchScopeChildOrgUnit.updatePath();

User user = new User();
user.setUid(CodeGenerator.generateUid());
Expand Down

0 comments on commit 66da90a

Please sign in to comment.