public class AdminRolePersistenceHandler extends OperationAwarePersistenceHandler
AdminRole
data to update
UserRole
. This is designed to perform a replacement of existing data within this service
from the admin user service.Constructor and Description |
---|
AdminRolePersistenceHandler(UserRoleService<UserRole> userRoleService,
com.fasterxml.jackson.databind.ObjectMapper mapper,
com.broadleafcommerce.common.extension.TypeFactory typeFactory) |
Modifier and Type | Method and Description |
---|---|
protected UserRole |
buildUserRoleForCreate(String id,
AdminRole request,
Instant lastUpdated) |
protected AdminRole |
deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode) |
String[] |
getSupportedSimpleTypeNames() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
protected UserRoleService<UserRole> |
getUserRoleService() |
void |
hook(String entityJson) |
protected void |
mapUpdatesFromRequest(AdminRole request,
UserRole target) |
protected void |
modifyForArchival(UserRole target)
Mimic what
UserRoleService.archive(String) would do to mark this record as archived. |
protected void |
performArchivalReplacementIfEligible(@NonNull String entityId,
@NonNull UserRole existing,
@NonNull Instant changeTimestamp) |
protected void |
performReplacementIfEligible(@NonNull String entityId,
@NonNull UserRole existing,
@NonNull AdminRole 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 an
OperationType of
OperationType.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 an
OperationType of
OperationType.UPDATE . |
protected void |
updateBasicRoleInfo(AdminRole request,
UserRole role) |
protected void |
updateParent(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 void |
updatePermissions(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 void |
updateRoleTenantRestrictions(AdminRole request,
UserRole role) |
getChangeTimestamp, getEntityIdOrThrow, getNonNullField, getValidOperationTypeOrThrow, processStateChange, processStateChange
getObjectMapper, handle, isNodeNull, isValidType
public AdminRolePersistenceHandler(UserRoleService<UserRole> userRoleService, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
@StreamListener(value="persistenceInputAdminRole") public void hook(String entityJson)
protected void processCreateOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
OperationAwarePersistenceHandler
OperationType
of
OperationType.CREATE
.processCreateOperation
in class OperationAwarePersistenceHandler
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.IOException
protected UserRole buildUserRoleForCreate(String id, AdminRole request, Instant lastUpdated)
protected AdminRole deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode) throws IOException
IOException
protected void processUpdateOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
OperationAwarePersistenceHandler
OperationType
of
OperationType.UPDATE
.processUpdateOperation
in class OperationAwarePersistenceHandler
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.IOException
protected void performReplacementIfEligible(@NonNull @NonNull String entityId, @NonNull @NonNull UserRole existing, @NonNull @NonNull AdminRole request, @NonNull @NonNull Instant changeTimestamp)
protected void processDeleteOperation(@NonNull @NonNull String entityId, @NonNull @NonNull Instant changeTimestamp, @NonNull @NonNull com.fasterxml.jackson.databind.JsonNode entityJson) throws IOException
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.
processDeleteOperation
in class OperationAwarePersistenceHandler
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.IOException
protected void performArchivalReplacementIfEligible(@NonNull @NonNull String entityId, @NonNull @NonNull UserRole existing, @NonNull @NonNull Instant changeTimestamp)
protected void modifyForArchival(UserRole target)
UserRoleService.archive(String)
would do to mark this record as archived.target
- the instance to modifyprotected void updatePermissions(AdminRole request, UserRole role)
TODO https://github.com/BroadleafCommerce/AuthenticationServices/issues/182
request
- the request whose permissions should be used to replace the existing datarole
- the target on which the permissions will be replacedprotected void updateParent(AdminRole request, UserRole role)
request
- the payload received in the persistence messagerole
- the target instance to updateUserRoleService.createOnlyIfDoesNotExist(UserRole, Instant)
,
UserRoleService.replaceOnlyIfLastUpdatedBefore(String, UserRole, Instant)
protected void updateRoleTenantRestrictions(AdminRole request, UserRole role)
public String[] getSupportedSimpleTypeNames()
protected UserRoleService<UserRole> getUserRoleService()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Copyright © 2021. All rights reserved.