public static boolean subgroupExists(StemI stem, String systemNameOfGroup) { Set<GroupI> existingGroups = stem.getChildGroups(); for (GroupI group : existingGroups) { if (group.getExtension().equals(systemNameOfGroup)) { return true; } } return false; }
/** * Return a stem with matching group (sytem) extension, or null if that group doesn't exist * * @param groupExtension the extension of the group to find * @return */ public static GroupI findChildGroup(StemI stem, String groupExtension) { Set<GroupI> groups = stem.getChildGroups(); for (GroupI group : groups) { if (group.getExtension().equals(groupExtension)) { return group; } } return null; }
/** * WARNING: this will remove all sub-groups and sub-stems recursively. The stem itself is left * unchanged. * * @param stem * @throws InsufficientPrivilegeException * @throws GroupDeleteException * @throws StemDeleteException */ public static void deleteStemHierarchy(StemI curStem) throws GroupDeleteException, InsufficientPrivilegeException, StemDeleteException { Set<StemI> subStems = (Set<StemI>) curStem.getChildStems(); for (StemI stem : subStems) { deleteStemHierarchy(stem); stem.delete(); } Set<GroupI> groups = (Set<GroupI>) curStem.getChildGroups(); for (GroupI group : groups) { deleteGroup(group); } }