Package edu.internet2.middleware.grouper
Class RegistrySubject
java.lang.Object
edu.internet2.middleware.grouper.GrouperAPI
edu.internet2.middleware.grouper.RegistrySubject
- All Implemented Interfaces:
HibGrouperLifecycle,GrouperCloneable,GrouperUtil.FieldValuable,Subject,Serializable,org.hibernate.classic.Lifecycle
A
Subject local to the Groups Registry.
NOTE: THIS CLASS IS NOT CONSIDERED STABLE AND MAY CHANGE IN FUTURE RELEASES.
- Since:
- 1.2.0
- Version:
- $Id: RegistrySubject.java,v 1.19 2009-09-02 05:57:26 mchyzer Exp $
- See Also:
-
Field Summary
Fields inherited from class edu.internet2.middleware.grouper.GrouperAPI
COLUMN_HIBERNATE_VERSION_NUMBER, dbVersion, FIELD_DB_VERSION, FIELD_HIBERNATE_VERSION_NUMBER, INITIAL_VERSION_NUMBERFields inherited from interface org.hibernate.classic.Lifecycle
NO_VETO, VETO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RegistrySubjectadd(GrouperSession s, String id, String type, String name) static RegistrySubjectadd(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) static voidstatic RegistrySubjectaddOrUpdate(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) static voidaddOrUpdateOrDeleteAttribute(RegistrySubject registrySubject, String subjectId, String attributeName, String attributeValue) static voidassignCreateOtherAttributes(boolean shouldCreateOtherAttributes) clone()deep clone the fields in this objectvoidDelete existingRegistrySubject.booleanstatic RegistrySubjectGets a map attribute names and values.getAttributes(boolean excludeInternalAttributes) Gets a map attribute names and values.getAttributeValue(String name) Return the value of the specified attribute.getAttributeValue(String attributeName, boolean excludeInternalAttributes) Returns the value of a single-valued attribute.getAttributeValueOrCommaSeparated(String attributeName) Returns the attribute value if single-valued, or if multi-valued, returns the values comma separated (with a space too).getAttributeValueOrCommaSeparated(String attributeName, boolean excludeInternalAttributes) Returns the attribute value if single-valued, or if multi-valued, returns the values comma separated (with a space too).getAttributeValues(String name) Return the values for the specified attribute.getAttributeValues(String attributeName, boolean excludeInternalAttributes) Returns the values of a multi-valued attribute, or a set of size one for a single valued attribute.getAttributeValueSingleValued(String attributeName) Returns the attribute value if single-valued, or if multi-valued, throws an exception.getAttributeValueSingleValued(String attributeName, boolean excludeInternalAttributes) Returns the attribute value if single-valued, or if multi-valued, throws an exception.Return this subject's description.getId()Return the subject id.getName()Return the subject's name.Return the source.get the source id of a subjectwe want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translationgetType()Return this subject'sSubjectType.get the type nameinthashCode()booleanstatic voidvoidvoidvoidsetResolvedFromSource(boolean isResolvedFromSource) true if resolved from source (rather than cache)voidsetTranslationMap(Map<String, Object> translationMap) we want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translationvoidsetTypeString(String type) toString()Methods inherited from class edu.internet2.middleware.grouper.GrouperAPI
dbVersion, dbVersionClear, dbVersionDifferentFields, dbVersionIsDifferent, dbVersionReset, fieldValue, getHibernateVersionNumber, onDelete, onLoad, onPostDelete, onPostSave, onPostUpdate, onPreDelete, onPreSave, onPreUpdate, onSave, onUpdate, setHibernateVersionNumber
-
Constructor Details
-
RegistrySubject
public RegistrySubject()
-
-
Method Details
-
clone
Description copied from class:GrouperAPIdeep clone the fields in this object- Specified by:
clonein interfaceGrouperCloneable- Specified by:
clonein classGrouperAPI- Returns:
- the clone of the object
- See Also:
-
add
public static RegistrySubject add(GrouperSession s, String id, String type, String name) throws GrouperException, InsufficientPrivilegeException Add aSubjectto aSourcewithin the Groups Registry.Subjects may only be added within a root-like session.
try { RegistrySubject subj = RegistrySubject.add(s, "subject id", "person", "name"); } catch (GrouperException eG) { // unable to add subject } catch (InsufficientPrivilegeException eIP) { // not privileged to add subject }- Parameters:
s- Create subject within this session context.id- The subject id to assign to the subject.type- The subject type to assign to the subject.name- The name to assign to the subject.- Returns:
- The created
RegistrySubject. - Throws:
GrouperExceptionInsufficientPrivilegeException- Since:
- 1.2.0
-
main
-
addFirstLastNameSubjectAttributes
public static void addFirstLastNameSubjectAttributes() -
assignCreateOtherAttributes
public static void assignCreateOtherAttributes(boolean shouldCreateOtherAttributes) -
add
public static RegistrySubject add(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) throws GrouperException, InsufficientPrivilegeException Add aSubjectto aSourcewithin the Groups Registry.Subjects may only be added within a root-like session.
try { RegistrySubject subj = RegistrySubject.add(s, "subject id", "person", "name"); } catch (GrouperException eG) { // unable to add subject } catch (InsufficientPrivilegeException eIP) { // not privileged to add subject }- Parameters:
s- Create subject within this session context.id- The subject id to assign to the subject.type- The subject type to assign to the subject.name- The name to assign to the subject.nameAttributeValue-loginid-description-email-- Returns:
- The created
RegistrySubject. - Throws:
GrouperExceptionInsufficientPrivilegeException- Since:
- 2.4.0
-
addOrUpdate
public static RegistrySubject addOrUpdate(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) throws GrouperException, InsufficientPrivilegeException Add or update aSubjectto aSourcewithin the Groups Registry.Subjects may only be added within a root-like session.
try { RegistrySubject subj = RegistrySubject.add(s, "subject id", "person", "name"); } catch (GrouperException eG) { // unable to add subject } catch (InsufficientPrivilegeException eIP) { // not privileged to add subject }- Parameters:
s- Create subject within this session context.id- The subject id to assign to the subject.type- The subject type to assign to the subject.name- The name to assign to the subject.loginid-description-email-- Returns:
- The created
RegistrySubject. - Throws:
GrouperExceptionInsufficientPrivilegeException- Since:
- 2.4.0
-
find
- Parameters:
id-exceptionIfNotFound-- Returns:
- the subject or null
-
addOrUpdateOrDeleteAttribute
public static void addOrUpdateOrDeleteAttribute(RegistrySubject registrySubject, String subjectId, String attributeName, String attributeValue) - Parameters:
registrySubject-subjectId-attributeName-attributeValue-
-
delete
public void delete(GrouperSession s) throws GrouperException, IllegalStateException, InsufficientPrivilegeException Delete existingRegistrySubject.try { rSubj.delete(s); } catch (GrouperException eG) { // failed to delete this RegistrySubject } catch (InsufficientPrivilegeException eIP) { // not privileged to delete this RegistrySubject }- Parameters:
s- Delete RegistrySubject within this GrouperSession context.- Throws:
GrouperException- if RegistrySubject cannot be deleted.IllegalStateException- if GrouperSession is null.InsufficientPrivilegeException- if not privileged to delete RegistrySubjects.- Since:
- 1.2.0
-
getAttributeValue
Return the value of the specified attribute.- Specified by:
getAttributeValuein interfaceSubject- Parameters:
name-- Returns:
- attribute value
-
getAttributeValues
Return the values for the specified attribute.- Specified by:
getAttributeValuesin interfaceSubject- Parameters:
name-- Returns:
- attributes
-
getDescription
Return this subject's description.- Specified by:
getDescriptionin interfaceSubject- Returns:
- description
-
getId
Return the subject id. -
getName
Return the subject's name. -
getSource
Return the source.NOTE: The current implementation is very crude and inefficient. It attempts to query for the subject to identify the source.
- Specified by:
getSourcein interfaceSubject- Returns:
- the source
- Throws:
IllegalStateException- if source cannot be returned.- Since:
- 1.2.0
-
getType
Return this subject'sSubjectType. -
getTypeString
- Returns:
- type string
-
equals
-
hashCode
public int hashCode() -
setId
- Parameters:
id-
-
setName
- Parameters:
name-
-
setTypeString
- Parameters:
type-
-
toString
-
getAttributeValueOrCommaSeparated
Description copied from interface:SubjectReturns the attribute value if single-valued, or if multi-valued, returns the values comma separated (with a space too). So if the values are: a b c; this would return the string: "a, b, c" Implementors can use the static helper in SubjectImpl. This does not return values for internal attributes. Note, the keys are case-insensitive
- Specified by:
getAttributeValueOrCommaSeparatedin interfaceSubject- Returns:
- value or values or null if not there
- See Also:
-
getAttributeValueSingleValued
Description copied from interface:SubjectReturns the attribute value if single-valued, or if multi-valued, throws an exception. Implementors can use the static helper in SubjectImpl. This does not return values for internal attributes. Note, the keys are case-insensitive- Specified by:
getAttributeValueSingleValuedin interfaceSubject- Returns:
- value or null if not there
- See Also:
-
getSourceId
Description copied from interface:Subjectget the source id of a subject- Specified by:
getSourceIdin interfaceSubject- Returns:
- the source id
- See Also:
-
getTypeName
Description copied from interface:Subjectget the type name- Specified by:
getTypeNamein interfaceSubject- Returns:
- the type name
- See Also:
-
getAttributes
Description copied from interface:SubjectGets a map attribute names and values. The map's key contains the attribute name and the map's value contains a Set of attribute value(s). This does not return internal attributes. Note, the keys are case-insensitive- Specified by:
getAttributesin interfaceSubject- Returns:
- map or empty map or null if not there
- See Also:
-
getAttributeValue
Description copied from interface:SubjectReturns the value of a single-valued attribute. If multivalued, this returns the first value. Note, the keys are case-insensitive- Specified by:
getAttributeValuein interfaceSubjectexcludeInternalAttributes- if true, values for internal attributes are not returned- Returns:
- value or null if not found
- See Also:
-
getAttributeValueOrCommaSeparated
public String getAttributeValueOrCommaSeparated(String attributeName, boolean excludeInternalAttributes) Description copied from interface:SubjectReturns the attribute value if single-valued, or if multi-valued, returns the values comma separated (with a space too). So if the values are: a b c; this would return the string: "a, b, c" Implementors can use the static helper in SubjectImpl. Note, the keys are case-insensitive
- Specified by:
getAttributeValueOrCommaSeparatedin interfaceSubjectexcludeInternalAttributes- if true, values for internal attributes are not returned- Returns:
- value or values or null if not there
- See Also:
-
getAttributeValueSingleValued
public String getAttributeValueSingleValued(String attributeName, boolean excludeInternalAttributes) Description copied from interface:SubjectReturns the attribute value if single-valued, or if multi-valued, throws an exception. Implementors can use the static helper in SubjectImpl. Note, the keys are case-insensitive- Specified by:
getAttributeValueSingleValuedin interfaceSubjectexcludeInternalAttributes- if true, values for internal attributes are not returned- Returns:
- value or null if not there
- See Also:
-
getAttributeValues
Description copied from interface:SubjectReturns the values of a multi-valued attribute, or a set of size one for a single valued attribute. Note the returned set should not be changed. Note, the keys are case-insensitive- Specified by:
getAttributeValuesin interfaceSubjectexcludeInternalAttributes- if true, values for internal attributes are not returned- Returns:
- set or empty set or null if not there
- See Also:
-
getAttributes
Description copied from interface:SubjectGets a map attribute names and values. The map's key contains the attribute name and the map's value contains a Set of attribute value(s). The returned Map can be augmented or changed. Note, the keys are case-insensitive- Specified by:
getAttributesin interfaceSubject- Parameters:
excludeInternalAttributes- if true, internal attributes are not returned- Returns:
- map or empty map or null if not there
- See Also:
-
getTranslationMap
Description copied from interface:Subjectwe want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation- Specified by:
getTranslationMapin interfaceSubject- Returns:
-
setTranslationMap
Description copied from interface:Subjectwe want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation- Specified by:
setTranslationMapin interfaceSubject
-
isResolvedFromSource
public boolean isResolvedFromSource()- Specified by:
isResolvedFromSourcein interfaceSubject- Returns:
- true if resolved from source (rather than cache)
-
setResolvedFromSource
public void setResolvedFromSource(boolean isResolvedFromSource) true if resolved from source (rather than cache)- Specified by:
setResolvedFromSourcein interfaceSubject- Parameters:
isResolvedFromSource-
-