Class MemberFinder

java.lang.Object
edu.internet2.middleware.grouper.MemberFinder

public class MemberFinder extends Object

Use this class to find members within the Groups registry

Sample call

 Set members = MemberFinder.findAll(grouperSession, gsaSource);
 

Sample call to find members by attribute def names

 Set members = new MemberFinder().assignNameOfAttributeDefName(attributeDefName.getName())
      .assignAttributeCheckReadOnAttributeDef(true).assignQueryOptions(QueryOptions.create("subjectId", true, null, null)).findMembers();
 

  • Constructor Details

    • MemberFinder

      public MemberFinder()
      constructor
  • Method Details

    • findMembers

      public Set<Member> findMembers()
      find members
      Returns:
      the set of groups or the empty set if none found
    • addAttributeValuesOnAssignment

      public MemberFinder addAttributeValuesOnAssignment(Object value)
      if looking for an attribute value on an assignment, could be multiple values
      Parameters:
      theValues -
      Returns:
      this for chaining
    • addAttributeValuesOnAssignment2

      public MemberFinder addAttributeValuesOnAssignment2(Object value)
      if looking for an attribute value on an assignment2, could be multiple values
      Parameters:
      value -
      Returns:
      this for chaining
    • assignAttributeCheckReadOnAttributeDef

      public MemberFinder assignAttributeCheckReadOnAttributeDef(boolean theAttributeDefNameUseSecurity)
      use security around attribute def? default is true
      Parameters:
      theAttributeDefNameUseSecurity -
      Returns:
      this for chaining
    • assignAttributeValue

      public MemberFinder assignAttributeValue(Object theValue)
      find objects with this value
      Parameters:
      theValue -
      Returns:
      this for chaining
    • assignAttributeValue2

      public MemberFinder assignAttributeValue2(Object theValue)
      find objects with this value2
      Parameters:
      theValue -
      Returns:
      this for chaining
    • assignAttributeValuesOnAssignment

      public MemberFinder assignAttributeValuesOnAssignment(Set<Object> theValues)
      if looking for an attribute value on an assignment, could be multiple values
      Parameters:
      theValues -
      Returns:
      this for chaining
    • assignAttributeValuesOnAssignment2

      public MemberFinder assignAttributeValuesOnAssignment2(Set<Object> theValues)
      if looking for an attribute value on an assignment2, could be multiple values
      Parameters:
      theValues -
      Returns:
      this for chaining
    • assignIdOfAttributeDefName

      public MemberFinder assignIdOfAttributeDefName(String theAttributeDefNameId)
      find groups that have this attribute def name id, note could be an assignment on an assignment
      Parameters:
      theAttributeDefNameId -
      Returns:
      this for chaining
    • assignIdOfAttributeDefName2

      public MemberFinder assignIdOfAttributeDefName2(String theAttributeDefNameId)
      find groups that have this attribute def name id, note could be an assignment on an assignment
      Parameters:
      theAttributeDefNameId -
      Returns:
      this for chaining
    • assignNameOfAttributeDefName

      public MemberFinder assignNameOfAttributeDefName(String theNameOfAttributeDefName)
      find groups that have this attribute assigned
      Parameters:
      theNameOfAttributeDefName -
      Returns:
      this for chaining
    • assignNameOfAttributeDefName2

      public MemberFinder assignNameOfAttributeDefName2(String theNameOfAttributeDefName)
      find groups that have this attribute assigned
      Parameters:
      theNameOfAttributeDefName -
      Returns:
      this for chaining
    • assignQueryOptions

      public MemberFinder assignQueryOptions(QueryOptions theQueryOptions)
      if sorting, paging, caching, etc
      Parameters:
      theQueryOptions -
      Returns:
      this for chaining
    • findAll

      public static Set findAll(GrouperSession s) throws GrouperException
      Find all members.
       Set members = MemberFinder.findAll(s);
       
      Parameters:
      s - Find all members within this session context.
      Returns:
      Set of Member objects.
      Throws:
      GrouperException
    • findAllUsed

      public static Set<Member> findAllUsed(GrouperSession grouperSession, Source source) throws GrouperException
      Find all members by source used somewhere, e.g. with memberships or attributes etc.
       Set members = MemberFinder.findAllUsed(s, source);
       
      Parameters:
      grouperSession - Find all members within this session context.
      source - Find all members with this source.
      Returns:
      Set of Member objects.
      Throws:
      GrouperException
    • findAll

      public static Set<Member> findAll(GrouperSession s, Source source) throws GrouperException
      Find all members by source.
       Set members = MemberFinder.findAll(s, source);
       
      Parameters:
      s - Find all members within this session context.
      source - Find all members with this source.
      Returns:
      Set of Member objects.
      Throws:
      GrouperException
    • internal_findMembersByType

      public static Set<Member> internal_findMembersByType(GrouperSession grouperSession, Group group, Field field, String type, Set<Source> sources, QueryOptions queryOptions, SortStringEnum memberSortStringEnum, SearchStringEnum memberSearchStringEnum, String memberSearchStringValue)

      Grouper internal method only

      make sure allowed to see them, and find the members
      Parameters:
      grouperSession -
      group -
      field -
      type -
      sources -
      queryOptions -
      memberSortStringEnum -
      memberSearchStringEnum -
      memberSearchStringValue -
      Returns:
      the members, dont return null
    • findBySubject

      @Deprecated public static Member findBySubject(GrouperSession s, Subject subj)
      Deprecated.
      use overload
      Convert a Subject to a Member. Create if not exist
       // Convert a subject to a Member object, create if not exist
         Member m = MemberFinder.findBySubject(s, subj);
       
      Parameters:
      s - Find Member within this session context.
      subj - Subject to convert.
      Returns:
      A Member object.
    • findBySubjectsInGroup

      public static Set<Member> findBySubjectsInGroup(GrouperSession grouperSession, Set<Subject> subjects, Group group, Field field, MembershipType membershipType)
      convert a set of subjects to a set of members
      Parameters:
      grouperSession -
      subjects - to convert to members
      group - that subjects must be in
      field - that they must be in in the group (null will default to eh members list
      membershipType - that they must be in in the group or null for any
      Returns:
      the members in the group
    • findBySubjects

      public static Set<Member> findBySubjects(Collection<Subject> subjects, boolean createIfNotExists)
      convert a set of subjects to a set of members
      Parameters:
      subjects - to convert to members
      createIfNotExists -
      group - that subjects must be in
      field - that they must be in in the group (null will default to eh members list
      membershipType - that they must be in in the group or null for any
      Returns:
      the members in the group
    • find

      public static Member find(String sourceId, String subjectId, String subjectIdentifier, String subjectIdOrIdentifier, String memberId)
      might want to make sure the user is root before doing this
      Parameters:
      sourceId -
      subjectId -
      subjectIdentifier -
      subjectIdOrIdentifier -
      memberId -
      Returns:
      the member
    • findBySubject

      public static Member findBySubject(GrouperSession s, Subject subj, boolean createIfNotExist)
      Convert a Subject to a Member.
       // Convert a subject to a Member object, create if not exist
         Member m = MemberFinder.findBySubject(s, subj, true);
       
      Parameters:
      s - Find Member within this session context.
      subj - Subject to convert.
      createIfNotExist - true if the member should be created if not there
      Returns:
      A Member object.
    • findBySubject

      public static Member findBySubject(GrouperSession s, Subject subj, boolean createIfNotExist, QueryOptions queryOptions)
      Convert a Subject to a Member.
       // Convert a subject to a Member object, create if not exist
         Member m = MemberFinder.findBySubject(s, subj, true);
       
      Parameters:
      s - Find Member within this session context.
      subj - Subject to convert.
      createIfNotExist - true if the member should be created if not there
      queryOptions -
      Returns:
      A Member object.
    • findByUuid

      @Deprecated public static Member findByUuid(GrouperSession s, String uuid) throws MemberNotFoundException
      Deprecated.
      Get a member by UUID.
       // Get a member by uuid.
       try {
         Member m = MemberFind.findByUuid(s, uuid);
       }
       catch (MemberNotFoundException e) {
         // Member not found
       }
       
      Parameters:
      s - Get Member within this session context.
      uuid - Get Member with this UUID.
      Returns:
      A Member object.
      Throws:
      MemberNotFoundException
    • findByUuid

      public static Member findByUuid(GrouperSession s, String uuid, boolean exceptionIfNotFound) throws MemberNotFoundException
      Get a member by UUID.
       // Get a member by uuid.
       Member m = MemberFind.findByUuid(s, uuid, false);
       
      Parameters:
      s - Get Member within this session context.
      uuid - Get Member with this UUID.
      exceptionIfNotFound - true to throw exception if not found
      Returns:
      A Member object.
      Throws:
      MemberNotFoundException
    • internal_findAllMember

      public static Member internal_findAllMember() throws GrouperException

      Grouper internal method only

      Returns:
      member
      Throws:
      GrouperException
    • internal_findRootMember

      public static Member internal_findRootMember() throws GrouperException

      Grouper internal method only

      Returns:
      member
      Throws:
      GrouperException
    • internal_findBySubject

      public static Member internal_findBySubject(Subject subj, String uuidIfCreate, boolean createIfNotExist)

      Grouper internal method only

      find a member, perhaps create a new one if not there
      Parameters:
      subj -
      uuidIfCreate - uuid to use if creating
      createIfNotExist -
      Returns:
      the member or null if not found
    • internal_findBySubject

      public static Member internal_findBySubject(Subject subj, String uuidIfCreate, boolean createIfNotExist, QueryOptions queryOptions)

      Grouper internal method only

      find a member, perhaps create a new one if not there
      Parameters:
      subj -
      uuidIfCreate - uuid to use if creating
      createIfNotExist -
      Returns:
      the member or null if not found
    • internal_findOrCreateBySubject

      public static Member internal_findOrCreateBySubject(String id, String src, String type)

      Grouper internal method only

      find a member
      Parameters:
      id -
      src -
      type -
      Returns:
      the member
    • memberCreatedCacheDelete

      public static void memberCreatedCacheDelete(String sourceId, String subjectId)

      Grouper internal method only

      Parameters:
      sourceId -
      subjectId -
    • internal_createMember

      public static Member internal_createMember(Subject subj, String memberUuidIfCreate)

      Grouper internal method only

      create a member
      Parameters:
      subj -
      memberUuidIfCreate -
      Returns:
      the member object
    • internal_findViewableMemberBySubject

      public static Member internal_findViewableMemberBySubject(GrouperSession s, Subject subj, boolean exceptionIfNotExist) throws InsufficientPrivilegeException, MemberNotFoundException

      Grouper internal method only

      Parameters:
      s -
      subj -
      exceptionIfNotExist -
      Returns:
      the member or null if exceptionIfNotExist is false
      Throws:
      InsufficientPrivilegeException
      MemberNotFoundException
    • internal_findReadableMemberBySubject

      public static Member internal_findReadableMemberBySubject(GrouperSession grouperSession, Subject subject, boolean exceptionIfNotExist, boolean createIfNotExist) throws MemberNotFoundException, InsufficientPrivilegeException

      Grouper internal method only

      find a member object and if group, make sure it is readable
      Parameters:
      grouperSession -
      subject -
      exceptionIfNotExist -
      createIfNotExist -
      Returns:
      the member
      Throws:
      MemberNotFoundException
      InsufficientPrivilegeException
    • clearInternalMembers

      public static void clearInternalMembers()

      Grouper internal method only

    • findInternalIdsByNames

      public static Map<MultiKey,Long> findInternalIdsByNames(Set<MultiKey> sourceIdsSubjectIds)
      this will cache for a minute, find internal ids by name
      Parameters:
      sourceIdsSubjectIds -
      Returns:
      the internal ids