Class AdminRolePersistenceHandler
java.lang.Object
com.broadleafcommerce.auth.user.listener.AuthDataUpdatePersistenceHandler
com.broadleafcommerce.auth.user.listener.OperationAwarePersistenceHandler
com.broadleafcommerce.auth.user.listener.AdminRolePersistenceHandler
- All Implemented Interfaces:
com.broadleafcommerce.common.messaging.PersistenceHandler
Handles messages from the Persistence channel for
AdminRole data to update
UserRole. This is designed to perform a replacement of existing data within this service
from the admin user service.- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorsConstructorDescriptionAdminRolePersistenceHandler(UserRoleService<UserRole> userRoleService, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected UserRolebuildUserRoleForCreate(String id, AdminRole request, Instant lastUpdated) protected AdminRoledeserialize(com.fasterxml.jackson.databind.JsonNode jsonNode) String[]protected com.broadleafcommerce.common.extension.TypeFactoryprotected UserRoleService<UserRole>voidprotected voidmapUpdatesFromRequest(AdminRole request, UserRole target) protected voidmodifyForArchival(UserRole target) Mimic whatUserRoleService.archive(String)would do to mark this record as archived.protected voidperformArchivalReplacementIfEligible(@NonNull String entityId, @NonNull UserRole existing, @NonNull Instant changeTimestamp) protected voidperformReplacementIfEligible(@NonNull String entityId, @NonNull UserRole existing, @NonNull AdminRole request, @NonNull Instant changeTimestamp) protected voidprocessCreateOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) Invoked if the persistence message had anOperationTypeofOperationType.CREATE.protected voidprocessDeleteOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) Archives the given entity.protected voidprocessUpdateOperation(@NonNull String entityId, @NonNull Instant changeTimestamp, @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) Invoked if the persistence message had anOperationTypeofOperationType.UPDATE.protected voidupdateBasicRoleInfo(AdminRole request, UserRole role) protected voidupdateParent(AdminRole request, UserRole role) Don't validate parent or ancestry here, since we expect the admin user service to have pre-validated it against cycles or broken references.protected voidupdatePermissions(AdminRole request, UserRole role) We will not validate these references by querying for them, as the associated permissions may not yet be synchronized to the authentication service.protected voidupdateRoleTenantRestrictions(AdminRole request, UserRole role) Methods inherited from class com.broadleafcommerce.auth.user.listener.OperationAwarePersistenceHandler
getChangeTimestamp, getEntityIdOrThrow, getNonNullField, getValidOperationTypeOrThrow, processStateChange, processStateChangeMethods inherited from class com.broadleafcommerce.auth.user.listener.AuthDataUpdatePersistenceHandler
getObjectMapper, handle, isNodeNull, isValidTypeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.common.messaging.PersistenceHandler
validate
-
Constructor Details
-
AdminRolePersistenceHandler
public AdminRolePersistenceHandler(UserRoleService<UserRole> userRoleService, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
hook
-
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:OperationAwarePersistenceHandlerInvoked if the persistence message had anOperationTypeofOperationType.CREATE.- Specified by:
processCreateOperationin 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
-
buildUserRoleForCreate
-
mapUpdatesFromRequest
-
deserialize
protected AdminRole 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:OperationAwarePersistenceHandlerInvoked if the persistence message had anOperationTypeofOperationType.UPDATE.- Specified by:
processUpdateOperationin 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
-
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:
processDeleteOperationin 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
-
modifyForArchival
Mimic whatUserRoleService.archive(String)would do to mark this record as archived.- Parameters:
target- the instance to modify
-
updatePermissions
We will not validate these references by querying for them, as the associated permissions may not yet be synchronized to the authentication service. We trust the admin user service to have pre-validated these associations, and thus eventually no references will be broken.TODO https://github.com/BroadleafCommerce/AuthenticationServices/issues/182
- Parameters:
request- the request whose permissions should be used to replace the existing datarole- the target on which the permissions will be replaced
-
updateBasicRoleInfo
-
updateParent
Don't validate parent or ancestry here, since we expect the admin user service to have pre-validated it against cycles or broken references. Thus if this reference is currently broken or causes a problem, it's probably due to out-of-order message delivery and we expect it to be resolved shortly via another persistence message.- Parameters:
request- the payload received in the persistence messagerole- the target instance to update- See Also:
-
updateRoleTenantRestrictions
-
getSupportedSimpleTypeNames
-
getUserRoleService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-