Class RoleMap

java.lang.Object
com.appiancorp.suiteapi.common.RoleMap
All Implemented Interfaces:
XMLable, Serializable, Map
Direct Known Subclasses:
AdminConsoleRoleMap, CollaborationRoleMap, ContentRoleMap, ProcessApplicationRoleMap, ProcessRoleMap, PublicRoleMap, ThreadRoleMap

public class RoleMap extends Object implements Map, XMLable, Serializable
A mapping of roles and the users and groups that fill those roles.

N.B. The ComplexForeignKey.requiredByIxSpec() for groups is set true in RoleBinder.getRefMd(Role, ReferenceContext, boolean) in order to prevent the import of objects referencing missing security groups.

See Also:
  • Field Details

  • Constructor Details

    • RoleMap

      public RoleMap()
  • Method Details

    • init

      protected void init(RoleMap rm)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toXML

      public String toXML()
      Converts this role map to xml and returns it as a string.
      Specified by:
      toXML in interface XMLable
      Returns:
      a String containing the XML serialization of this palette item
    • toXML

      public void toXML(StringBuilder buffer_)
      Converts this role map node to XML and stores it in a StringBuilder.
      Specified by:
      toXML in interface XMLable
      Parameters:
      buffer_ - the StringBuilder to append the XML to
    • size

      public int size()
      Returns the number of roles in the role map.
      Specified by:
      size in interface Map
      Returns:
      the number of roles in the role map
    • isEmpty

      public boolean isEmpty()
      Returns whether this role map contains no roles.
      Specified by:
      isEmpty in interface Map
      Returns:
      true if the map contains no roles; false otherwise
    • containsKey

      public boolean containsKey(Object key_)
      Returns whether this role map contains the role specified.
      Specified by:
      containsKey in interface Map
      Parameters:
      key_ - the role to check for
      Returns:
      true if the map contains the specified role; false otherwise
    • containsValue

      public boolean containsValue(Object value_)
      Not implemented.
      Specified by:
      containsValue in interface Map
      Parameters:
      value_ - The object to look for.
      Returns:
      false
    • get

      public Object get(Object key_)
      Returns the actors at the particular role.
      Specified by:
      get in interface Map
      Parameters:
      key_ - the role to get the actors at
      Returns:
      a Map containing the users and groups, where the keys are the types TYPE_USER or TYPE_GROUP and the values are Array objects of usernames (Strings) and group IDs (Longs) respectively.
    • put

      public Object put(Object key_, Object value_)
      Returns the users and groups in the given role.
      Specified by:
      put in interface Map
      Parameters:
      key_ - the role
      value_ - a Map containing the users and groups, where the keys are the types TYPE_USER or TYPE_GROUP and the values are Array objects of usernames (Strings) and group IDs (Longs) respectively.
      Returns:
      the previous value
    • remove

      public Object remove(Object key_)
      Remove all users and groups at the role.
      Specified by:
      remove in interface Map
      Parameters:
      key_ - The key of the object to remove from the role map.
      Returns:
      a Map with the previous users and groups in the role, where the keys are the types (TYPE_USER or TYPE_GROUP) and the values are Array objects of usernames (Strings) and group IDs (Longs) respectively.
    • putAll

      public void putAll(Map t_)
      Not supported.
      Specified by:
      putAll in interface Map
      Parameters:
      t_ - value does not matter
      Throws:
      UnsupportedOperatorException - always
    • clear

      public void clear()
      Removes all roles and actors.
      Specified by:
      clear in interface Map
    • keySet

      public Set keySet()
      Returns all of the roles in the role map.
      Specified by:
      keySet in interface Map
      Returns:
      a Set containing the roles
    • values

      public Collection values()
      Returns all of the users and groups at any roles.
      Specified by:
      values in interface Map
      Returns:
      a Collection containing all of the user and group Map objects, where for each Map, the keys are the types TYPE_USER or TYPE_GROUP and the values are Array objects of usernames (Strings) and group IDs (Longs) respectively.
    • entrySet

      public Set entrySet()
      Returns all of the entries in the role map.
      Specified by:
      entrySet in interface Map
      Returns:
      a Set containing Map.Entry objects, where the keys in the entries are the roles, and the values are the Map objects
      See Also:
    • equals

      public boolean equals(Object obj)
      Compares this role map with another, and returns whether this role map contains exactly the same data as the other.
      Specified by:
      equals in interface Map
      Overrides:
      equals in class Object
      Parameters:
      obj - the other role map
      Returns:
      true, if this rolemap equals o_; else false
    • hashCode

      public int hashCode()
      Returns a hash code for the role map.
      Specified by:
      hashCode in interface Map
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • getActorsInRole

      public Object[] getActorsInRole(String role_, String type_)
      Returns all of the actors at the given role and of the given type.
      Parameters:
      role_ - the role to get users for
      type_ - TYPE_USER or TYPE_GROUP
      Returns:
      an Array of the actor IDs (String for users, Long for groups)
      See Also:
    • containsActors

      public boolean containsActors()
      Returns true if there are actors in any role of the role map.
      Returns:
      true if there are actors in any role of the role map
    • setActorsInRole

      public void setActorsInRole(String role_, String type_, Long[] id_)
      Sets the actors in the given role at the given type.
      Parameters:
      role_ - the role. This parameter is required.
      type_ - should always be TYPE_GROUP
      id_ - the group ids
      Throws:
      NullPointerException - if the role is not specified.
      See Also:
    • setActorsInRole

      public void setActorsInRole(String role_, String type_, String[] id_)
      Sets the actors in the specified role.
      Parameters:
      role_ - the role. This parameter is required.
      type_ - should always be TYPE_USER
      id_ - the usernames of the users
      Throws:
      NullPointerException - if the role is not specified.
      See Also:
    • addActorsToRole

      public void addActorsToRole(String role_, String type_, Long[] id_) throws NullPointerException
      Adds groups to the specified role.
      Parameters:
      role_ - the role. This parameter is required. Example: ContentRoleMap.AUTHOR, ContentRoleMap.VIEWER...
      type_ - should always be RoleMap.TYPE_GROUP
      id_ - the group ids
      Throws:
      NullPointerException - if the role is not specified.
    • addActorsToRole

      public void addActorsToRole(String role_, String type_, String[] id_) throws NullPointerException
      Adds users to the specified role.
      Parameters:
      role_ - the role. This parameter is required. Example: ContentRoleMap.AUTHOR, ContentRoleMap.VIEWER...
      type_ - should always be RoleMap.TYPE_USER
      id_ - the usernames of the users to add
      Throws:
      NullPointerException - if the role is not specified.
    • removeActorsFromRole

      public void removeActorsFromRole(String role_, String type_, Long[] id_)
      Removes groups from the specified role.
      Parameters:
      role_ - the role
      type_ - should always be TYPE_GROUP
      id_ - the group ids to remove
    • removeActorsFromRole

      public void removeActorsFromRole(String role_, String type_, String[] id_)
      Removes users from the specified role.
      Parameters:
      role_ - the role
      type_ - should always be TYPE_USER
      id_ - the usernames to remove
    • setSecurity

      public void setSecurity(Integer security_)
      Sets the security bitmap for the object. Only currently exists for Content. For possible values for Content, see ContentConstants.SEC_XXX. May be null
      Parameters:
      security_ - the security map
      See Also:
    • getSecurity

      public Integer getSecurity()
      Gets the security bitmap for the object. Only currently exists for Content. For possible values for Content, see ContentConstants.SEC_XXX. May be null
      Returns:
      the security map
      See Also:
    • setAggregateSecurity

      public void setAggregateSecurity(Integer aggregateSecurity_)
      Sets the aggregate security bitmap for the object. Only currently exists for Content. For possible values for Content, see ContentConstants.SEC_XXX. May be null
      Parameters:
      aggregateSecurity_ - the aggregate security map
      See Also:
    • getAggregateSecurity

      public Integer getAggregateSecurity()
      Gets the aggregate security bitmap for the object. Only currently exists for Content. For possible values for Content, see ContentConstants.SEC_XXX. May be null
      Returns:
      the aggregate security map
      See Also:
    • mergeWith

      public void mergeWith(RoleMap newRM)
      Merges this role map with the given new role map. Only the fields TYPE_USER and TYPE_GROUP are merged. All other fields are left unchanged. The following rules are used to merge the users and groups:
      1. The merged role map should be the union of the existing and new role maps.
      2. When the same user/group is present in both the existing and new role maps, the role from the NEW role map should be used for the user/group.
      Parameters:
      newRM - The new role map to merge with this (existing/old) role map.
    • getAllGroupIds

      public Set<Long> getAllGroupIds()
      Returns all the group ids in this role map.
    • getAllUsernames

      public Set<String> getAllUsernames()
      Returns all the usernames in this role map.
    • getRoles

      public Role[] getRoles()
      Returns an array of Role objects for all the roles stored in this role map.
    • setRoles

      public void setRoles(Role[] roles)
      Removes any roles that are currently set and sets the roles to the given data. If the given array is null or empty the existing roles are cleared. The security vector (SECURITY_KEY) is not affected by this call.
      Parameters:
      roles - The roles data to set in the role map.
    • setRoles

      public void setRoles(Collection<? extends Role> rolesSet)
      Removes any roles that are currently set and sets the roles to the given data. If the given array is null or empty the existing roles are cleared. mimic the call with input as an array of Roles The security vector (SECURITY_KEY) is not affected by this call.
      Parameters:
      rolesSet - The set of roles data to set in the role map.
    • getRoleNames

      protected String[] getRoleNames()
    • removeAllRoles

      protected void removeAllRoles()
    • getRole

      protected Role getRole(String roleName)
    • setRole

      protected void setRole(Role role)