Example #1
0
  public Set<Entity> search(String entityType, String searchTerm) {

    Set<Entity> results = new HashSet<Entity>();
    EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
    EntityIdentifier[] identifiers;
    Class identifierType;

    // if the entity type is a group, use the group service's findGroup method
    // to locate it
    if (entityEnum.isGroup()) {
      identifiers =
          GroupService.searchForGroups(searchTerm, GroupService.CONTAINS, entityEnum.getClazz());
      identifierType = IEntityGroup.class;
    }
    // otherwise use the getGroupMember method
    else {
      identifiers =
          GroupService.searchForEntities(searchTerm, GroupService.CONTAINS, entityEnum.getClazz());
      identifierType = entityEnum.getClazz();
    }

    for (EntityIdentifier entityIdentifier : identifiers) {
      if (entityIdentifier.getType().equals(identifierType)) {
        IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
        Entity entity = getEntity(groupMember);
        results.add(entity);
      }
    }

    return results;
  }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
   result = prime * result + ((memberId == null) ? 0 : memberId.hashCode());
   return result;
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   MembershipCacheKey other = (MembershipCacheKey) obj;
   if (groupId == null) {
     if (other.groupId != null) return false;
   } else if (!groupId.equals(other.groupId)) return false;
   if (memberId == null) {
     if (other.memberId != null) return false;
   } else if (!memberId.equals(other.memberId)) return false;
   return true;
 }
  /**
   * @see
   *     org.jasig.portal.groups.IEntityGroupStore#updateMembers(org.jasig.portal.groups.IEntityGroup)
   */
  public void updateMembers(IEntityGroup group) throws GroupsException {

    // assume key is fully qualified group name
    String groupName = group.getLocalKey();

    GcAddMember gcAddMember = new GcAddMember().assignGroupName(groupName);

    for (IGroupMember iGroupMember : group.getChildren()) {
      EntityIdentifier entityIdentifier = iGroupMember.getEntityIdentifier();
      String identifier = entityIdentifier.getKey();
      gcAddMember.addSubjectIdentifier(identifier);
    }
    gcAddMember.execute();
  }