Skip to content

Commit f8479ab

Browse files
committed
exact matches for groups and projects
1 parent 0f2eb05 commit f8479ab

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/main/java/com/redhat/labs/omp/service/GroupService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,14 @@ public Optional<Group> getGitLabGroupByName(String name) throws UnexpectedGitLab
3434
return optional;
3535
}
3636

37-
if (1 == groupList.size()) {
38-
return Optional.of(groupList.get(0));
39-
}
40-
41-
// found more than one group with name in either 'name' or 'path' attribute
42-
// should match path
37+
// look for a match between returned name and provided path
4338
for(Group group : groupList) {
44-
if(name.equalsIgnoreCase(group.getPath())) {
39+
if(name.equals(group.getPath())) {
4540
return Optional.of(group);
4641
}
4742
}
4843

49-
throw new UnexpectedGitLabResponseException(
50-
"No resource found with name equal to path attribute.");
44+
return optional;
5145

5246
}
5347

src/main/java/com/redhat/labs/omp/service/ProjectService.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,9 @@ public Optional<Project> getProjectByName(Integer namespaceId, String name)
3535
return optional;
3636
}
3737

38-
if (1 == resultList.size()) {
39-
return Optional.of(Project.from(resultList.get(0)));
40-
}
41-
42-
// found more than one project with name in either 'name' or 'path' attribute
43-
// should match path
38+
// look for a project with name that matches the namespace id and the path
4439
for (ProjectSearchResults result : resultList) {
45-
if (namespaceId.equals(result.getNamespace().getId()) && name.equalsIgnoreCase(result.getPath())) {
40+
if (namespaceId.equals(result.getNamespace().getId()) && name.equals(result.getPath())) {
4641
return Optional.of(Project.from(result));
4742
}
4843
}

0 commit comments

Comments
 (0)