@Override public boolean groupExists(final String groupUUID) { FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); if (identityService.getGroup(groupUUID) != null) { return true; } return false; }
@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); }
FacadeUtil.checkArgsNotNull(groupUUID, name); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); parentGroup = identityService.getGroup(parentGroupUUID); if (parentGroup == null) { throw new GroupNotFoundException("bai_IAPII_13", parentGroupUUID);
private String getGroupPath(final GroupImpl group) { final StringBuilder builder = new StringBuilder(); GroupImpl currentGroup = group; final IdentityService identityService = EnvTool.getIdentityService(); while (currentGroup != null) { builder.insert(0, currentGroup.getName()); builder.insert(0, "/"); final Group parent = currentGroup.getParentGroup(); if (parent != null) { currentGroup = identityService.getGroup(parent.getUUID()); } else { currentGroup = null; } } return builder.toString(); }
final IdentityService identityService = EnvTool.getIdentityService(); for (final String groupUUID : groupUUIDs) { final GroupImpl group = identityService.getGroup(groupUUID); if (group != null) { final List<GroupImpl> children = identityService.getGroupChildren(groupUUID);
@Override public List<User> getUsersInGroup(final String groupUUID, final int fromIndex, final int numberOfUsers, final UserCriterion pagingCriterion) throws GroupNotFoundException { FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } final List<UserImpl> usersInGroup = identityService.getUsersByGroup(groupUUID, fromIndex, numberOfUsers, pagingCriterion); final List<User> users = new ArrayList<User>(); for (final UserImpl userInGroup : usersInGroup) { users.add(new UserImpl(userInGroup)); } return users; }
@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); }
@Override public List<User> getUsersInGroup(final String groupUUID, final int fromIndex, final int numberOfUsers) throws GroupNotFoundException { FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } final List<UserImpl> usersInGroup = identityService.getUsersByGroup(groupUUID, fromIndex, numberOfUsers); final List<User> users = new ArrayList<User>(); for (final UserImpl userInGroup : usersInGroup) { users.add(new UserImpl(userInGroup)); } return users; }
FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID);
@Override public List<User> getAllUsersInGroup(final String groupUUID) throws GroupNotFoundException { FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } final List<UserImpl> users = identityService.getUsersByGroup(groupUUID); final List<User> result = new ArrayList<User>(); if (users != null) { for (final UserImpl user : users) { result.add(new UserImpl(user)); } } return result; }
@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 getGroupByUUID(final String groupUUID) throws GroupNotFoundException { FacadeUtil.checkArgsNotNull(groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } return new GroupImpl(group); }
@Override public List<User> getAllUsersInRoleAndGroup(final String roleUUID, final String groupUUID) throws RoleNotFoundException, GroupNotFoundException { FacadeUtil.checkArgsNotNull(roleUUID, groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final RoleImpl role = identityService.getRole(roleUUID); if (role == null) { throw new RoleNotFoundException("bai_IAPII_3", roleUUID); } final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } final MembershipImpl membership = identityService.findMembershipByRoleAndGroup(roleUUID, groupUUID); final List<User> result = new ArrayList<User>(); if (membership != null) { final List<UserImpl> users = identityService.getUsersByMembership(membership.getUUID()); for (final UserImpl user : users) { result.add(new UserImpl(user)); } } return result; }
@Override public Membership getMembershipForRoleAndGroup(final String roleUUID, final String groupUUID) throws RoleNotFoundException, GroupNotFoundException { FacadeUtil.checkArgsNotNull(roleUUID, groupUUID); final IdentityService identityService = EnvTool.getIdentityService(); final RoleImpl role = identityService.getRole(roleUUID); if (role == null) { throw new RoleNotFoundException("bai_IAPII_3", roleUUID); } final GroupImpl group = identityService.getGroup(groupUUID); if (group == null) { throw new GroupNotFoundException("bai_IAPII_12", groupUUID); } MembershipImpl membership = identityService.findMembershipByRoleAndGroup(roleUUID, groupUUID); if (membership != null) { return new MembershipImpl(membership); } else { membership = new MembershipImpl(); membership.setGroup(group); membership.setRole(role); identityService.addMembership(membership); return new MembershipImpl(membership); } }