Skip to content

Commit 4498e74

Browse files
committed
update response parsing
1 parent f8a7089 commit 4498e74

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/java/main/com/cronos/onlinereview/actions/project/SaveProjectAction.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,17 +1463,34 @@ private Set<Long> getParentGroups(long groupId) throws BaseException {
14631463

14641464
JsonNode result = objectMapper.readTree(entity.getContent());
14651465

1466-
JsonNode groups = result.path("result").path("content");
1467-
Set<Long> groupIds = new HashSet<Long>();
1468-
for (JsonNode group : groups) {
1469-
groupIds.add(group.path("id").asLong());
1470-
}
1466+
JsonNode groupNode = result.path("result").path("content");
1467+
Set<Long> groupIds = parseGroup(groupNode);
14711468

14721469
return groupIds;
14731470
} catch (Exception exp) {
14741471
throw new BaseException(exp.getMessage(), exp);
14751472
}
14761473
}
1474+
1475+
/**
1476+
* Parse the group from the JSON node
1477+
* @param groupNode the JSON node
1478+
* @return the group
1479+
*/
1480+
private Set<Long> parseGroup(JsonNode groupNode) {
1481+
Set<Long> parentGroupIds = new HashSet<>();
1482+
Long parentGroupId = groupNode.path("id").asLong();
1483+
if (parentGroupId != 0) {
1484+
// exclude null node
1485+
parentGroupIds.add(groupNode.path("id").asLong());
1486+
}
1487+
1488+
if (groupNode.has("parentGroup")) {
1489+
parentGroupIds.addAll(parseGroup(groupNode.path("parentGroup")));
1490+
}
1491+
1492+
return parentGroupIds;
1493+
}
14771494

14781495
/**
14791496
* Check group permission

0 commit comments

Comments
 (0)