Package com.appiancorp.suiteapi.common
Class Role
java.lang.Object
com.appiancorp.suiteapi.common.Role
- All Implemented Interfaces:
Comparable<Role>
- Direct Known Subclasses:
ContentRole
Holds the data for an individual role within a role map.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Takes a set of existing permissions and a set of new permissions and decides how to combine them into a result set. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Role.PermissionMergeStrategy
Returns the result of addingnewPermissions
toexistingPermissions
.static final Role.PermissionMergeStrategy
Returns the result of removingnewPermissions
fromexistingPermissions
.static final Role.PermissionMergeStrategy
ReturnsnewPermissions
. -
Constructor Summary
ConstructorDescriptionRole()
Copy constructor.Creates a role with the given name and empty id/uuid sets.Creates a role with the given name and the given ids/uuids.Creates a role with the given name and the given ids/uuids.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. -
Method Summary
Modifier and TypeMethodDescriptionaddPermissions
(Set<Role> existingPermissions, Set<Role> permissionsToAdd) Returns a newSet<Role>
with permissions (groups and users) frompermissionsToAdd
added toexistingPermissions
.static Role
applyRole
(Role existingRole, Role newRole, Role.PermissionMergeStrategy strategy) Returns a newRole
that is the result of applying thestrategy
toexistingRole
andnewRole
.applyRoleMap
(Set<Role> existingRoleMap, Set<Role> newRoleMap, Role.PermissionMergeStrategy strategy) Returns a newSet<Role>
that is the result of applying the permissionstrategy
to matching pairs ofRole
s fromexistingRoleMap
andnewRoleMap
.int
boolean
Returns true if the given object is a non-null Role object that has the same name as this Role.Returns the ids of the groups that have this role.Returns the UUIDs of the groups that have this role.getName()
Returns the name of this role.Returns the usernames of the users that have this role.Returns the UUIDs of the users that have this role.int
hashCode()
Returns the hash code for this Role, calculated as the hash code of this Role's name.removePermissions
(Set<Role> existingPermissions, Set<Role> permissionsToRemove) Returns a newSet<Role>
with permissions (groups and users) frompermissionsToRemove
removed fromexistingPermissions
.void
setGroupIds
(Set<Long> groupIds) void
setGroupUuids
(Set<String> groupUuids) void
void
setUsernames
(Set<String> userIds) void
setUserUuids
(Set<String> userUuids) toString()
-
Field Details
-
asRoleName
-
ADDING_STRATEGY
Returns the result of addingnewPermissions
toexistingPermissions
. If any new permissions already exist, they are ignored. -
REMOVING_STRATEGY
Returns the result of removingnewPermissions
fromexistingPermissions
. -
REPLACING_STRATEGY
ReturnsnewPermissions
.
-
-
Constructor Details
-
Role
public Role() -
Role
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. Ifnull
is passed in for one of the sets, the role will use a new empty set instead. -
Role
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
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
Returns true if the given object is a non-null Role object that has the same name as this Role. Returns false otherwise. -
hashCode
public int hashCode()Returns the hash code for this Role, calculated as the hash code of this Role's name. -
toString
-
getName
Returns the name of this role. -
setName
-
getUsernames
Returns the usernames of the users that have this role. -
setUsernames
-
getUserUuids
Returns the UUIDs of the users that have this role. This field is not populated except when using the IX API. -
setUserUuids
-
getGroupIds
Returns the ids of the groups that have this role. -
setGroupIds
-
getGroupUuids
Returns the UUIDs of the groups that have this role. This field is not populated except when using the IX API. -
setGroupUuids
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Role>
-
addPermissions
Returns a newSet<Role>
with permissions (groups and users) frompermissionsToAdd
added toexistingPermissions
. -
removePermissions
public static Set<Role> removePermissions(Set<Role> existingPermissions, Set<Role> permissionsToRemove) Returns a newSet<Role>
with permissions (groups and users) frompermissionsToRemove
removed fromexistingPermissions
. -
applyRoleMap
public static Set<Role> applyRoleMap(Set<Role> existingRoleMap, Set<Role> newRoleMap, Role.PermissionMergeStrategy strategy) Returns a newSet<Role>
that is the result of applying the permissionstrategy
to matching pairs ofRole
s fromexistingRoleMap
andnewRoleMap
.Role
s are matched up by role name. -
applyRole
public static Role applyRole(Role existingRole, Role newRole, Role.PermissionMergeStrategy strategy) Returns a newRole
that is the result of applying thestrategy
toexistingRole
andnewRole
. For example, if the strategy wasADDING_STRATEGY
, this would return a newRole
with the groups and users of bothnewRole
andexistingRole
.
-