Interface AdminRoleService<P extends AdminRole>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P>
- All Known Implementing Classes:
DefaultAdminRoleService
AdminRole
.
Supported by AdminRoleRepository
.
Declares different versions of CRUD operations beyond just those provided by
MappableCrudEntityService
- these operations declare a ContextInfo
argument to
enable access control based upon context. In most scenarios, these operations should be preferred
to those without ContextInfo
arguments to prevent unwanted mutation/assignment in invalid
contexts.
Global roles can be read in any context, but are immutable in all but the global context.
All other roles can be read/modified in the global context or the tenant context the role is assigned to. Tenant-level users can only create/modify roles from their tenant.
Certain operations will emit an OperationAwarePersistenceMessage
to the
PersistenceProducer.TYPE
channel, which is expected to be consumed by the authentication
service and synchronized there.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Creates the role.void
Deprecated.Perform a delete operation on the entity identified by the id.void
Deprecated.Deletes the given role.boolean
existsById
(String id) Deprecated.Performs an existence check to determine if there is a role in the data store matching the given id.boolean
existsById
(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Performs an existence check to determine if there is a role in the data store matching the given ID.boolean
Deprecated.Performs an existence check to determine if there is a role in the data store matching the given ID that has anull
AdminRole.tenantId
.boolean
existsByNameAndIdNot
(String name, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reports whether there exists a role in the data store whoseAdminRole.name
is equal to the givenname
and whoseAdminRole.id
is not equal to the givenid
.org.springframework.data.domain.Page<P>
readAll
(org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads all roles in the data store.org.springframework.data.domain.Page<P>
readAllByName
(String name, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads roles in the data store, filtering to those whose name contains the given value.Deprecated.Reads the role in the data store matching the given ID.Deprecated.Read a single role by id.readByIds
(List<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads the roles in the data store matching the given IDs.replace
(String id, P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Replaces the given role.Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService
create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByIds, readById, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess
-
Method Details
-
readByIdOptional
Deprecated.Read a single role by id.Similar to
MappableCrudEntityService.readById(String)
, but does not throw an exception if the entity is not found.- Parameters:
id
- the id of the role to find- Returns:
- an
Optional
containing the role if found, otherwiseOptional.empty()
-
readByIds
List<P> readByIds(List<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads the roles in the data store matching the given IDs. If any of the roles are not accessible from the given context as described in the class-level javadocs, they will not be returned (effectively not found).- Parameters:
ids
- the ids of the roles to findcontextInfo
- context information about multitenant state- Returns:
- the roles matching the given ids if found and accessible from the given context
-
readAllByName
org.springframework.data.domain.Page<P> readAllByName(String name, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads roles in the data store, filtering to those whose name contains the given value. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.- Parameters:
name
- the value that role names must contain in order to matchpageable
- describes the page of results to returncontextInfo
- context information about multitenant state- Returns:
- roles accessible in the current context that match the given name
-
existsByNameAndIdNot
boolean existsByNameAndIdNot(String name, @Nullable String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reports whether there exists a role in the data store whoseAdminRole.name
is equal to the givenname
and whoseAdminRole.id
is not equal to the givenid
. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.- Parameters:
name
- the value that role name must equal in order to matchid
- (optional) the value that the role's id must not equal in order to match. If this value isnull
, then results will not be filtered by their id.contextInfo
- context information about multitenant state- Returns:
true
if there exists a role accessible from the given context matching the given name and not matching the given id,false
otherwise
-
readAll
org.springframework.data.domain.Page<P> readAll(org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads all roles in the data store. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.- Parameters:
pageable
- describes the page of results to returncontextInfo
- context information about multitenant state- Returns:
- roles accessible in the current context
-
readById
P readById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Reads the role in the data store matching the given ID.- Parameters:
id
- the id of the role to findcontextInfo
- context information about multitenant state- Returns:
- the role matching the given id if found and accessible from the given context
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the role was not found or accessible from the given context
-
existsById
Deprecated.Performs an existence check to determine if there is a role in the data store matching the given id.- Parameters:
id
- the id of the role to find- Returns:
- true if the role exists, false otherwise
-
existsByIdInGlobal
Deprecated.Performs an existence check to determine if there is a role in the data store matching the given ID that has anull
AdminRole.tenantId
.- Parameters:
id
- the id of the role to find- Returns:
- true if the role exists and has a
null
AdminRole.tenantId
, false otherwise
-
existsById
boolean existsById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Performs an existence check to determine if there is a role in the data store matching the given ID.Result will only be
true
if the record is also accessible from the given context as described in the class-level javadocs.- Parameters:
id
- the id of the role to findcontextInfo
- context information about multitenant state- Returns:
true
if a role exists that matches the given id and is accessible from the given context
-
create
P create(P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Creates the role.If in a tenant or application context, the role's context information will be overwritten and initialized to match the given context.
If in a global context, the role's context information will be untouched from what is supplied.
Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
role
- the role to createcontextInfo
- context information about multitenant state- Returns:
- the role after it has been created in the data store
- Throws:
com.broadleafcommerce.data.tracking.core.exception.NotPermittedException
- if the current authentication cannot perform the operation (ex: the current authentication is application-restricted and therefore cannot perform this tenant-level operation)com.broadleafcommerce.common.error.validation.ValidationException
- if there were any validation errors
-
replace
P replace(String id, P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Replaces the given role.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
id
- the id of the role to replacerole
- the replacement rolecontextInfo
- context information about multitenant state- Returns:
- the role after it has been replaced in the data store
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the role was not found or accessible from the given contextcom.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given contextcom.broadleafcommerce.common.error.validation.ValidationException
- if there were validation errors
-
delete
void delete(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.Deletes the given role.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Parameters:
id
- the ID of the role to deletecontextInfo
- context information about multitenant state- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the role was not found or accessible from the given contextcom.broadleafcommerce.data.tracking.core.exception.InvalidContextRequestException
- if the role is immutable from the given contextcom.broadleafcommerce.common.error.validation.ValidationException
- if there were validation errorsInvalidAdminRoleDeleteException
- if the role has children
-
delete
Deprecated.Perform a delete operation on the entity identified by the id.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Specified by:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P extends AdminRole>
- Parameters:
id
- The id for the entity.- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if no instance was found in the backing store corresponding to idInvalidAdminRoleDeleteException
- if the role has children
-