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 ROLE
    java.util.List<Role> getAllRoles()
    GET ALL ROLES
    Role getRole​(java.lang.String roleName)
    GET ROLE BY NAME
    boolean removeUserRole​(AppUser user, Role role)
    REMOVE USER ROLE
    Role saveRole​(Role role)
    SAVE ROLE
    boolean setUserRole​(java.lang.String username, java.lang.String roleName)
    SET USER ROLE

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • RoleServiceFacade

      public RoleServiceFacade()
  • Method Details

    • saveRole

      public Role saveRole​(Role role)
      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 interface RoleService
      Parameters:
      role - The role that is going to be added.
      Returns:
      The user role that has been created on the database.
    • getRole

      public Role getRole​(java.lang.String roleName)
      Description copied from interface: RoleService

      GET ROLE BY NAME

      Get a role form the database using its name.

      Specified by:
      getRole in interface RoleService
      Parameters:
      roleName - The name of the role that is going to be searched.
      Returns:
      The role from the database.
    • getAllRoles

      public java.util.List<Role> getAllRoles()
      Description copied from interface: RoleService

      GET ALL ROLES

      Get all roles form the database.

      Specified by:
      getAllRoles in interface RoleService
      Returns:
      The roles from the database.
    • deleteRole

      public Role deleteRole​(Role role)
      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 interface RoleService
      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 interface RoleService
      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

      public boolean removeUserRole​(AppUser user, Role role)
      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 interface RoleService
      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.