private IEntityGroup getGroup(String key) { try { return GroupService.findGroup(key); } catch (GroupsException e) { throw new RuntimeException( "An exception occurred retrieving " + "the group " + groupName + ".", e); } }
/** * Given the key, returns the entity's name. * * @param key java.lang.String */ @Override public String getName(String key) throws Exception { IEntityGroup g = GroupService.findGroup(key); return g.getName(); }
@Override public Entity getRootGroup() { IEntityGroup entityGroup = GroupService.findGroup(ROOT_GROUP_KEY); return EntityFactory.createEntity(entityGroup, EntityEnum.GROUP); }
/** * Given the key, returns the entity's name. * * @param key java.lang.String */ @Override public String getName(String key) throws Exception { IEntityGroup g = GroupService.findGroup(key); return g.getName(); }
@Override public boolean isUserDeepMemberOf(String userName, String groupKey) { final IEntityGroup distinguishedGroup = GroupService.findGroup(groupKey); if (distinguishedGroup == null) { if (this.logger.isDebugEnabled()) { this.logger.debug("No group found for key '" + groupKey + "'"); } return false; } final IEntity entity = GroupService.getEntity(userName, IPerson.class); if (entity == null) { if (this.logger.isDebugEnabled()) { this.logger.debug("No user found for key '" + userName + "'"); } return false; } return distinguishedGroup.deepContains(entity); }
@Override public boolean isUserDeepMemberOf(String userName, String groupKey) { final IEntityGroup distinguishedGroup = GroupService.findGroup(groupKey); if (distinguishedGroup == null) { if (this.logger.isDebugEnabled()) { this.logger.debug("No group found for key '" + groupKey + "'"); } return false; } final IEntity entity = GroupService.getEntity(userName, IPerson.class); if (entity == null) { if (this.logger.isDebugEnabled()) { this.logger.debug("No user found for key '" + userName + "'"); } return false; } return distinguishedGroup.deepContains(entity); }
@Override public Set<PortletCategory> getChildCategories(PortletCategory parent) { String parentKey = String.valueOf(parent.getId()); IEntityGroup parentGroup = GroupService.findGroup(parentKey); Set<PortletCategory> categories = new HashSet<>(); for (IGroupMember gm : parentGroup.getChildren()) { if (gm.isGroup()) { String categoryId = gm.getKey(); categories.add(getPortletCategory(categoryId)); } } return categories; }
@Override public Set<PortletCategory> getParentCategories(PortletCategory child) { String childKey = String.valueOf(child.getId()); IEntityGroup childGroup = GroupService.findGroup(childKey); Set<PortletCategory> parents = new HashSet<>(); for (IGroupMember gm : childGroup.getParentGroups()) { if (gm.isGroup()) { String categoryId = gm.getKey(); parents.add(getPortletCategory(categoryId)); } } return parents; }
@Override public Set<PortletCategory> getParentCategories(PortletCategory child) { String childKey = String.valueOf(child.getId()); IEntityGroup childGroup = GroupService.findGroup(childKey); Set<PortletCategory> parents = new HashSet<>(); for (IGroupMember gm : childGroup.getParentGroups()) { if (gm.isGroup()) { String categoryId = gm.getKey(); parents.add(getPortletCategory(categoryId)); } } return parents; }
@Override public Set<PortletCategory> getChildCategories(PortletCategory parent) { String parentKey = String.valueOf(parent.getId()); IEntityGroup parentGroup = GroupService.findGroup(parentKey); Set<PortletCategory> categories = new HashSet<>(); for (IGroupMember gm : parentGroup.getChildren()) { if (gm.isGroup()) { String categoryId = gm.getKey(); categories.add(getPortletCategory(categoryId)); } } return categories; }
/** * Returns member groups for the <code>IEntityGroup</code>. First get the member groups that are * local to this service. Then retrieve the keys of all of the member groups and ask the * GroupService to find the groups we do not yet have. * * @param eg IEntityGroup */ @Override public Iterator findMemberGroups(IEntityGroup eg) throws GroupsException { Map groups = new HashMap(); IEntityGroup group = null; for (Iterator itr = findLocalMemberGroups(eg); itr.hasNext(); ) { group = (IEntityGroup) itr.next(); groups.put(group.getKey(), group); } String[] memberGroupKeys = getGroupStore().findMemberGroupKeys(eg); for (int i = 0; i < memberGroupKeys.length; i++) { if (!groups.containsKey(memberGroupKeys[i])) { group = GroupService.findGroup(memberGroupKeys[i]); if (group != null) { groups.put(group.getKey(), group); } } } return groups.values().iterator(); }
/** * Find {@link IEntityGroup} from group name (case sensitive). * * @param groupName name of group to search from {@code GroupService} * @return {@code IEntityGroup} with given name or null if no group with given name found * @see org.apereo.portal.services.GroupService#searchForEntities(String, * org.apereo.portal.groups.IGroupConstants.SearchMethod, Class) * @see org.apereo.portal.services.GroupService#findGroup(String) */ private static IEntityGroup findGroupByName(String groupName) { EntityIdentifier[] identifiers = GroupService.searchForGroups( groupName, GroupService.SearchMethod.DISCRETE, IPerson.class); for (EntityIdentifier entityIdentifier : identifiers) { if (entityIdentifier.getType().equals(IEntityGroup.class)) { return GroupService.findGroup(entityIdentifier.getKey()); } } return null; }
/** * Find {@link IEntityGroup} from group name (case sensitive). * * @param groupName name of group to search from {@code GroupService} * @return {@code IEntityGroup} with given name or null if no group with given name found * @see org.apereo.portal.services.GroupService#searchForEntities(String, * org.apereo.portal.groups.IGroupConstants.SearchMethod, Class) * @see org.apereo.portal.services.GroupService#findGroup(String) */ private static IEntityGroup findGroupByName(String groupName) { EntityIdentifier[] identifiers = GroupService.searchForGroups( groupName, GroupService.SearchMethod.DISCRETE, IPerson.class); for (EntityIdentifier entityIdentifier : identifiers) { if (entityIdentifier.getType().equals(IEntityGroup.class)) { return GroupService.findGroup(entityIdentifier.getKey()); } } return null; }
/** * Delete a group from the group store * * @param key key of the group to be deleted * @param user performing the delete operation */ public void deleteGroup(String key, IPerson deleter) { if (!canDeleteGroup(deleter, key)) { throw new RuntimeAuthorizationException( deleter, IPermission.DELETE_GROUP_ACTIVITY, key); } log.info("Deleting group with key " + key); // find the current version of this group entity IEntityGroup group = GroupService.findGroup(key); // remove this group from the membership list of any current parent // groups for (IEntityGroup parent : group.getParentGroups()) { parent.removeChild(group); parent.updateMembers(); } // delete the group group.delete(); }
/** * Update the title and description of an existing group in the group store. * * @param groupForm Form representing the new group configuration * @param updater Updating user */ public void updateGroupDetails(GroupForm groupForm, IPerson updater) { if (!canEditGroup(updater, groupForm.getKey())) { throw new RuntimeAuthorizationException( updater, IPermission.EDIT_GROUP_ACTIVITY, groupForm.getKey()); } if (log.isDebugEnabled()) { log.debug("Updating group for group form [" + groupForm.toString() + "]"); } // find the current version of this group entity IEntityGroup group = GroupService.findGroup(groupForm.getKey()); group.setName(groupForm.getName()); group.setDescription(groupForm.getDescription()); // save the group, updating both its basic information and group // membership group.update(); }
@Override public PortletCategory getPortletCategory(String portletCategoryId) { IEntityGroup categoryGroup = GroupService.findGroup(portletCategoryId); if (categoryGroup == null) { return null; } PortletCategory category = new PortletCategory(portletCategoryId); category.setName(categoryGroup.getName()); category.setDescription(categoryGroup.getDescription()); category.setCreatorId(categoryGroup.getCreatorID()); return category; }
@Override public PortletCategory getPortletCategory(String portletCategoryId) { IEntityGroup categoryGroup = GroupService.findGroup(portletCategoryId); if (categoryGroup == null) { return null; } PortletCategory category = new PortletCategory(portletCategoryId); category.setName(categoryGroup.getName()); category.setDescription(categoryGroup.getDescription()); category.setCreatorId(categoryGroup.getCreatorID()); return category; }
@Override public PortletCategory getPortletCategoryByName(String portletCategoryName) { final EntityIdentifier[] eids = GroupService.searchForGroups( portletCategoryName, IGroupConstants.SearchMethod.DISCRETE_CI, IPortletDefinition.class); if (eids == null || eids.length == 0) { return null; } else if (eids.length > 1) { throw new IllegalStateException( "More than one group found with name '" + portletCategoryName + "' (case insensitive)"); } final IEntityGroup categoryGroup = GroupService.findGroup(eids[0].getKey()); final PortletCategory category = new PortletCategory(eids[0].getKey()); category.setName(categoryGroup.getName()); category.setDescription(categoryGroup.getDescription()); category.setCreatorId(categoryGroup.getCreatorID()); return category; }
@Override public PortletCategory getPortletCategoryByName(String portletCategoryName) { final EntityIdentifier[] eids = GroupService.searchForGroups( portletCategoryName, IGroupConstants.SearchMethod.DISCRETE_CI, IPortletDefinition.class); if (eids == null || eids.length == 0) { return null; } else if (eids.length > 1) { throw new IllegalStateException( "More than one group found with name '" + portletCategoryName + "' (case insensitive)"); } final IEntityGroup categoryGroup = GroupService.findGroup(eids[0].getKey()); final PortletCategory category = new PortletCategory(eids[0].getKey()); category.setName(categoryGroup.getName()); category.setDescription(categoryGroup.getDescription()); category.setCreatorId(categoryGroup.getCreatorID()); return category; }
/** * Construct a group form for the group with the specified key. * * @param key * @param entityEnum * @return */ public GroupForm getGroupForm(String key) { log.debug("Initializing group form for group key " + key); // find the current version of this group entity IEntityGroup group = GroupService.findGroup(key); // update the group form with the existing group's main information GroupForm form = new GroupForm(); form.setKey(key); form.setName(group.getName()); form.setDescription(group.getDescription()); form.setCreatorId(group.getCreatorID()); form.setType(groupListHelper.getEntityType(group).toString()); // add child groups to our group form bean for (IGroupMember child : group.getChildren()) { JsonEntityBean childBean = groupListHelper.getEntity(child); form.addMember(childBean); } return form; }