Class AdminPermissionPersistenceHandler
- java.lang.Object
-
- com.broadleafcommerce.auth.user.listener.AuthDataUpdatePersistenceHandler
-
- com.broadleafcommerce.auth.user.listener.OperationAwarePersistenceHandler
-
- com.broadleafcommerce.auth.user.listener.AdminPermissionPersistenceHandler
-
- All Implemented Interfaces:
com.broadleafcommerce.common.messaging.PersistenceHandler
public class AdminPermissionPersistenceHandler extends OperationAwarePersistenceHandler
Handles messages from the Persistence channel forAdminPermission
data to updateUserPermission
. This is designed to perform a replacement of existing data within this service from the admin user service.- Author:
- Samarth Dhruva (samarthd)
-
-
Constructor Summary
Constructors Constructor Description AdminPermissionPersistenceHandler(UserPermissionService<UserPermission> userPermissionService, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UserPermission
buildUserPermissionForCreate(String id, AdminPermission request, Instant lastUpdated)
protected AdminPermission
deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode)
String[]
getSupportedSimpleTypeNames()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
protected UserPermissionService<UserPermission>
getUserPermissionService()
void
hook(String entityJson)
protected void
mapUpdatesFromRequest(AdminPermission request, UserPermission target)
protected void
modifyForArchival(UserPermission target)
Mimic whatUserPermissionService.archive(String)
would do to mark this record as archived.protected void
performArchivalReplacementIfEligible(@NonNull String entityId, @NonNull UserPermission existing, @NonNull Instant changeTimestamp)
protected void
performReplacementIfEligible(@NonNull String entityId, @NonNull UserPermission existing, @NonNull AdminPermission request, @NonNull Instant changeTimestamp)
protected void
processCreateOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson)
Invoked if the persistence message had anOperationType
ofOperationType.CREATE
.protected void
processDeleteOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson)
Archives the given entity.protected void
processUpdateOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson)
Invoked if the persistence message had anOperationType
ofOperationType.UPDATE
.protected void
updatePermissionInfo(AdminPermission request, UserPermission permission)
protected void
updatePermissionTenantRestrictions(AdminPermission request, UserPermission permission)
-
Methods inherited from class com.broadleafcommerce.auth.user.listener.OperationAwarePersistenceHandler
getChangeTimestamp, getEntityIdOrThrow, getNonNullField, getValidOperationTypeOrThrow, processStateChange, processStateChange
-
Methods inherited from class com.broadleafcommerce.auth.user.listener.AuthDataUpdatePersistenceHandler
getObjectMapper, handle, isNodeNull, isValidType
-
-
-
-
Constructor Detail
-
AdminPermissionPersistenceHandler
public AdminPermissionPersistenceHandler(UserPermissionService<UserPermission> userPermissionService, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Detail
-
hook
@StreamListener("persistenceInputAdminPermission") public void hook(String entityJson)
-
processCreateOperation
protected void processCreateOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
Description copied from class:OperationAwarePersistenceHandler
Invoked if the persistence message had anOperationType
ofOperationType.CREATE
.- Specified by:
processCreateOperation
in classOperationAwarePersistenceHandler
- Parameters:
entityId
- the ID found on the persistence message. Guaranteed non-empty.changeTimestamp
- the timestamp found on the persistence message. Guaranteed non-null.entityJson
- the persistence message json itself. Guaranteed non-null.- Throws:
IOException
-
buildUserPermissionForCreate
protected UserPermission buildUserPermissionForCreate(String id, AdminPermission request, Instant lastUpdated)
-
mapUpdatesFromRequest
protected void mapUpdatesFromRequest(AdminPermission request, UserPermission target)
-
deserialize
protected AdminPermission deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode) throws IOException
- Throws:
IOException
-
processUpdateOperation
protected void processUpdateOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
Description copied from class:OperationAwarePersistenceHandler
Invoked if the persistence message had anOperationType
ofOperationType.UPDATE
.- Specified by:
processUpdateOperation
in classOperationAwarePersistenceHandler
- Parameters:
entityId
- the entity ID found on the persistence message. Guaranteed non-empty.changeTimestamp
- the timestamp found on the persistence message. Guaranteed non-null.entityJson
- the persistence message json itself. Guaranteed non-null.- Throws:
IOException
-
performReplacementIfEligible
protected void performReplacementIfEligible(@NonNull @NonNull String entityId, @NonNull @NonNull UserPermission existing, @NonNull @NonNull AdminPermission request, @NonNull @NonNull Instant changeTimestamp)
-
processDeleteOperation
protected void processDeleteOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
Archives the given entity.Note that if an existing record is not found, one will be created in an archived state. The motivation for this is to protect against out-of-order messages (ex: "Delete" message on an entity arrives before the "Create"). By establishing a pre-existing record in an archived state with a timestamp, any subsequent persistence message received can be compared against this record's timestamp and appropriately discarded as outdated rather than triggering creation of a new record.
- Specified by:
processDeleteOperation
in classOperationAwarePersistenceHandler
- Parameters:
entityId
- the entity ID found on the persistence message. Guaranteed non-empty.changeTimestamp
- the timestamp found on the persistence message. Guaranteed non-null.entityJson
- the persistence message json itself. Guaranteed non-null.- Throws:
IOException
-
performArchivalReplacementIfEligible
protected void performArchivalReplacementIfEligible(@NonNull @NonNull String entityId, @NonNull @NonNull UserPermission existing, @NonNull @NonNull Instant changeTimestamp)
-
modifyForArchival
protected void modifyForArchival(UserPermission target)
Mimic whatUserPermissionService.archive(String)
would do to mark this record as archived.- Parameters:
target
- the instance to modify
-
updatePermissionInfo
protected void updatePermissionInfo(AdminPermission request, UserPermission permission)
-
updatePermissionTenantRestrictions
protected void updatePermissionTenantRestrictions(AdminPermission request, UserPermission permission)
-
getSupportedSimpleTypeNames
public String[] getSupportedSimpleTypeNames()
-
getUserPermissionService
protected UserPermissionService<UserPermission> getUserPermissionService()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
-