Package com.avoka.tm.svc
Class RoleBuilder
java.lang.Object
com.avoka.tm.svc.RoleBuilder
Provides a Role value object builder class.
Examples
Please find the Role builder examples below.
Create a Role
This example shows how to create a Role
object.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role newRole = new RoleBuilder() .setRoleName("RoleTest") .setRoleDescription("Desc1") .setActiveFlag(true) .setClientAssignableFlag(true) .create();
Update a Role's Active Flag
This example shows how to update a Role's Active Flag.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role role = new RoleBuilder() .setRoleName("RoleTest") .setActiveFlag(false) .update()
Create/Update a Role
The example below shows how to create or update a Role and assign a user.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role role = new RoleBuilder() .setRoleName("RoleTest") .addUser("UserLoginName1") .createOrUpdate()
The example below shows how to create or update a Role and set all users have this role.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role role = new RoleBuilder() .setRoleName("RoleTest") .setUserLoginNames(Set.of("UserLoginName1", "UserLoginName2", "UserLoginName3")) .createOrUpdate()
The example below shows how to create or update a Role and assign a permission.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role role = new RoleBuilder() .setRoleName("RoleTest") .addPermission("PortalName", "PermissionName") .createOrUpdate()
The example below shows how to create or update a Role and set all permissions for the role.
import com.avoka.tm.svc.* import com.avoka.tm.vo.* Role role = new RoleBuilder() .setRoleName("RoleTest") .setPermissions("PortalName", Set.of("PermissionName1", "PermissionName2", "PermissionName3")) .createOrUpdate()
- Since:
- 23.04.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPermission
(String spaceName, String permissionName) Add a permission to the role permissions for a specific spaceAssign the user to the role.create()
Create a new Role based on the specified parameter and return the new Role value object.Create or update the role specified by the given parameters, and return current role value object.removePermission
(String spaceName, String permissionName) remove a permission from the role permissions for a specific spaceremoveUser
(String userLoginName) Remove the user from role userssetActiveFlag
(boolean activeFlag) Set the user activeFlag parameter.setClientAssignableFlag
(boolean clientAssignableFlag) Set the clientAssignableFlag parameter.setPermissions
(String spaceName, Set<String> setPermissionNames) set the role permissions for a specific space.setRoleDescription
(String roleDescription) Set the roleDescription parameter.setRoleName
(String roleName) Set the role name parameter.setUserLoginNames
(Set<String> userLoginNames) Set of user should have the roleupdate()
Update the role specified by the roleName parameter and return the update Role value object.
-
Constructor Details
-
RoleBuilder
Create a Role object
-
-
Method Details
-
setActiveFlag
Set the user activeFlag parameter.- Parameters:
activeFlag
- the activeFlag- Returns:
- the RoleBuilder
-
setClientAssignableFlag
Set the clientAssignableFlag parameter.- Parameters:
clientAssignableFlag
- the clientAssignableFlag- Returns:
- the RoleBuilder
-
setRoleDescription
Set the roleDescription parameter.- Parameters:
roleDescription
- the roleDescription parameter- Returns:
- the RoleBuilder
-
setRoleName
Set the role name parameter.- Parameters:
roleName
- the role name- Returns:
- the RoleBuilder
-
addPermission
Add a permission to the role permissions for a specific space- Parameters:
spaceName
- the space namepermissionName
- the permission name- Returns:
- the RoleBuilder
-
removePermission
remove a permission from the role permissions for a specific space- Parameters:
spaceName
- the space namepermissionName
- the permission name- Returns:
- the RoleBuilder
-
setPermissions
set the role permissions for a specific space. It's important to know, this method removes all previous permissions for the specified space and add the permissions set which is provided here as parameter- Parameters:
spaceName
- the space namesetPermissionNames
- the role permission names for a space- Returns:
- the RoleBuilder
-
addUser
@FluentSecurityPermission(permissions="role-assign") public RoleBuilder addUser(String userLoginName) Assign the user to the role.- Parameters:
userLoginName
- the user login name should assign to the role- Returns:
- the RoleBuilder
-
removeUser
@FluentSecurityPermission(permissions="role-assign") public RoleBuilder removeUser(String userLoginName) Remove the user from role users- Parameters:
userLoginName
- the user login name should not assign to the role- Returns:
- the RoleBuilder
-
setUserLoginNames
@FluentSecurityPermission(permissions="role-assign") public RoleBuilder setUserLoginNames(Set<String> userLoginNames) Set of user should have the role- Parameters:
userLoginNames
- set of user login names- Returns:
- the RoleBuilder
-
create
Create a new Role based on the specified parameter and return the new Role value object.- Returns:
- the newly created Role value object
-
createOrUpdate
Create or update the role specified by the given parameters, and return current role value object. If the role specified by the roleName is not found then a new Role account will be created.- Returns:
- create or update the role specified by the given parameters, and return current role value object
-
update
Update the role specified by the roleName parameter and return the update Role value object. This method will throw an IllegalArgumentException if the specified role specified by roleName parameter was not found.- Returns:
- the update Role value object
-