Class SubjectFinder

java.lang.Object
edu.internet2.middleware.grouper.SubjectFinder
All Implemented Interfaces:
CheckboxValueDriver

public class SubjectFinder extends Object implements CheckboxValueDriver

Use this class to find subjects

Sample call

 Subject subject = SubjectFinder.findById(uuid, true);
 

Retrieve unresolvable

 Subject subject = new SubjectFinder().assignSourceId("mysourceId").assignSubjectId("theSubjectId").assignAllowUnresolvable(true).findSubject();
 

  • Constructor Details

    • SubjectFinder

      public SubjectFinder()
  • Method Details

    • assignSubjectId

      public SubjectFinder assignSubjectId(String theSubjectId)
      assign a subjectId to search for
      Parameters:
      theSubjectId -
      Returns:
      this for chaining
    • assignSourceId

      public SubjectFinder assignSourceId(String theSourceId)
      assign the source id to search in
      Parameters:
      theSourceId -
      Returns:
      this for chaining
    • assignSubjectIdentifier

      public SubjectFinder assignSubjectIdentifier(String theSubjectIdentifier1)
      assign a subject identifier to search for
      Parameters:
      theSubjectIdentifier1 -
      Returns:
      this for chaining
    • assignAllowUnresolvable

      public SubjectFinder assignAllowUnresolvable(boolean theAllowUnresolvable)
      if should allow unresolvable
      Parameters:
      theAllowUnresolvable -
      Returns:
      self for chaining
    • assignIgnoreCachedSubjects

      public SubjectFinder assignIgnoreCachedSubjects(boolean ignoreCachedSubjects)
      whether to ignore cached subjects, false by default
      Parameters:
      ignoreCachedSubjects -
      Returns:
      self for chaining
    • assignSubjectIdOrIdentifier

      public SubjectFinder assignSubjectIdOrIdentifier(String theSubjectIdOrIdentifier)
      assign subject id or identifier to search for
      Parameters:
      theSubjectIdOrIdentifier -
      Returns:
      this for chaining
    • assignMemberId

      public SubjectFinder assignMemberId(String theMemberId)
      assign a member id to search for
      Parameters:
      theMemberId -
      Returns:
      this for chaining
    • assignExceptionIfNotFound

      public SubjectFinder assignExceptionIfNotFound(boolean theExceptionIfNotFound)
      if there should be an exception if not found on one subject to query
      Parameters:
      theExceptionIfNotFound -
      Returns:
      this for chaining
    • findSubject

      public Subject findSubject()
    • grouperSessionOrRootForSubjectFinder

      @Deprecated public static GrouperSession grouperSessionOrRootForSubjectFinder()
      Deprecated.
      DONT USE THIS
      Returns:
      session
    • useThreads

      public static void useThreads(boolean ifUseThreads)
      if we should use threads when doing searches (if grouper.properties allows), this must be used in a try/finally
      Parameters:
      ifUseThreads -
    • isUseThreadsBasedOnThreadLocal

      public static boolean isUseThreadsBasedOnThreadLocal()
      if we should use threads when doing searches (if grouper.properties allows)
      Returns:
      isUseThreadsBasedOnThreadLocal
    • findByIdOrIdentifier

      public static Subject findByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      find by id or identifier
      Parameters:
      idOrIdentifier -
      exceptionIfNull - if SubjectNotFoundException or null
      Returns:
      the subject
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdOrIdentifier

      public static Subject findByIdOrIdentifier(String idOrIdentifier, boolean ignoreCachedSubjects, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      find by id or identifier
      Parameters:
      idOrIdentifier -
      ignoreCachedSubjects -
      exceptionIfNull - if SubjectNotFoundException or null
      Returns:
      the subject
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByOptionalArgs

      public static Subject findByOptionalArgs(String sourceId, String subjectId, String subjectIdentifier, boolean exceptionIfNotFound)
      pass in the source (optional), and the id or identifier
      Parameters:
      sourceId -
      subjectId -
      subjectIdentifier -
      exceptionIfNotFound -
      Returns:
      the subject or null
    • findByIdOrIdentifierAndSource

      public static Subject findByIdOrIdentifierAndSource(String idOrIdentifier, String source, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      find by id or identifier
      Parameters:
      idOrIdentifier -
      source -
      exceptionIfNull - if SubjectNotFoundException or null
      Returns:
      the subject
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdOrIdentifierAndSource

      public static Subject findByIdOrIdentifierAndSource(String idOrIdentifier, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      find by id or identifier
      Parameters:
      idOrIdentifier -
      source -
      ignoreCachedSubjects -
      exceptionIfNull - if SubjectNotFoundException or null
      Returns:
      the subject
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdOrIdentifierAndSource

      public static Subject findByIdOrIdentifierAndSource(String idOrIdentifier, Set<Source> sources, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      find by id or identifier in certain sources
      Parameters:
      idOrIdentifier -
      sources -
      exceptionIfNull - if SubjectNotFoundException or null
      Returns:
      the subject
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findById

      Deprecated.
      Search within all configured sources for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findById(subjectID);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findById

      public static Subject findById(String id, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within all configured sources for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findById(subjectID);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findById

      public static Subject findById(String id, boolean ignoreCachedSubjects, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within all configured sources for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findById(subjectID);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      ignoreCachedSubjects -
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdAndSource

      public static Subject findByIdAndSource(String id, String source, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within all configured sources for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findByIdAndSource(subjectID, source, true);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      source - is the source to check in
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdAndSource

      public static Subject findByIdAndSource(String id, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within all configured sources for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findByIdAndSource(subjectID, source, true);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      source - is the source to check in
      ignoreCachedSubjects -
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdAndSourceIds

      public static Subject findByIdAndSourceIds(String id, Set<String> sourceIds, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within given sources
      Parameters:
      id -
      sourceIds -
      exceptionIfNull -
      Returns:
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifierAndSourceIds

      public static Subject findByIdentifierAndSourceIds(String identifier, Set<String> sourceIds, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within given sources
      Parameters:
      identifier -
      sourceIds -
      exceptionIfNull -
      Returns:
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdorIdentifierAndSourceIds

      public static Subject findByIdorIdentifierAndSourceIds(String idOrIdentifier, Set<String> sourceIds, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search within given sources
      Parameters:
      idOrIdentifier -
      sourceIds -
      exceptionIfNull -
      Returns:
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdOrIdentifierOrBothAndSourceIds

      public static Subject findByIdOrIdentifierOrBothAndSourceIds(String type, String lookupId, Set<String> sourceIds, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Search by type within given sources
      Parameters:
      type -
      lookupId -
      sourceIds -
      exceptionIfNull -
      Returns:
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findBySubjectBeans

      public static Map<SubjectBean,Subject> findBySubjectBeans(Collection<SubjectBean> subjectBeans)
      find by subject beans
      Parameters:
      subjectBeans -
      Returns:
      the subjects
    • findByMembers

      public static Map<MultiKey,Subject> findByMembers(Collection<Member> members)
      find subjects by members
      Parameters:
      members -
      Returns:
      the map of sourceId, subjectId, to subject
    • findByIds

      public static Map<String,Subject> findByIds(Collection<String> ids)
      find subjects by ids
      Parameters:
      ids -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • findByIdsOrIdentifiers

      public static Map<String,Subject> findByIdsOrIdentifiers(Collection<String> idsOrIdentifiers)
      find subjects by idsOrIdentifiers
      Parameters:
      idsOrIdentifiers -
      Returns:
      the map of id or identifier to subject. If a subject is not found, it will not be in the result
    • findByIdsOrIdentifiers

      public static Map<String,Subject> findByIdsOrIdentifiers(Collection<String> idsOrIdentifiers, String source)
      find subjects by idsOrIdentifiers
      Parameters:
      idsOrIdentifiers -
      source -
      Returns:
      the map of id or identifier to subject. If a subject is not found, it will not be in the result
    • findByIdsOrIdentifiers

      public static Map<String,Subject> findByIdsOrIdentifiers(Collection<String> idsOrIdentifiers, Set<Source> sources)
      find subjects by idsOrIdentifiers
      Parameters:
      idsOrIdentifiers -
      sources -
      Returns:
      the map of id or identifier to subject. If a subject is not found, it will not be in the result
    • findByIdentifiers

      public static Map<String,Subject> findByIdentifiers(Collection<String> identifiers)
      find subjects by identifiers
      Parameters:
      identifiers -
      Returns:
      the map of identifier to subject. If a subject is not found, it will not be in the result
    • flushCache

      public static void flushCache()
      flush the cache (e.g. for testing)
    • findById

      Deprecated.
      Search within all configured sources providing type for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findById(subjectID, type);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      type - Subject type.
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findById

      Deprecated.
      Search for subject by id, type and source.
       try {
         Subject subj = SubjectFinder.findById(id, type, source);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
       catch (SubjectNotFoundException eSNF) {
         // subject not found
       }
        
      Parameters:
      id - Subject ID
      type - Subject type.
      source - Subject source.
      Returns:
      Matching subject.
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      @Deprecated public static Subject findByIdentifier(String id) throws SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      Get a subject by a well-known identifier.
       try {
         Subject subj = SubjectFinder.findByIdentifier(identifier);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject identifier.
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      @Deprecated public static Subject findByIdentifier(String id, String type) throws SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      Get a subject by a well-known identifier and the specified type.
       try {
         Subject subj = SubjectFinder.findByIdentifier(identifier, type);
       }
       catch (SubjectNotFoundException eSNF)  {
         // subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // subject not found
       }
        
      Parameters:
      id - Subject identifier.
      type - Subject type.
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      Deprecated.
      Get a subject by a well-known identifier, type and source.

      NOTE: This method does not perform any caching.

       try {
         Subject subj = SubjectFinder.findByIdentifier(id, type, source);
       }
       catch (SubjectNotFoundException e) {
         // Subject not found
       }
        
      Parameters:
      id - Well-known identifier.
      type - Subject type.
      source - Source adapter to search.
      Returns:
      A Subject object
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findAll

      public static Set<Subject> findAll(String query)
      Find all subjects matching the query.

      The query string specification is currently unique to each subject source adapter. Queries may not work or may lead to erratic results across different source adapters. Consult the documentation for each source adapter for more information on the query language supported by each adapter.

      NOTE: This method does not perform any caching.

       // Find all subjects matching the given query string.
       Set subjects = SubjectFinder.findAll(query);
       
      Parameters:
      query - Subject query string.
      Returns:
      A Set of Subject objects.
      Throws:
      SubjectTooManyResults - if more results than configured
    • findAllInStem

      public static Set<Subject> findAllInStem(String stemName, String query)
      Find all subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those folders

      The query string specification is currently unique to each subject source adapter. Queries may not work or may lead to erratic results across different source adapters. Consult the documentation for each source adapter for more information on the query language supported by each adapter.

      NOTE: This method does not perform any caching.

       // Find all subjects matching the given query string.
       Set subjects = SubjectFinder.findAll(query);
       
      Parameters:
      stemName - stem name to search in
      query - Subject query string.
      Returns:
      A Set of Subject objects.
      Throws:
      SubjectTooManyResults - if more results than configured
    • findAll

      public static Set<Subject> findAll(String query, String source) throws SourceUnavailableException
      Find all subjects matching the query within the specified Source.

      NOTE: This method does not perform any caching.

       try {
         Set subjects = SubjectFinder.findAll(query, source);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
        
      Parameters:
      query - Subject query string.r.
      source - Source adapter to search.
      Returns:
      A Set of Subjects.
      Throws:
      SourceUnavailableException
    • findAll

      public static Set<Subject> findAll(String query, Set<Source> sources) throws SourceUnavailableException
      Find all subjects matching the query within the specified Sources.

      NOTE: This method does not perform any caching.

       try {
         Set subjects = SubjectFinder.findAll(query, sources);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
        
      Parameters:
      query - Subject query string.
      sources - Source adapters to search.
      Returns:
      A Set of Subjects.
      Throws:
      SourceUnavailableException
    • findAllSubject

      public static Subject findAllSubject() throws GrouperException
      Get GrouperAll subject.
       Subject all = SubjectFinder.findAllSubject();
        
      Returns:
      The GrouperAll Subject Get GrouperAll subject.
       Subject all = SubjectFinder.findAllSubject();
        
      Throws:
      GrouperException - if unable to retrieve GrouperAll.
      Since:
      1.1.0
    • findRootSubject

      public static Subject findRootSubject() throws GrouperException
      Get GrouperSystem subject.
       Subject root = SubjectFinder.findRootSubject();
        
      Returns:
      The GrouperSystem subject.
      Throws:
      GrouperException - if unable to retrieve GrouperSystem.
      Since:
      1.1.0
    • getSource

      public static Source getSource(String id) throws IllegalArgumentException, SourceUnavailableException
       try {
         Source sa = SubjectFinder.getSource(id);
       }
       catch (SourceUnavailableException eSU) {
         // unable to retrieve source
       }
       
      Parameters:
      id -
      Returns:
      Source identified by id.
      Throws:
      IllegalArgumentException - if id is null.
      SourceUnavailableException - if unable to retrieve source.
    • getSources

      public static Set<Source> getSources()
       Set sources = SubjectFinder.getSources();
       
      Returns:
      Set of all Source adapters.
    • retrieveCheckboxAttributes

      public List<MultiKey> retrieveCheckboxAttributes()
      Specified by:
      retrieveCheckboxAttributes in interface CheckboxValueDriver
      Returns:
      list of multikeys. first key is id, second key is name and the third key is should this checkbox be auto selected or not
    • internal_getGSA

      public static Source internal_getGSA()

      Grouper internal method only

      Returns:
      source
      Since:
      1.2.0
    • internal_getEntitySourceAdapter

      public static Source internal_getEntitySourceAdapter(boolean failIfError)

      Grouper internal method only

      Parameters:
      failIfError -
      Returns:
      source
      Since:
      2.1.0
    • reset

      public static void reset()
      Reset SubjectResolver.
      Since:
      1.2.1
    • findById

      @Deprecated public static Subject findById(String id, String type, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      since type is no longer an identifier... just use id or id/source
      Search within all configured sources providing type for subject with identified by id.
       try {
         Subject subj = SubjectFinder.findById(subjectID, type);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject ID
      type - Subject type.
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findById

      @Deprecated public static Subject findById(String id, String type, String source, boolean exceptionIfNull) throws SourceUnavailableException, SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      Search for subject by id, type and source.
       try {
         Subject subj = SubjectFinder.findById(id, type, source);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
       catch (SubjectNotFoundException eSNF) {
         // subject not found
       }
        
      Parameters:
      id - Subject ID
      type - Subject type. If blank dont consider type
      source - Subject source.
      exceptionIfNull -
      Returns:
      Matching subject.
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      public static Subject findByIdentifier(String id, boolean exceptionIfNotFound) throws SubjectNotFoundException, SubjectNotUniqueException
      Get a subject by a well-known identifier.
       try {
         Subject subj = SubjectFinder.findByIdentifier(identifier);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject identifier.
      exceptionIfNotFound -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      public static Subject findByIdentifier(String id, boolean ignoreCachedSubjects, boolean exceptionIfNotFound) throws SubjectNotFoundException, SubjectNotUniqueException
      Get a subject by a well-known identifier.
       try {
         Subject subj = SubjectFinder.findByIdentifier(identifier);
       }
       catch (SubjectNotFoundException eSNF)  {
         // Subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // Subject not unique
       }
        
      Parameters:
      id - Subject identifier.
      ignoreCachedSubjects -
      exceptionIfNotFound -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      @Deprecated public static Subject findByIdentifier(String id, String type, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      use id or id/source
      Get a subject by a well-known identifier and the specified type.
       try {
         Subject subj = SubjectFinder.findByIdentifier(identifier, type);
       }
       catch (SubjectNotFoundException eSNF)  {
         // subject not found
       }
       catch (SubjectNotUniqueException eSNU) {
         // subject not found
       }
        
      Parameters:
      id - Subject identifier.
      type - Subject type.
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifier

      @Deprecated public static Subject findByIdentifier(String id, String type, String source, boolean exceptionIfNull) throws SourceUnavailableException, SubjectNotFoundException, SubjectNotUniqueException
      Deprecated.
      Get a subject by a well-known identifier, type and source.

      NOTE: This method does not perform any caching.

       try {
         Subject subj = SubjectFinder.findByIdentifier(id, type, source);
       }
       catch (SubjectNotFoundException e) {
         // Subject not found
       }
        
      Parameters:
      id - Well-known identifier.
      type - Subject type.
      source - Source adapter to search.
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findBySubjectsInGroup

      public static Set<Subject> findBySubjectsInGroup(GrouperSession grouperSession, Set<Subject> subjects, Group group, Field field, MembershipType membershipType)
      convert a set of subjects to a set of subject that are in a group
      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 subjects in the group (never null)
    • findByIdentifierAndSource

      public static Subject findByIdentifierAndSource(String identifier, String source, boolean exceptionIfNull) throws SourceUnavailableException, SubjectNotFoundException, SubjectNotUniqueException
      Get a subject by a well-known identifier, and source.

      NOTE: This method does not perform any caching.

       try {
         Subject subj = SubjectFinder.findByIdentifierAndSource(id, source, true);
       }
       catch (SubjectNotFoundException e) {
         // Subject not found
       }
        
      Parameters:
      identifier - Well-known identifier.
      source - Source adapter to search.
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByIdentifierAndSource

      public static Subject findByIdentifierAndSource(String identifier, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) throws SourceUnavailableException, SubjectNotFoundException, SubjectNotUniqueException
      Get a subject by a well-known identifier, and source.

      NOTE: This method does not perform any caching.

       try {
         Subject subj = SubjectFinder.findByIdentifierAndSource(id, source, true);
       }
       catch (SubjectNotFoundException e) {
         // Subject not found
       }
        
      Parameters:
      identifier - Well-known identifier.
      source - Source adapter to search.
      ignoreCachedSubjects -
      exceptionIfNull -
      Returns:
      A Subject object
      Throws:
      SourceUnavailableException
      SubjectNotFoundException
      SubjectNotUniqueException
    • findByPackedSubjectString

      public static Subject findByPackedSubjectString(String subjectString, boolean exceptionIfNotFound)
       Find a subject by packed subject string.  This could be a four colons then subjectId or six colons then a subjectIdentifier, or
       a source then four colons, then subjectId, or a source then six colons then a subjectIdentifier. 
       or a subjectIdOrIdentifier, or a source, then eight colons, then a subjectIdentifier e.g.
       subjectIdOrIdentifier
       sourceId::::subjectId
       ::::subjectId
       sourceId::::::subjectIdentifier
       ::::::subjectIdentifier
       sourceId::::::::subjectIdOrIdentifier
       ::::::::subjectIdOrIdentifier
       
      Parameters:
      subjectString -
      exceptionIfNotFound -
      Returns:
      the subject
    • restrictSourceForGroup

      public static SubjectFinder.RestrictSourceForGroup restrictSourceForGroup(String stemName, String sourceId)
      Parameters:
      sourceId -
      stemName -
      Returns:
      if restricted and to what extent
    • findPage

      public static SearchPageResult findPage(String query)
      Find a page of subjects matching the query.

      The query string specification is currently unique to each subject source adapter. Queries may not work or may lead to erratic results across different source adapters. Consult the documentation for each source adapter for more information on the query language supported by each adapter.

      NOTE: This method does not perform any caching.

       // Find all subjects matching the given query string.
       SearchPageResult subjects = SubjectFinder.findPage(query);
       
      Parameters:
      query - Subject query string.
      Returns:
      A Set of Subject objects and if there are too many.
      Throws:
      SubjectTooManyResults - if more results than configured
    • findPage

      public static SearchPageResult findPage(String query, Set<Source> sources) throws SourceUnavailableException
      Find a page of subjects matching the query within the specified Sources.

      NOTE: This method does not perform any caching.

       try {
         SearchPageResult subjects = SubjectFinder.findPage(query, sources);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
        
      Parameters:
      query - Subject query string.
      sources - Source adapters to search.
      Returns:
      A Set of Subjects and if there are too many.
      Throws:
      SourceUnavailableException
    • findPage

      public static SearchPageResult findPage(String query, String source) throws SourceUnavailableException
      Find a page of subjects matching the query within the specified Source.

      NOTE: This method does not perform any caching.

       try {
         Set subjects = SubjectFinder.findPage(query, source);
       }
       catch (SourceUnavailableException eSU) {
         // unable to query source
       }
        
      Parameters:
      query - Subject query string.r.
      source - Source adapter to search.
      Returns:
      A Set of Subjects and if too many.
      Throws:
      SourceUnavailableException
    • findPageInStem

      public static SearchPageResult findPageInStem(String stemName, String query)
      Find a page of subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those folders

      The query string specification is currently unique to each subject source adapter. Queries may not work or may lead to erratic results across different source adapters. Consult the documentation for each source adapter for more information on the query language supported by each adapter.

      NOTE: This method does not perform any caching.

       // Find all subjects matching the given query string.
       Set subjects = SubjectFinder.findAll(query);
       
      Parameters:
      stemName - stem name to search in
      query - Subject query string.
      Returns:
      A Set of Subject objects.
      Throws:
      SubjectTooManyResults - if more results than configured
    • findPageInStem

      public static SearchPageResult findPageInStem(String stemName, String query, Set<Source> sources)
      Find a page of subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those folders

      The query string specification is currently unique to each subject source adapter. Queries may not work or may lead to erratic results across different source adapters. Consult the documentation for each source adapter for more information on the query language supported by each adapter.

      NOTE: This method does not perform any caching.

       // Find all subjects matching the given query string.
       Set subjects = SubjectFinder.findAll(query);
       
      Parameters:
      stemName - stem name to search in
      query - Subject query string.
      Returns:
      A Set of Subject objects.
      Throws:
      SubjectTooManyResults - if more results than configured
    • findByIdentifiers

      public static Map<String,Subject> findByIdentifiers(Collection<String> identifiers, String source)
      find subjects by identifiers
      Parameters:
      identifiers -
      source -
      Returns:
      the map of identifier to subject. If a subject is not found, it will not be in the result
    • findByIds

      public static Map<String,Subject> findByIds(Collection<String> ids, String source)
      find subjects by ids
      Parameters:
      ids -
      source -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • findByIds

      public static Map<String,Subject> findByIds(Collection<String> ids, String source, boolean resolveAsLazySubjects)
      find subjects by ids
      Parameters:
      ids -
      source -
      resolveAsLazySubjects -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • findByIds

      public static Map<String,Subject> findByIds(Collection<String> ids, String source, boolean resolveAsLazySubjects, boolean ignoreCachedSubjects)
      find subjects by ids
      Parameters:
      ids -
      source -
      resolveAsLazySubjects -
      ignoreCachedSubjects -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • findBySourceIdsAndSubjectIds

      public static Map<MultiKey,Subject> findBySourceIdsAndSubjectIds(Collection<MultiKey> sourceIdsSubjectIds, boolean resolveAsLazySubjects)
      find subjects by ids
      Parameters:
      ids -
      source -
      resolveAsLazySubjects -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • findBySourceIdsAndSubjectIds

      public static Map<MultiKey,Subject> findBySourceIdsAndSubjectIds(Collection<MultiKey> sourceIdsSubjectIds, boolean resolveAsLazySubjects, boolean ignoreCachedSubjects)
      find subjects by ids
      Parameters:
      sourceIdsSubjectIds -
      resolveAsLazySubjects -
      Returns:
      the map of id to subject. If a subject is not found, it will not be in the result
    • decorateSubjects

      public static void decorateSubjects(GrouperSession grouperSession, Set<Subject> subjects, Collection<String> attributeNamesRequested)
      decorate subjects based on subject customizer in grouper.properties
      Parameters:
      grouperSession -
      subjects -
      attributeNamesRequested -
    • filterSubjectAttributesBasedOnGroup

      public static void filterSubjectAttributesBasedOnGroup(Collection<Subject> subjects)
      based on config: requireGroupNameForView, filter subjects
      Parameters:
      subjects -
    • filterSubjects

      public static Map<String,Subject> filterSubjects(GrouperSession grouperSession, Map<String,Subject> subjectMap, String filterSubjectsInStemName)
      filter subjects based on subject customizer in grouper.properties
      Parameters:
      grouperSession -
      subjectMap - is map os subject id to subject
      filterSubjectsInStemName -
      Returns:
      subject map
    • filterSubjects

      public static Set<Subject> filterSubjects(GrouperSession grouperSession, Set<Subject> subjects, String filterSubjectsInStemName)
      filter subjects based on subject customizer in grouper.properties
      Parameters:
      grouperSession -
      subjects -
      filterSubjectsInStemName -
      Returns:
      subjects
    • filterSubject

      public static Subject filterSubject(GrouperSession grouperSession, Subject subject, String filterSubjectsInStemName)
      filter subjects based on subject customizer in grouper.properties
      Parameters:
      grouperSession -
      subject -
      filterSubjectsInStemName -
      Returns:
      subjects
    • internalClearSubjectCustomizerCache

      public static void internalClearSubjectCustomizerCache()

      Grouper internal method only

      clea the subject customizer cache
    • subjectCustomizer

      public static SubjectCustomizer subjectCustomizer()
      get the subject customizer
      Returns:
      subject customizer or null