Interface UserPermissionService<P extends UserPermission>
- All Known Implementing Classes:
DefaultUserPermissionService
public interface UserPermissionService<P extends UserPermission>
Provides CRUD management operations on
UserPermission.- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionvoidSoft-deletes a record by setting itsUserPermission.archivedtotrue.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.createPermission(P payload) Creates a new permission in the data store.voidHard-deletes the given record.org.springframework.data.domain.Page<P>findAllByNameContainingAndNotArchived(String name, boolean accountPermission, boolean includeNonUserAssignablePermissions, org.springframework.data.domain.Pageable page) Finds and returns all entities that are notUserPermission.archivedwhose name contains the given value.org.springframework.data.domain.Page<P>findAllByNameContainingAndNotArchived(String name, org.springframework.data.domain.Pageable page) Deprecated.Since 1.8.0.Finds and returns the entity with the given ID.Finds and returns the entity with the given ID if notUserPermission.archived.replaceOnlyIfLastUpdatedBefore(String entityId, P permission, Instant lastUpdated) A specialized replace operation that does not invoke the "save" create-or-update behavior.replacePermission(String id, P payload) Replaces the permission in the data store with the givenidwithpayload.
-
Method Details
-
findById
Finds and returns the entity with the given ID.- Parameters:
id- the id of the entity to find- Returns:
- an
Optionalcontaining the entity if found,Optional.empty()otherwise
-
findByIdAndNotArchived
Finds and returns the entity with the given ID if notUserPermission.archived.- Parameters:
id- the id of the entity to find- Returns:
- an
Optionalcontaining the entity if found,Optional.empty()otherwise
-
findAllByNameContainingAndNotArchived
@Deprecated org.springframework.data.domain.Page<P> findAllByNameContainingAndNotArchived(@Nullable String name, org.springframework.data.domain.Pageable page) Deprecated.Since 1.8.0. Use#findAllByNameContainingAndNotArchived(String, boolean, Pageable)Finds and returns all entities that are notUserPermission.archivedwhose name contains the given value.- Parameters:
name- the name value to match withpage- information about which page of results to return from the database- Returns:
- all entities that are not archived whose name matches the given value
-
findAllByNameContainingAndNotArchived
org.springframework.data.domain.Page<P> findAllByNameContainingAndNotArchived(@Nullable String name, boolean accountPermission, boolean includeNonUserAssignablePermissions, org.springframework.data.domain.Pageable page) Finds and returns all entities that are notUserPermission.archivedwhose name contains the given value.- Parameters:
name- the name value to match withaccountPermission- Should we read account permissions?includeNonUserAssignablePermissions- Should non user-assignable permissions be included?page- information about which page of results to return from the database- Returns:
- all entities that are not archived whose name matches the given value
-
createPermission
Creates a new permission in the data store.- Parameters:
payload- the permission to create- Returns:
- the final permission after creation
- Throws:
com.broadleafcommerce.common.error.validation.ValidationException- if the givenpayloadfailed validation for creation
-
delete
Hard-deletes the given record.In all but exceptional cases,
archive(String)should be preferred to this operation.- Parameters:
id- the id of the entity to delete- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException- if the entity to delete was not found- See Also:
-
archive
Soft-deletes a record by setting itsUserPermission.archivedtotrue.- Parameters:
id- the id of the entity to archive- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException- if the entity to archive was not found- See Also:
-
replacePermission
Replaces the permission in the data store with the givenidwithpayload.- Parameters:
id- the ID of the permission to replacepayload- the replacement permission- Returns:
- the final permission after replacement
- Throws:
com.broadleafcommerce.common.error.validation.ValidationException- if thepayloadfailed validation for replacementcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException- if the permission to replace was not found or wasUserPermission.archived
-
createOnlyIfDoesNotExist
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.This is intended to be used in concurrent scenarios where only one operation should succeed.
- Parameters:
permission- the permission to create. Must have a non-null id present.lastUpdated- theUserPermission.lastUpdatedto set on the permission- Returns:
- the permission if successfully created, or
nullif creation failed due to the entity already existing.
-
replaceOnlyIfLastUpdatedBefore
A specialized replace operation that does not invoke the "save" create-or-update behavior. This operation should directly attempt an atomic update that the data store will reject if the entity is not found or has a lastUpdated ahead of the current change.This is intended to be used in concurrent scenarios where only one operation should succeed.
- Parameters:
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 itsUserPermission.lastUpdatedset to this value.- Returns:
- the permission after replacement if successfully replaced, or
nullif the entity was not found or could not be updated due to its lastUpdated value.
-
findByIdsAndNotArchived
-