public interface UserRoleService<P extends UserRole>
Modifier and Type | Method and Description |
---|---|
void |
archive(String id)
Soft-deletes a record by setting its
UserRole.archived to true . |
P |
createOnlyIfDoesNotExist(P role,
Instant lastUpdated)
A specialized create operation for creating an entity with a pre-defined id with the minimum
guarantee that concurrent requests to this method for the same entity ID will fail.
|
P |
createRole(P payload)
Creates a new role in the data store.
|
void |
delete(String id)
Hard-deletes the given record.
|
List<P> |
findAllByIdInAndNotArchived(Collection<String> ids)
Finds and returns a list of entities that are not
UserRole.archived and whose id
matches one of the given values. |
org.springframework.data.domain.Page<P> |
findAllByNameContainingAndNotArchived(String name,
org.springframework.data.domain.Pageable page)
Finds and returns all entities that are not
UserRole.archived whose name contains the
given value. |
Stream<P> |
findAllStreamByIdInAndNotArchived(Collection<String> ids)
Finds and returns a stream of entities that are not
UserRole.archived and whose id
matches one of the given values. |
Optional<P> |
findById(String id)
Finds and returns the entity with the given ID.
|
Optional<P> |
findByIdAndNotArchived(String id)
Finds and returns the entity with the given ID if not
UserRole.archived . |
P |
replaceOnlyIfLastUpdatedBefore(String entityId,
P role,
Instant lastUpdated)
A specialized replace operation that does not invoke the "save" create-or-update behavior.
|
P |
replaceRole(String id,
P payload)
Replaces the role in the data store with the given
id with payload . |
Optional<P> findById(String id)
id
- the id of the entity to findOptional
containing the entity if found, Optional.empty()
otherwiseOptional<P> findByIdAndNotArchived(String id)
UserRole.archived
.id
- the id of the entity to findOptional
containing the entity if found, Optional.empty()
otherwiseorg.springframework.data.domain.Page<P> findAllByNameContainingAndNotArchived(@Nullable String name, org.springframework.data.domain.Pageable page)
UserRole.archived
whose name contains the
given value.name
- the name value to match withpage
- information about which page of results to return from the databaseStream<P> findAllStreamByIdInAndNotArchived(Collection<String> ids)
UserRole.archived
and whose id
matches one of the given values.ids
- the ids of the entities to findList<P> findAllByIdInAndNotArchived(Collection<String> ids)
UserRole.archived
and whose id
matches one of the given values.ids
- the ids of the entities to findP createRole(P payload)
payload
- the role to createcom.broadleafcommerce.common.error.validation.ValidationException
- if the given payload
failed validation for creationvoid delete(String id)
In all but exceptional cases, archive(String)
should be preferred to this operation.
id
- the id of the entity to deletecom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the entity to delete was not foundInvalidUserRoleDeleteException
- if the role has childrenarchive(String)
void archive(String id)
UserRole.archived
to true
.
As part of this operation, the UserRole.permissions
collections should be cleared
such that those relationships are deleted.
id
- the id of the entity to archivecom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the entity to archive was not foundInvalidUserRoleDeleteException
- if the role has childrendelete(String)
P replaceRole(String id, P payload)
id
with payload
.id
- the ID of the role to replacepayload
- the replacement rolecom.broadleafcommerce.common.error.validation.ValidationException
- if the payload
failed validation for replacementcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the role to replace was not found or was
UserRole.archived
@Nullable P createOnlyIfDoesNotExist(P role, Instant lastUpdated)
This is intended to be used in a message handler, a highly concurrent scenario where only one operation should succeed.
Furthermore, this operation must not validate the request as
createRole(UserRole)
does, since we expect message handlers to receive out-of-order
messages that may temporarily have invalid references.
role
- the role to create. Must have a non-null id present.lastUpdated
- the UserRole.lastUpdated
to set on the rolenull
if creation failed due to the
entity already existing.AdminRolePersistenceHandler
@Nullable P replaceOnlyIfLastUpdatedBefore(String entityId, P role, Instant lastUpdated)
This is intended to be used in a message handler, a highly concurrent scenario where only one operation should succeed.
Furthermore, this operation must not validate the request as
replaceRole(String, UserRole)
does, since we expect message handlers to receive
out-of-order messages that may temporarily have invalid references.
entityId
- the id of the entity to replacerole
- the replacement entitylastUpdated
- the timestamp of the current change. This will be compared to the
lastUpdated on the existing entity for determination of whether the replacement should
occur. Furthermore, the replacement will have its UserRole.lastUpdated
set to
this value.null
if the entity
was not found or could not be updated due to its lastUpdated value.AdminRolePersistenceHandler
Copyright © 2021. All rights reserved.