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_NUMBER
Fields inherited from interface org.hibernate.classic.Lifecycle
NO_VETO, VETO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RegistrySubject
add
(GrouperSession s, String id, String type, String name) static RegistrySubject
add
(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) static void
static RegistrySubject
addOrUpdate
(GrouperSession s, String id, String type, String name, String nameAttributeValue, String loginid, String description, String email) static void
addOrUpdateOrDeleteAttribute
(RegistrySubject registrySubject, String subjectId, String attributeName, String attributeValue) static void
assignCreateOtherAttributes
(boolean shouldCreateOtherAttributes) clone()
deep clone the fields in this objectvoid
Delete existingRegistrySubject
.boolean
static RegistrySubject
Gets 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 nameint
hashCode()
boolean
static void
void
void
void
setResolvedFromSource
(boolean isResolvedFromSource) true if resolved from source (rather than cache)void
setTranslationMap
(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 translationvoid
setTypeString
(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:GrouperAPI
deep clone the fields in this object- Specified by:
clone
in interfaceGrouperCloneable
- Specified by:
clone
in 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 aSubject
to aSource
within 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:
GrouperException
InsufficientPrivilegeException
- 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 aSubject
to aSource
within 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:
GrouperException
InsufficientPrivilegeException
- 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 aSubject
to aSource
within 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:
GrouperException
InsufficientPrivilegeException
- 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:
getAttributeValue
in interfaceSubject
- Parameters:
name
-- Returns:
- attribute value
-
getAttributeValues
Return the values for the specified attribute.- Specified by:
getAttributeValues
in interfaceSubject
- Parameters:
name
-- Returns:
- attributes
-
getDescription
Return this subject's description.- Specified by:
getDescription
in 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:
getSource
in 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:Subject
Returns 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:
getAttributeValueOrCommaSeparated
in interfaceSubject
- Returns:
- value or values or null if not there
- See Also:
-
getAttributeValueSingleValued
Description copied from interface:Subject
Returns 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:
getAttributeValueSingleValued
in interfaceSubject
- Returns:
- value or null if not there
- See Also:
-
getSourceId
Description copied from interface:Subject
get the source id of a subject- Specified by:
getSourceId
in interfaceSubject
- Returns:
- the source id
- See Also:
-
getTypeName
Description copied from interface:Subject
get the type name- Specified by:
getTypeName
in interfaceSubject
- Returns:
- the type name
- See Also:
-
getAttributes
Description copied from interface:Subject
Gets 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:
getAttributes
in interfaceSubject
- Returns:
- map or empty map or null if not there
- See Also:
-
getAttributeValue
Description copied from interface:Subject
Returns the value of a single-valued attribute. If multivalued, this returns the first value. Note, the keys are case-insensitive- Specified by:
getAttributeValue
in interfaceSubject
excludeInternalAttributes
- 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:Subject
Returns 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:
getAttributeValueOrCommaSeparated
in interfaceSubject
excludeInternalAttributes
- 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:Subject
Returns 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:
getAttributeValueSingleValued
in interfaceSubject
excludeInternalAttributes
- if true, values for internal attributes are not returned- Returns:
- value or null if not there
- See Also:
-
getAttributeValues
Description copied from interface:Subject
Returns 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:
getAttributeValues
in interfaceSubject
excludeInternalAttributes
- 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:Subject
Gets 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:
getAttributes
in 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:Subject
we want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation- Specified by:
getTranslationMap
in interfaceSubject
- Returns:
-
setTranslationMap
Description copied from interface:Subject
we want to resolve virtual translated attributes when they are needed so store a map of subject and source attributes for that translation- Specified by:
setTranslationMap
in interfaceSubject
-
isResolvedFromSource
public boolean isResolvedFromSource()- Specified by:
isResolvedFromSource
in 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:
setResolvedFromSource
in interfaceSubject
- Parameters:
isResolvedFromSource
-
-