Interface AccountRoleService<P extends AccountRole>
-
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
- All Known Implementing Classes:
DefaultAccountRoleService
public interface AccountRoleService<P extends AccountRole> extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
Service API for management ofAccountRole
.Supported by
AccountRoleRepository
.Declares different versions of CRUD operations beyond just those provided by
MappableCrudEntityService
- these operations declare aContextInfo
argument to enable access control based upon context. In most scenarios, these operations should be preferred to those withoutContextInfo
arguments to prevent unwanted mutation/assignment in invalid contexts.Certain operations will emit an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel, which is expected to be consumed by the authentication service and synchronized there.- Author:
- Samarth Dhruva (samarthd)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description P
create(P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Creates the role.void
delete(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deletes the given role.boolean
existsById(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Reports whether there exists a role in the data store whoseAccountRole.getId()
()} is equal to the givenid
.boolean
existsByNameAndIdNot(String name, String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Reports whether there exists a role in the data store whoseAccountRole.getName()
is equal to the givenname
and whoseAccountRole.getId()
is not equal to the givenid
.org.springframework.data.domain.Page<P>
readAllByName(String name, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Reads roles in the data store, filtering to those whose name contains the given value.Optional<P>
readByIdOptional(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Read a single role by id.P
replace(String id, P role, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Replaces the given role.-
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
-
-
-
-
Method Detail
-
readByIdOptional
Optional<P> readByIdOptional(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Read a single role by id.Similar to
CrudEntityService.readByContextId(String, ContextInfo)
, but does not throw an exception if the entity is not found.- Parameters:
id
- the id of the role to findcontext
-- Returns:
- an
Optional
containing the role if found, otherwiseOptional.empty()
-
readAllByName
org.springframework.data.domain.Page<P> readAllByName(String name, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
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 returncontext
- context information about multitenant state- Returns:
- roles accessible in the current context that match the given name
-
existsById
boolean existsById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Reports whether there exists a role in the data store whoseAccountRole.getId()
()} is equal to the givenid
. Results are restricted to only the roles accessible from the given context as described in the class-level javadocs.- Parameters:
id
- the value that the role's id must not equal in order to matchcontext
- 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
-
existsByNameAndIdNot
boolean existsByNameAndIdNot(String name, @Nullable String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Reports whether there exists a role in the data store whoseAccountRole.getName()
is equal to the givenname
and whoseAccountRole.getId()
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.context
- 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
-
create
P create(P role, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Creates the role.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Specified by:
create
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
- Parameters:
role
- the role to createcontext
- context information about multitenant state- Returns:
- the role after it has been created in the data store
- Throws:
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 context)
Replaces the given role.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Specified by:
replace
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
- Parameters:
id
- the id of the role to replacerole
- the replacement rolecontext
- 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.common.error.validation.ValidationException
- if there were validation errors
-
delete
void delete(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deletes the given role.Emits an
OperationAwarePersistenceMessage
to thePersistenceProducer.TYPE
channel.- Specified by:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends AccountRole>
- Parameters:
id
- the ID of the role to deletecontext
- 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.common.error.validation.ValidationException
- if there were validation errorsInvalidAccountRoleDeleteException
- if the role has children
-
-