public interface UserPermissionService<P extends UserPermission>
UserPermission
.Modifier and Type | Method and Description |
---|---|
void |
archive(String id)
Soft-deletes a record by setting its
UserPermission.archived to true . |
P |
createOnlyIfDoesNotExist(P permission,
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 |
createPermission(P payload)
Creates a new permission in the data store.
|
void |
delete(String id)
Hard-deletes the given record.
|
org.springframework.data.domain.Page<P> |
findAllByNameContainingAndNotArchived(String name,
org.springframework.data.domain.Pageable page)
Finds and returns all entities that are not
UserPermission.archived whose name
contains the given value. |
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
UserPermission.archived . |
P |
replaceOnlyIfLastUpdatedBefore(String entityId,
P permission,
Instant lastUpdated)
A specialized replace operation that does not invoke the "save" create-or-update behavior.
|
P |
replacePermission(String id,
P payload)
Replaces the permission 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)
UserPermission.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)
UserPermission.archived
whose name
contains the given value.name
- the name value to match withpage
- information about which page of results to return from the databaseP createPermission(P payload)
payload
- the permission 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 foundarchive(String)
void archive(String id)
UserPermission.archived
to true
.id
- the id of the entity to archivecom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the entity to archive was not founddelete(String)
P replacePermission(String id, P payload)
id
with payload
.id
- the ID of the permission to replacepayload
- the replacement permissioncom.broadleafcommerce.common.error.validation.ValidationException
- if the payload
failed validation for replacementcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if the permission to replace was not found or was
UserPermission.archived
@Nullable P createOnlyIfDoesNotExist(P permission, Instant lastUpdated)
This is intended to be used in concurrent scenarios where only one operation should succeed.
permission
- the permission to create. Must have a non-null id present.lastUpdated
- the UserPermission.lastUpdated
to set on the permissionnull
if creation failed due to the
entity already existing.@Nullable P replaceOnlyIfLastUpdatedBefore(String entityId, P permission, Instant lastUpdated)
This is intended to be used in concurrent scenarios where only one operation should succeed.
entityId
- the id of the entity to replacepermission
- 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 UserPermission.lastUpdated
set to this value.null
if the
entity was not found or could not be updated due to its lastUpdated value.Copyright © 2021. All rights reserved.