Skip to content

Commit

Permalink
Closes Taskana#2563 - refactoring of method
Browse files Browse the repository at this point in the history
  • Loading branch information
MM1277 committed May 28, 2024
1 parent ed57237 commit 886aa40
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,28 +400,32 @@ public String searchDnForAccessId(String accessId)
AccessIdRepresentationModel groupByDn = searchAccessIdByDn(accessId);
return groupByDn.getAccessId();
} else {
final List<String> distinguishedNames = searchDnForUserAccessId(accessId);
if (distinguishedNames == null || distinguishedNames.isEmpty()) {
final List<String> distinguishedNamesPermissions = searchDnForPermissionAccessId(accessId);
if (distinguishedNamesPermissions == null || distinguishedNamesPermissions.isEmpty()) {
final List<String> distinguishedNamesGroups = searchDnForGroupAccessId(accessId);
if (distinguishedNamesGroups == null || distinguishedNamesGroups.isEmpty()) {
return null;
} else if (distinguishedNamesGroups.size() > 1) {
throw new InvalidArgumentException("Ambiguous access id found: " + accessId);
} else {
return distinguishedNamesGroups.get(0);
}
} else if (distinguishedNamesPermissions.size() > 1) {
return searchDnForAccessIdIfAccessIdNameIsNotDn(accessId);
}
}

private String searchDnForAccessIdIfAccessIdNameIsNotDn(String accessId) {
final List<String> distinguishedNames = searchDnForUserAccessId(accessId);
if (distinguishedNames == null || distinguishedNames.isEmpty()) {
final List<String> distinguishedNamesPermissions = searchDnForPermissionAccessId(accessId);
if (distinguishedNamesPermissions == null || distinguishedNamesPermissions.isEmpty()) {
final List<String> distinguishedNamesGroups = searchDnForGroupAccessId(accessId);
if (distinguishedNamesGroups == null || distinguishedNamesGroups.isEmpty()) {
return null;
} else if (distinguishedNamesGroups.size() > 1) {
throw new InvalidArgumentException("Ambiguous access id found: " + accessId);
} else {
return distinguishedNamesPermissions.get(0);
return distinguishedNamesGroups.get(0);
}
} else if (distinguishedNames.size() > 1) {
} else if (distinguishedNamesPermissions.size() > 1) {
throw new InvalidArgumentException("Ambiguous access id found: " + accessId);
} else {
return distinguishedNames.get(0);
return distinguishedNamesPermissions.get(0);
}
} else if (distinguishedNames.size() > 1) {
throw new InvalidArgumentException("Ambiguous access id found: " + accessId);
} else {
return distinguishedNames.get(0);
}
}

Expand Down

0 comments on commit 886aa40

Please sign in to comment.