Skip to content

Commit 8fddcff

Browse files
committed
added parent id to group exists method
1 parent f8479ab commit 8fddcff

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private Project createProjectStucture(Engagement engagement) {
140140

141141
private Group getOrCreateGroup(String groupName, Group groupToCreate) {
142142

143-
Optional<Group> optional = groupService.getGitLabGroupByName(groupName);
143+
Optional<Group> optional = groupService.getGitLabGroupByName(groupName, groupToCreate.getParentId());
144144

145145
if (!optional.isPresent()) {
146146

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class GroupService {
2424
GitLabService gitLabService;
2525

2626
// get a group
27-
public Optional<Group> getGitLabGroupByName(String name) throws UnexpectedGitLabResponseException {
27+
public Optional<Group> getGitLabGroupByName(String name, Integer parentId)
28+
throws UnexpectedGitLabResponseException {
2829

2930
Optional<Group> optional = Optional.empty();
3031

@@ -35,8 +36,8 @@ public Optional<Group> getGitLabGroupByName(String name) throws UnexpectedGitLab
3536
}
3637

3738
// look for a match between returned name and provided path
38-
for(Group group : groupList) {
39-
if(name.equals(group.getPath())) {
39+
for (Group group : groupList) {
40+
if (name.equals(group.getPath()) && parentId.equals(group.getParentId())) {
4041
return Optional.of(group);
4142
}
4243
}
@@ -45,15 +46,16 @@ public Optional<Group> getGitLabGroupByName(String name) throws UnexpectedGitLab
4546

4647
}
4748

48-
public List<Group> getAllGroups(Integer engagementRepositoryId) {
49+
public List<Group> getAllGroups(Integer engagementRepositoryId) {
4950

50-
//FIRST LEVEL
51+
// FIRST LEVEL
5152
List<Group> customerGroups = gitLabService.getSubGroups(engagementRepositoryId);
5253

5354
List<Group> customerEngagementGroups = new ArrayList<>();
54-
customerGroups.stream().forEach(group -> customerEngagementGroups.addAll(gitLabService.getSubGroups(group.getId())));
55+
customerGroups.stream()
56+
.forEach(group -> customerEngagementGroups.addAll(gitLabService.getSubGroups(group.getId())));
5557

56-
if(LOGGER.isDebugEnabled()) {
58+
if (LOGGER.isDebugEnabled()) {
5759
customerEngagementGroups.stream().forEach(group -> LOGGER.debug("Group -> {}", group.getName()));
5860
}
5961

0 commit comments

Comments
 (0)