private GroupImpl createDefaultGroup(final IdentityService identityService, final String name, final String label, final String description, final Group parentGroup) { final Set<GroupImpl> groups = identityService.findGroupsByName(name); GroupImpl group = null; if (groups == null || groups.isEmpty()) { group = new GroupImpl(name); group.setLabel(label); group.setDescription(description); group.setParentGroup(parentGroup); identityService.addGroup(group); } else { group = groups.iterator().next(); } return group; }
@Override public Group addGroup(final String name, final String parentGroupUUID) throws GroupAlreadyExistsException, GroupNotFoundException { FacadeUtil.checkArgsNotNull(name); final IdentityService identityService = EnvTool.getIdentityService(); final List<GroupImpl> childrenGroups = identityService.getGroupChildren(parentGroupUUID); for (final GroupImpl childGroup : childrenGroups) { if (name.equalsIgnoreCase(childGroup.getName())) { throw new GroupAlreadyExistsException("bai_IAPII_7", name); } } final GroupImpl group = new GroupImpl(name); if (parentGroupUUID != null) { final GroupImpl parentGroup = identityService.getGroup(parentGroupUUID); if (parentGroup == null) { throw new GroupNotFoundException("bai_IAPII_13", parentGroupUUID); } group.setParentGroup(parentGroup); } identityService.addGroup(group); return new GroupImpl(group); }
@Override public Group addGroup(final String name, final String label, final String description, final String parentGroupUUID) throws GroupAlreadyExistsException, GroupNotFoundException { FacadeUtil.checkArgsNotNull(name); final IdentityService identityService = EnvTool.getIdentityService(); final List<GroupImpl> childrenGroups = identityService.getGroupChildren(parentGroupUUID); for (final GroupImpl childGroup : childrenGroups) { if (name.equalsIgnoreCase(childGroup.getName())) { throw new GroupAlreadyExistsException("bai_IAPII_7", name); } } final GroupImpl group = new GroupImpl(name); group.setLabel(label); group.setDescription(description); identityService.addGroup(group); if (parentGroupUUID != null) { final GroupImpl parentGroup = identityService.getGroup(parentGroupUUID); if (parentGroup == null) { throw new GroupNotFoundException("bai_IAPII_13", parentGroupUUID); } group.setParentGroup(parentGroup); } return new GroupImpl(group); }
@Override public Group importGroup(final String uuid, final String name, final String label, final String description, final String parentGroupUUID) throws GroupAlreadyExistsException, GroupNotFoundException { FacadeUtil.checkArgsNotNull(name); final IdentityService identityService = EnvTool.getIdentityService(); final Group group = identityService.getGroup(uuid); if (group != null) { throw new GroupAlreadyExistsException("bai_IAPII_7", uuid); } final List<GroupImpl> childrenGroups = identityService.getGroupChildren(parentGroupUUID); for (final GroupImpl childGroup : childrenGroups) { if (name.equalsIgnoreCase(childGroup.getName())) { throw new GroupAlreadyExistsException("bai_IAPII_7", name); } } final GroupImpl groupToImport = new GroupImpl(uuid, name); groupToImport.setLabel(label); groupToImport.setDescription(description); identityService.addGroup(groupToImport); if (parentGroupUUID != null) { final GroupImpl parentGroup = identityService.getGroup(parentGroupUUID); if (parentGroup == null) { throw new GroupNotFoundException("bai_IAPII_13", parentGroupUUID); } groupToImport.setParentGroup(parentGroup); } return new GroupImpl(groupToImport); }