Class SubjectFinder
- All Implemented Interfaces:
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();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
result to see if source if restricted by group -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassignAllowUnresolvable
(boolean theAllowUnresolvable) if should allow unresolvableassignExceptionIfNotFound
(boolean theExceptionIfNotFound) if there should be an exception if not found on one subject to queryassignIgnoreCachedSubjects
(boolean ignoreCachedSubjects) whether to ignore cached subjects, false by defaultassignMemberId
(String theMemberId) assign a member id to search forassignSourceId
(String theSourceId) assign the source id to search inassignSubjectId
(String theSubjectId) assign a subjectId to search forassignSubjectIdentifier
(String theSubjectIdentifier1) assign a subject identifier to search forassignSubjectIdOrIdentifier
(String theSubjectIdOrIdentifier) assign subject id or identifier to search forstatic void
decorateSubjects
(GrouperSession grouperSession, Set<Subject> subjects, Collection<String> attributeNamesRequested) decorate subjects based on subject customizer in grouper.propertiesstatic Subject
filterSubject
(GrouperSession grouperSession, Subject subject, String filterSubjectsInStemName) filter subjects based on subject customizer in grouper.propertiesstatic void
filterSubjectAttributesBasedOnGroup
(Collection<Subject> subjects) based on config: requireGroupNameForView, filter subjectsfilterSubjects
(GrouperSession grouperSession, Map<String, Subject> subjectMap, String filterSubjectsInStemName) filter subjects based on subject customizer in grouper.propertiesfilterSubjects
(GrouperSession grouperSession, Set<Subject> subjects, String filterSubjectsInStemName) filter subjects based on subject customizer in grouper.propertiesFind all subjects matching the query.Find all subjects matching the query within the specifiedSource
.Find all subjects matching the query within the specifiedSource
s.findAllInStem
(String stemName, String query) Find all subjects matching the query, in a certain folder.static Subject
Get GrouperAll subject.static Subject
Deprecated.static Subject
Search within all configured sources for subject with identified by id.static Subject
Search within all configured sources for subject with identified by id.static Subject
Deprecated.static Subject
Deprecated.since type is no longer an identifier...static Subject
Deprecated.static Subject
Deprecated.static Subject
findByIdAndSource
(String id, String source, boolean exceptionIfNull) Search within all configured sources for subject with identified by id.static Subject
findByIdAndSource
(String id, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) Search within all configured sources for subject with identified by id.static Subject
findByIdAndSourceIds
(String id, Set<String> sourceIds, boolean exceptionIfNull) Search within given sourcesstatic Subject
Deprecated.static Subject
findByIdentifier
(String id, boolean exceptionIfNotFound) Get a subject by a well-known identifier.static Subject
findByIdentifier
(String id, boolean ignoreCachedSubjects, boolean exceptionIfNotFound) Get a subject by a well-known identifier.static Subject
findByIdentifier
(String id, String type) Deprecated.static Subject
findByIdentifier
(String id, String type, boolean exceptionIfNull) Deprecated.use id or id/sourcestatic Subject
findByIdentifier
(String id, String type, String source) Deprecated.static Subject
findByIdentifier
(String id, String type, String source, boolean exceptionIfNull) Deprecated.static Subject
findByIdentifierAndSource
(String identifier, String source, boolean exceptionIfNull) Get a subject by a well-known identifier, and source.static Subject
findByIdentifierAndSource
(String identifier, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) Get a subject by a well-known identifier, and source.static Subject
findByIdentifierAndSourceIds
(String identifier, Set<String> sourceIds, boolean exceptionIfNull) Search within given sourcesfindByIdentifiers
(Collection<String> identifiers) find subjects by identifiersfindByIdentifiers
(Collection<String> identifiers, String source) find subjects by identifiersstatic Subject
findByIdOrIdentifier
(String idOrIdentifier, boolean exceptionIfNull) find by id or identifierstatic Subject
findByIdOrIdentifier
(String idOrIdentifier, boolean ignoreCachedSubjects, boolean exceptionIfNull) find by id or identifierstatic Subject
findByIdOrIdentifierAndSource
(String idOrIdentifier, String source, boolean exceptionIfNull) find by id or identifierstatic Subject
findByIdOrIdentifierAndSource
(String idOrIdentifier, String source, boolean ignoreCachedSubjects, boolean exceptionIfNull) find by id or identifierstatic Subject
findByIdOrIdentifierAndSource
(String idOrIdentifier, Set<Source> sources, boolean exceptionIfNull) find by id or identifier in certain sourcesstatic Subject
findByIdorIdentifierAndSourceIds
(String idOrIdentifier, Set<String> sourceIds, boolean exceptionIfNull) Search within given sourcesstatic Subject
findByIdOrIdentifierOrBothAndSourceIds
(String type, String lookupId, Set<String> sourceIds, boolean exceptionIfNull) Search by type within given sourcesfindByIds
(Collection<String> ids) find subjects by idsfindByIds
(Collection<String> ids, String source) find subjects by idsfindByIds
(Collection<String> ids, String source, boolean resolveAsLazySubjects) find subjects by idsfindByIds
(Collection<String> ids, String source, boolean resolveAsLazySubjects, boolean ignoreCachedSubjects) find subjects by idsfindByIdsOrIdentifiers
(Collection<String> idsOrIdentifiers) find subjects by idsOrIdentifiersfindByIdsOrIdentifiers
(Collection<String> idsOrIdentifiers, String source) find subjects by idsOrIdentifiersfindByIdsOrIdentifiers
(Collection<String> idsOrIdentifiers, Set<Source> sources) find subjects by idsOrIdentifiersfindByMembers
(Collection<Member> members) find subjects by membersstatic Subject
findByOptionalArgs
(String sourceId, String subjectId, String subjectIdentifier, boolean exceptionIfNotFound) pass in the source (optional), and the id or identifierstatic Subject
findByPackedSubjectString
(String subjectString, boolean exceptionIfNotFound) Find a subject by packed subject string.findBySourceIdsAndSubjectIds
(Collection<MultiKey> sourceIdsSubjectIds, boolean resolveAsLazySubjects) find subjects by idsfindBySourceIdsAndSubjectIds
(Collection<MultiKey> sourceIdsSubjectIds, boolean resolveAsLazySubjects, boolean ignoreCachedSubjects) find subjects by idsstatic Map<SubjectBean,
Subject> findBySubjectBeans
(Collection<SubjectBean> subjectBeans) find by subject beansfindBySubjectsInGroup
(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 groupstatic SearchPageResult
Find a page of subjects matching the query.static SearchPageResult
Find a page of subjects matching the query within the specifiedSource
.static SearchPageResult
Find a page of subjects matching the query within the specifiedSource
s.static SearchPageResult
findPageInStem
(String stemName, String query) Find a page of subjects matching the query, in a certain folder.static SearchPageResult
findPageInStem
(String stemName, String query, Set<Source> sources) Find a page of subjects matching the query, in a certain folder.static Subject
Get GrouperSystem subject.static void
flush the cache (e.g.static Source
try { Source sa = SubjectFinder.getSource(id); } catch (SourceUnavailableException eSU) { // unable to retrieve source }Set sources = SubjectFinder.getSources();static GrouperSession
Deprecated.DONT USE THISstatic Source
internal_getEntitySourceAdapter
(boolean failIfError) Grouper internal method onlystatic Source
Grouper internal method onlystatic void
Grouper internal method onlystatic boolean
if we should use threads when doing searches (if grouper.properties allows)static void
reset()
ResetSubjectResolver
.restrictSourceForGroup
(String stemName, String sourceId) static SubjectCustomizer
get the subject customizerstatic void
useThreads
(boolean ifUseThreads) if we should use threads when doing searches (if grouper.properties allows), this must be used in a try/finally
-
Constructor Details
-
SubjectFinder
public SubjectFinder()
-
-
Method Details
-
assignSubjectId
assign a subjectId to search for- Parameters:
theSubjectId
-- Returns:
- this for chaining
-
assignSourceId
assign the source id to search in- Parameters:
theSourceId
-- Returns:
- this for chaining
-
assignSubjectIdentifier
assign a subject identifier to search for- Parameters:
theSubjectIdentifier1
-- Returns:
- this for chaining
-
assignAllowUnresolvable
if should allow unresolvable- Parameters:
theAllowUnresolvable
-- Returns:
- self for chaining
-
assignIgnoreCachedSubjects
whether to ignore cached subjects, false by default- Parameters:
ignoreCachedSubjects
-- Returns:
- self for chaining
-
assignSubjectIdOrIdentifier
assign subject id or identifier to search for- Parameters:
theSubjectIdOrIdentifier
-- Returns:
- this for chaining
-
assignMemberId
assign a member id to search for- Parameters:
theMemberId
-- Returns:
- this for chaining
-
assignExceptionIfNotFound
if there should be an exception if not found on one subject to query- Parameters:
theExceptionIfNotFound
-- Returns:
- this for chaining
-
findSubject
-
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 public static Subject findById(String id) throws SubjectNotFoundException, SubjectNotUniqueException 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 IDexceptionIfNull
-- 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 IDignoreCachedSubjects
-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 IDsource
- is the source to check inexceptionIfNull
-- 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 IDsource
- is the source to check inignoreCachedSubjects
-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
find by subject beans- Parameters:
subjectBeans
-- Returns:
- the subjects
-
findByMembers
find subjects by members- Parameters:
members
-- Returns:
- the map of sourceId, subjectId, to subject
-
findByIds
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
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
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 public static Subject findById(String id, String type) throws SubjectNotFoundException, SubjectNotUniqueException 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 IDtype
- Subject type.- Returns:
- A
Subject
object - Throws:
SubjectNotFoundException
SubjectNotUniqueException
-
findById
@Deprecated public static Subject findById(String id, String type, String source) 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 IDtype
- 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 public static Subject findByIdentifier(String id, String type, String source) 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.- Returns:
- A
Subject
object - Throws:
SourceUnavailableException
SubjectNotFoundException
SubjectNotUniqueException
-
findAll
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
ofSubject
objects. - Throws:
SubjectTooManyResults
- if more results than configured
-
findAllInStem
Find all subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those foldersThe 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 inquery
- Subject query string.- Returns:
- A
Set
ofSubject
objects. - Throws:
SubjectTooManyResults
- if more results than configured
-
findAll
Find all subjects matching the query within the specifiedSource
.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
ofSubject
s. - Throws:
SourceUnavailableException
-
findAll
public static Set<Subject> findAll(String query, Set<Source> sources) throws SourceUnavailableException Find all subjects matching the query within the specifiedSource
s.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
ofSubject
s. - Throws:
SourceUnavailableException
-
findAllSubject
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
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
Set sources = SubjectFinder.getSources();
- Returns:
- Set of all
Source
adapters.
-
retrieveCheckboxAttributes
- Specified by:
retrieveCheckboxAttributes
in interfaceCheckboxValueDriver
- 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
Grouper internal method only
- Returns:
- source
- Since:
- 1.2.0
-
internal_getEntitySourceAdapter
Grouper internal method only
- Parameters:
failIfError
-- Returns:
- source
- Since:
- 2.1.0
-
reset
public static void reset()ResetSubjectResolver
.- 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/sourceSearch 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 IDtype
- 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 IDtype
- Subject type. If blank dont consider typesource
- 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/sourceGet 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 membersgroup
- that subjects must be infield
- that they must be in in the group (null will default to eh members listmembershipType
- 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
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
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
ofSubject
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 specifiedSource
s.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
ofSubject
s 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 specifiedSource
.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
ofSubject
s and if too many. - Throws:
SourceUnavailableException
-
findPageInStem
Find a page of subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those foldersThe 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 inquery
- Subject query string.- Returns:
- A
Set
ofSubject
objects. - Throws:
SubjectTooManyResults
- if more results than configured
-
findPageInStem
Find a page of subjects matching the query, in a certain folder. If there are rules restricting subjects, then dont search those foldersThe 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 inquery
- Subject query string.- Returns:
- A
Set
ofSubject
objects. - Throws:
SubjectTooManyResults
- if more results than configured
-
findByIdentifiers
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
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
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 subjectfilterSubjectsInStemName
-- 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
get the subject customizer- Returns:
- subject customizer or null
-