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 Detail

      • 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

        java.util.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​(java.lang.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

        java.util.Optional<java.lang.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​(java.lang.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

        java.util.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

        java.util.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

        java.util.Collection<PrincipalGroupModel> filterOutRolePrincipals​(java.util.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