Class RoleServiceFacade
java.lang.Object
org.eco.mubisoft.good_and_cheap.user.domain.service.RoleServiceFacade
- All Implemented Interfaces:
RoleService
@Service public class RoleServiceFacade extends java.lang.Object implements RoleService
-
Field Summary
Fields Modifier and Type Field Description private RoleRepository
roleRepo
private UserRepository
userRepo
-
Constructor Summary
Constructors Constructor Description RoleServiceFacade()
-
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 roleName)
SET USER ROLEMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
userRepo
-
roleRepo
-
-
Constructor Details
-
RoleServiceFacade
public RoleServiceFacade()
-
-
Method Details
-
saveRole
Description copied from interface:RoleService
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.
- Specified by:
saveRole
in interfaceRoleService
- Parameters:
role
- The role that is going to be added.- Returns:
- The user role that has been created on the database.
-
getRole
Description copied from interface:RoleService
GET ROLE BY NAME
Get a role form the database using its name.
- Specified by:
getRole
in interfaceRoleService
- Parameters:
roleName
- The name of the role that is going to be searched.- Returns:
- The role from the database.
-
getAllRoles
Description copied from interface:RoleService
GET ALL ROLES
Get all roles form the database.
- Specified by:
getAllRoles
in interfaceRoleService
- Returns:
- The roles from the database.
-
deleteRole
Description copied from interface:RoleService
DELETE ROLE
Delete a new role from the database. If the role doesn't exist it won't return anything.
- Specified by:
deleteRole
in interfaceRoleService
- Parameters:
role
- The role that is going to be removed.- Returns:
- The user role that has been removed from the database.
-
setUserRole
public boolean setUserRole(java.lang.String username, java.lang.String roleName)Description copied from interface:RoleService
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.
- Specified by:
setUserRole
in interfaceRoleService
- Parameters:
username
- The user that is going to have a new role assigned.roleName
- The role that is going to be assigned.- Returns:
- TRUE if the operation was successful, else FALSE.
-
removeUserRole
Description copied from interface:RoleService
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.
- Specified by:
removeUserRole
in interfaceRoleService
- 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.
-