Interface BackofficeRoleService

All Known Implementing Classes:
DefaultBackofficeRoleService

public interface BackofficeRoleService
Helper service to be used in situations where business logic relies on active backoffice role
  • Method Details

    • shouldTreatRolesAsGroups

      boolean shouldTreatRolesAsGroups()
      Tells whether backoffice roles should be treated like normal user groups (legacy mode).
      Returns:
      true if legacy mode should be used and roles should be treated equal to groups
    • getActiveRoleModel

      Optional<BackofficeRoleModel> getActiveRoleModel()
      Returns an optional of the active backoffice role or an empty optional if no role is active.
      Returns:
      model of active role
    • isActiveRole

      boolean isActiveRole(String roleId)
      Tells whether the role with a given id is the current active role.
      Parameters:
      roleId - the role id to check
      Returns:
      true if the id belongs to the current active role, false otherwise
    • getActiveRole

      Optional<String> getActiveRole()
      Returns an optional id of the active backoffice role or an empty optional if no role is active.
      Returns:
      GeneratedPrincipal.UID of active role
    • setActiveRole

      void setActiveRole(String roleId)
      Sets the active backoffice role in the session. Passing a null or an empty value will remove the attribute from the session.
      Parameters:
      roleId - {@link BackofficeRole@UID} of new active role
    • getActiveRolePrincipalsHierarchy

      Collection<PrincipalGroupModel> getActiveRolePrincipalsHierarchy()
      Returns user groups hierarchy of the active backoffice role (including the role) or an empty collection if there is no active role.
      Returns:
      a collection of all subgroups of active role including this role or empty collection if no active role
    • getNonRolePrincipalsHierarchy

      Collection<PrincipalModel> getNonRolePrincipalsHierarchy(PrincipalModel principal)
      Returns principal's user groups hierarchy with the exclusion of backoffice roles and their hierarchies. The returned collection is never empty, as it contains at least the principal itself.
      Parameters:
      principal - principal from which the hierarchy is taken
      Returns:
      a collection of active all subgroups that principal belongs to without those that are backoffice roles or comes from them and this principal
    • filterOutRolePrincipals

      Collection<PrincipalGroupModel> filterOutRolePrincipals(Collection<PrincipalGroupModel> principals)
      Filters out the roles from the given collection of principal groups.
      Parameters:
      principals - the collection to filter
      Returns:
      a new collection, without the roles