Package com.hybris.backoffice.user
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 Summary
Modifier and TypeMethodDescriptionfilterOutRolePrincipals(Collection<PrincipalGroupModel> principals) Filters out the roles from the given collection of principal groups.Returns an optional id of the active backoffice role or an empty optional if no role is active.Returns an optional of the active backoffice role or an empty optional if no role is active.Returns user groups hierarchy of the active backoffice role (including the role) or an empty collection if there is no active role.getNonRolePrincipalsHierarchy(PrincipalModel principal) Returns principal's user groups hierarchy with the exclusion of backoffice roles and their hierarchies.booleanisActiveRole(String roleId) Tells whether the role with a given id is the current active role.voidsetActiveRole(String roleId) Sets the active backoffice role in the session.booleanTells whether backoffice roles should be treated like normal user groups (legacy mode).
-
Method Details
-
shouldTreatRolesAsGroups
boolean shouldTreatRolesAsGroups()Tells whether backoffice roles should be treated like normal user groups (legacy mode).- Returns:
trueif 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
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
Returns an optional id of the active backoffice role or an empty optional if no role is active.- Returns:
GeneratedPrincipal.UIDof active role
-
setActiveRole
Sets the active backoffice role in the session. Passing anullor 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
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 theprincipalitself.- 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
Filters out the roles from the given collection of principal groups.- Parameters:
principals- the collection to filter- Returns:
- a new collection, without the roles
-