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

public class RegistrySubject extends GrouperAPI implements Subject
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:
  • Constructor Details

    • RegistrySubject

      public RegistrySubject()
  • Method Details

    • clone

      public RegistrySubject clone()
      Description copied from class: GrouperAPI
      deep clone the fields in this object
      Specified by:
      clone in interface GrouperCloneable
      Specified by:
      clone in class GrouperAPI
      Returns:
      the clone of the object
      See Also:
    • add

      Add a Subject to a Source 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

      public static void main(String[] args)
    • 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 a Subject to a Source 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 a Subject to a Source 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

      public static RegistrySubject find(String id, boolean exceptionIfNotFound)
      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

      Delete existing RegistrySubject.
       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

      public String getAttributeValue(String name)
      Return the value of the specified attribute.

      Specified by:
      getAttributeValue in interface Subject
      Parameters:
      name -
      Returns:
      attribute value
    • getAttributeValues

      public Set<String> getAttributeValues(String name)
      Return the values for the specified attribute.

      Specified by:
      getAttributeValues in interface Subject
      Parameters:
      name -
      Returns:
      attributes
    • getDescription

      public String getDescription()
      Return this subject's description.

      Specified by:
      getDescription in interface Subject
      Returns:
      description
    • getId

      public String getId()
      Return the subject id.

      Specified by:
      getId in interface Subject
      Returns:
      id
    • getName

      public String getName()
      Return the subject's name.

      Specified by:
      getName in interface Subject
      Returns:
      the name
    • getSource

      public Source getSource() throws IllegalStateException
      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 interface Subject
      Returns:
      the source
      Throws:
      IllegalStateException - if source cannot be returned.
      Since:
      1.2.0
    • getType

      public SubjectType getType()
      Return this subject's SubjectType.
      Specified by:
      getType in interface Subject
      Returns:
      type
    • getTypeString

      public String getTypeString()
      Returns:
      type string
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • setId

      public void setId(String id)
      Parameters:
      id -
    • setName

      public void setName(String name)
      Parameters:
      name -
    • setTypeString

      public void setTypeString(String type)
      Parameters:
      type -
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getAttributeValueOrCommaSeparated

      public String getAttributeValueOrCommaSeparated(String attributeName)
      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 interface Subject
      Returns:
      value or values or null if not there
      See Also:
    • getAttributeValueSingleValued

      public String getAttributeValueSingleValued(String attributeName)
      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 interface Subject
      Returns:
      value or null if not there
      See Also:
    • getSourceId

      public String getSourceId()
      Description copied from interface: Subject
      get the source id of a subject
      Specified by:
      getSourceId in interface Subject
      Returns:
      the source id
      See Also:
    • getTypeName

      public String getTypeName()
      Description copied from interface: Subject
      get the type name
      Specified by:
      getTypeName in interface Subject
      Returns:
      the type name
      See Also:
    • getAttributes

      public Map<String,Set<String>> 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 interface Subject
      Returns:
      map or empty map or null if not there
      See Also:
    • getAttributeValue

      public String getAttributeValue(String attributeName, boolean excludeInternalAttributes)
      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 interface Subject
      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 interface Subject
      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 interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      value or null if not there
      See Also:
    • getAttributeValues

      public Set<String> getAttributeValues(String attributeName, boolean excludeInternalAttributes)
      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 interface Subject
      excludeInternalAttributes - if true, values for internal attributes are not returned
      Returns:
      set or empty set or null if not there
      See Also:
    • getAttributes

      public Map<String,Set<String>> getAttributes(boolean excludeInternalAttributes)
      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 interface Subject
      Parameters:
      excludeInternalAttributes - if true, internal attributes are not returned
      Returns:
      map or empty map or null if not there
      See Also:
    • getTranslationMap

      public Map<String,Object> 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 interface Subject
      Returns:
    • setTranslationMap

      public void setTranslationMap(Map<String,Object> translationMap)
      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 interface Subject
    • isResolvedFromSource

      public boolean isResolvedFromSource()
      Specified by:
      isResolvedFromSource in interface Subject
      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 interface Subject
      Parameters:
      isResolvedFromSource -