public class DefaultUserPermissionService<P extends UserPermission,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> extends Object implements UserPermissionService<P>
| Constructor and Description |
|---|
DefaultUserPermissionService(UserPermissionRepository<D> repository,
SimplePayloadMapper mapper,
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyChangesForArchive(P permission)
Modifies the given instance for archival.
|
void |
archive(@NonNull String id)
Soft-deletes a record by setting its
UserPermission.archived to true. |
P |
createOnlyIfDoesNotExist(P permission,
@NonNull 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(@NonNull 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. |
protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager |
getValidator() |
P |
replaceOnlyIfLastUpdatedBefore(@NonNull String entityId,
P permission,
@NonNull 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. |
public DefaultUserPermissionService(UserPermissionRepository<D> repository, SimplePayloadMapper mapper, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator)
public Optional<P> findById(String id)
UserPermissionServicefindById in interface UserPermissionService<P extends UserPermission>id - the id of the entity to findOptional containing the entity if found, Optional.empty()
otherwisepublic Optional<P> findByIdAndNotArchived(String id)
UserPermissionServiceUserPermission.archived.findByIdAndNotArchived in interface UserPermissionService<P extends UserPermission>id - the id of the entity to findOptional containing the entity if found, Optional.empty()
otherwisepublic org.springframework.data.domain.Page<P> findAllByNameContainingAndNotArchived(@Nullable String name, org.springframework.data.domain.Pageable page)
UserPermissionServiceUserPermission.archived whose name
contains the given value.findAllByNameContainingAndNotArchived in interface UserPermissionService<P extends UserPermission>name - the name value to match withpage - information about which page of results to return from the databasepublic P createPermission(P payload)
UserPermissionServicecreatePermission in interface UserPermissionService<P extends UserPermission>payload - the permission to createpublic P replacePermission(String id, P payload)
UserPermissionServiceid with payload.replacePermission in interface UserPermissionService<P extends UserPermission>id - the ID of the permission to replacepayload - the replacement permissionpublic void delete(@NonNull
@NonNull String id)
UserPermissionService
In all but exceptional cases, UserPermissionService.archive(String) should be preferred to this operation.
delete in interface UserPermissionService<P extends UserPermission>id - the id of the entity to deleteUserPermissionService.archive(String)public void archive(@NonNull
@NonNull String id)
UserPermissionServiceUserPermission.archived to true.archive in interface UserPermissionService<P extends UserPermission>id - the id of the entity to archiveUserPermissionService.delete(String)protected void applyChangesForArchive(P permission)
permission - the instance to modify@Nullable public P createOnlyIfDoesNotExist(@NonNull P permission, @NonNull @NonNull Instant lastUpdated)
UserPermissionServiceThis is intended to be used in concurrent scenarios where only one operation should succeed.
createOnlyIfDoesNotExist in interface UserPermissionService<P extends UserPermission>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 public P replaceOnlyIfLastUpdatedBefore(@NonNull @NonNull String entityId, @NonNull P permission, @NonNull @NonNull Instant lastUpdated)
UserPermissionServiceThis is intended to be used in concurrent scenarios where only one operation should succeed.
replaceOnlyIfLastUpdatedBefore in interface UserPermissionService<P extends UserPermission>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.@NonNull protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager getValidator()
Copyright © 2021. All rights reserved.