final IGroupMember groupMember = GroupService.findGroup(group); if (groupMember != null) { return groupMember; GroupService.searchForGroups( group, IGroupConstants.SearchMethod.DISCRETE, IPerson.class); if (results == null || results.length == 0) { return GroupService.getGroupMember(results[0]);
@Override public boolean isUserDeepMemberOfGroupName(String userName, String groupName) { final EntityIdentifier[] results = GroupService.searchForGroups( groupName, GroupService.SearchMethod.DISCRETE, IPerson.class); if (results == null || results.length == 0) { final IGroupMember group = GroupService.getGroupMember(results[0]); final IEntity entity = GroupService.getEntity(userName, IPerson.class); if (entity == null) { if (this.logger.isDebugEnabled()) {
/** * Determines if the passed-in group member represents a user that is a member of the * administrator group or any of its sub groups. */ public static boolean isAdmin(IGroupMember member) { IEntityGroup adminGroup = null; try { adminGroup = GroupService.getDistinguishedGroup(PORTAL_ADMINISTRATORS_DISTINGUISHED_GROUP); } catch (GroupsException ge) { // cannot determine whether or not the user is an admin. cLog.error( "Administrative group not found, cannot determine " + "user's admininstrative membership.", ge); } return (null != adminGroup && adminGroup.deepContains(member)); } }
@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); }
/** * Convert a list of group names to a list of groups. * * @param groupNames the list of group names - case sensitive. * @return the list of groups. */ private Set<IGroupMember> toGroupMembers(List<String> groupNames, String fname) { final Set<IGroupMember> groups = new HashSet<>(); for (String groupName : groupNames) { // Assumes the groupName case matches the DB values. EntityIdentifier[] gs = GroupService.searchForGroups( groupName, IGroupConstants.SearchMethod.DISCRETE, IPerson.class); IGroupMember group; if (gs != null && gs.length > 0) { group = GroupService.findGroup(gs[0].getKey()); } else { // An actual group key might be specified, so try looking up group directly group = GroupService.findGroup(groupName); } if (group == null) { throw new IllegalArgumentException( "No group '" + groupName + "' found when importing portlet: " + fname); } groups.add(group); } return groups; }
/** * Returns an <code>IGroupMember</code> representing either a group or a portal entity, based on * the <code>EntityIdentifier</code>, which refers to the UNDERLYING entity for the <code> * IGroupMember</code>. */ public static IGroupMember getGroupMember(EntityIdentifier underlyingEntityIdentifier) throws GroupsException { return getGroupMember( underlyingEntityIdentifier.getKey(), underlyingEntityIdentifier.getType()); }
IEntityGroup group = GroupService.findGroup(groupForm.getKey()); EntityEnum type = EntityEnum.getEntityEnum(child.getEntityTypeAsString()); if (type.isGroup()) { IEntityGroup member = GroupService.findGroup(child.getId()); group.addChild(member); } else { IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz()); group.addChild(member);
private IEntityGroup getGroup(String key) { try { return GroupService.findGroup(key); } catch (GroupsException e) { throw new RuntimeException( "An exception occurred retrieving " + "the group " + groupName + ".", e); } }
/** * Returns an <code>IEntity</code> representing a portal entity. This does not guarantee that * the entity actually exists. * * @param key String - the group key. * @param type Class - the Class of the underlying IGroupMember. * @return org.apereo.portal.groups.IEntity */ public static IEntity getEntity(String key, Class<?> type) throws GroupsException { return getEntity(key, type, null); }
GroupService.searchForGroups( searchTerm, GroupService.SearchMethod.CONTAINS_CI, GroupService.searchForEntities( searchTerm, GroupService.SearchMethod.CONTAINS_CI, IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier); Entity entity = getEntity(groupMember); results.add(entity);
GroupService.searchForGroups( name, IGroupConstants.SearchMethod.DISCRETE, IPerson.class); if (eids.length == 0) { (IEntityGroup) GroupService.getGroupMember(eids[0]); // Names must be unique
EntityEnum entityEnum = a.getPrincipal().getEntityType(); if (entityEnum.isGroup()) { member = GroupService.findGroup(a.getPrincipal().getId()); } else { member = GroupService.getGroupMember(a.getPrincipal().getId(), entityEnum.getClazz()); Iterator<?> it = GroupService.getCompositeGroupService().findParentGroups(member); if (it.hasNext()) {
IEntityGroup group = GroupService.newGroup(type.getClazz()); EntityEnum childType = EntityEnum.getEntityEnum(child.getEntityTypeAsString()); if (childType.isGroup()) { IEntityGroup member = GroupService.findGroup(child.getId()); group.addChild(member); } else { IGroupMember member = GroupService.getGroupMember(child.getId(), type.getClazz()); group.addChild(member); IEntityGroup parentGroup = GroupService.findGroup(parent.getId()); parentGroup.addChild(group); parentGroup.updateMembers();
@Override public Set<Entity> getGroupsForMember(String memberName) { Set<Entity> groups = new HashSet<Entity>(); if (StringUtils.isNotEmpty(memberName)) { EntityIdentifier[] identifiers = GroupService.searchForEntities( memberName, GroupService.SearchMethod.DISCRETE, EntityEnum.PERSON.getClazz()); for (EntityIdentifier entityIdentifier : identifiers) { if (entityIdentifier.getType().equals(EntityEnum.PERSON.getClazz())) { IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier); if (memberName.equalsIgnoreCase(groupMember.getKey())) { Iterator it = GroupService.findParentGroups(groupMember); while (it.hasNext()) { IEntityGroup g = (IEntityGroup) it.next(); Entity e = EntityFactory.createEntity( g, EntityEnum.getEntityEnum(g.getLeafType(), true)); groups.add(e); } return groups; } } } } return groups; }
GroupService.getGroupMember( def.getPortletDefinitionId().getStringId(), IPortletDefinition.class); @SuppressWarnings("unchecked") final Iterator<IEntityGroup> categories = GroupService.getCompositeGroupService().findParentGroups(gm); while (categories.hasNext()) { IEntityGroup category = categories.next();
private String getGroupKey() { EntityIdentifier[] groups = null; try { groups = GroupService.searchForGroups( groupName, IGroupConstants.SearchMethod.DISCRETE, IPerson.class); } catch (GroupsException e1) { throw new RuntimeException( "An exception occurred searching for " + "the group " + groupName + ".", e1); } if (groups == null || groups.length == 0) throw new RuntimeException( "Group with name '" + groupName + "' not found for " + this.getClass().getName() + ". All evaluations will return false."); return groups[0].getKey(); }
private synchronized Set<IEntityGroup> buildParentGroupsSet() throws GroupsException { logger.debug( "Constructing containingGroups for member='{}'", getUnderlyingEntityIdentifier()); final Set<IEntityGroup> rslt = new HashSet<>(); for (Iterator it = GroupService.getCompositeGroupService().findParentGroups(this); it.hasNext(); ) { final IEntityGroup eg = (IEntityGroup) it.next(); rslt.add(eg); } return Collections.unmodifiableSet(rslt); }
/** * 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; }
/** * Returns an <code>IGroupMember</code> representing either a group or a portal entity, based on * the <code>EntityIdentifier</code>, which refers to the UNDERLYING entity for the <code> * IGroupMember</code>. */ public static IGroupMember getGroupMember(EntityIdentifier underlyingEntityIdentifier) throws GroupsException { return getGroupMember( underlyingEntityIdentifier.getKey(), underlyingEntityIdentifier.getType()); }
IEntityGroup entityGroup = GroupService.findGroup(entityId); if (entityGroup == null) { return null; IGroupMember groupMember = GroupService.getGroupMember(entityId, entityEnum.getClazz()); if (groupMember == null || groupMember instanceof IEntityGroup) { return null;