Interface RoleService
- All Known Implementing Classes:
RoleServiceFacade
public interface RoleService
-
Method Summary
Modifier and Type Method Description Role
deleteRole(Role role)
DELETE ROLEjava.util.List<Role>
getAllRoles()
GET ALL ROLESRole
getRole(java.lang.String roleName)
GET ROLE BY NAMEboolean
removeUserRole(AppUser user, Role role)
REMOVE USER ROLERole
saveRole(Role role)
SAVE ROLEboolean
setUserRole(java.lang.String username, java.lang.String role)
SET USER ROLE
-
Method Details
-
saveRole
SAVE ROLE
Save a new role on the database. Each role must be unique, so it will make sure the role is not already created.
- Parameters:
role
- The role that is going to be added.- Returns:
- The user role that has been created on the database.
-
getRole
GET ROLE BY NAME
Get a role form the database using its name.
- Parameters:
roleName
- The name of the role that is going to be searched.- Returns:
- The role from the database.
-
getAllRoles
java.util.List<Role> getAllRoles()GET ALL ROLES
Get all roles form the database.
- Returns:
- The roles from the database.
-
deleteRole
DELETE ROLE
Delete a new role from the database. If the role doesn't exist it won't return anything.
- Parameters:
role
- The role that is going to be removed.- Returns:
- The user role that has been removed from the database.
-
setUserRole
boolean setUserRole(java.lang.String username, java.lang.String role)SET USER ROLE
Give a user a new role. As the user cannot have the same role multiple times, if the user already has the role, it won't add it.
- Parameters:
username
- The user that is going to have a new role assigned.role
- The role that is going to be assigned.- Returns:
- TRUE if the operation was successful, else FALSE.
-
removeUserRole
REMOVE USER ROLE
Remove a role from a user. If a user with a lower power role tries to remove a higher power role, an error will happen.
- Parameters:
user
- The user that is going to have a role removed.role
- The role that is going to be removed.- Returns:
- TRUE if the operation was successful, else FALSE.
-