Class Role

java.lang.Object
com.appiancorp.suiteapi.common.Role
All Implemented Interfaces:
Comparable<Role>
Direct Known Subclasses:
ContentRole

public class Role extends Object implements Comparable<Role>
Holds the data for an individual role within a role map.
  • Field Details

    • asRoleName

      public static final com.google.common.base.Function<Role,String> asRoleName
    • ADDING_STRATEGY

      public static final Role.PermissionMergeStrategy ADDING_STRATEGY
      Returns the result of adding newPermissions to existingPermissions. If any new permissions already exist, they are ignored.
    • REMOVING_STRATEGY

      public static final Role.PermissionMergeStrategy REMOVING_STRATEGY
      Returns the result of removing newPermissions from existingPermissions.
    • REPLACING_STRATEGY

      public static final Role.PermissionMergeStrategy REPLACING_STRATEGY
      Returns newPermissions.
  • Constructor Details

    • Role

      public Role()
    • Role

      public Role(String name)
      Creates a role with the given name and empty id/uuid sets.
    • Role

      public Role(String name, Set<String> usernames, Set<Long> groupIds, Set<String> userUuids, Set<String> groupUuids)
      Creates a role with the given name and the given ids/uuids. Adding/removing to/from the given sets will affect the created role. If null is passed in for one of the sets, the role will use a new empty set instead.
    • Role

      public Role(String name, String[] usernames, Long[] groupIds)
      Creates a role with the given name and the given ids/uuids.
    • Role

      public Role(String name, String[] usernames, Long[] groupIds, String[] userUuids, String[] groupUuids)
      Creates a role with the given name and the given ids/uuids.
    • Role

      public Role(Role r)
      Copy constructor. Creates a role with the same data as the given role (the new role will have its own sets, so changes to the original role will not affect the new role).
  • Method Details

    • equals

      public boolean equals(Object obj)
      Returns true if the given object is a non-null Role object that has the same name as this Role. Returns false otherwise.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code for this Role, calculated as the hash code of this Role's name.
      Overrides:
      hashCode in class Object
    • toString

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

      public String getName()
      Returns the name of this role.
    • setName

      public void setName(String name)
    • getUsernames

      public Set<String> getUsernames()
      Returns the usernames of the users that have this role.
    • setUsernames

      public void setUsernames(Set<String> userIds)
    • getUserUuids

      public Set<String> getUserUuids()
      Returns the UUIDs of the users that have this role. This field is not populated except when using the IX API.
    • setUserUuids

      public void setUserUuids(Set<String> userUuids)
    • getGroupIds

      public Set<Long> getGroupIds()
      Returns the ids of the groups that have this role.
    • setGroupIds

      public void setGroupIds(Set<Long> groupIds)
    • getGroupUuids

      public Set<String> getGroupUuids()
      Returns the UUIDs of the groups that have this role. This field is not populated except when using the IX API.
    • setGroupUuids

      public void setGroupUuids(Set<String> groupUuids)
    • compareTo

      public int compareTo(Role otherRole)
      Specified by:
      compareTo in interface Comparable<Role>
    • addPermissions

      public static Set<Role> addPermissions(Set<Role> existingPermissions, Set<Role> permissionsToAdd)
      Returns a new Set<Role> with permissions (groups and users) from permissionsToAdd added to existingPermissions.
    • removePermissions

      public static Set<Role> removePermissions(Set<Role> existingPermissions, Set<Role> permissionsToRemove)
      Returns a new Set<Role> with permissions (groups and users) from permissionsToRemove removed from existingPermissions.
    • applyRoleMap

      public static Set<Role> applyRoleMap(Set<Role> existingRoleMap, Set<Role> newRoleMap, Role.PermissionMergeStrategy strategy)
      Returns a new Set<Role> that is the result of applying the permission strategy to matching pairs of Roles from existingRoleMap and newRoleMap. Roles are matched up by role name.
    • applyRole

      public static Role applyRole(Role existingRole, Role newRole, Role.PermissionMergeStrategy strategy)
      Returns a new Role that is the result of applying the strategy to existingRole and newRole. For example, if the strategy was ADDING_STRATEGY, this would return a new Role with the groups and users of both newRole and existingRole.