public class DefaultBasicAuditUtility extends Object implements BasicAuditUtility
Constructor and Description |
---|
DefaultBasicAuditUtility(RepositoryUtility repositoryUtility,
com.broadleafcommerce.common.extension.TypeFactory typeFactory) |
Modifier and Type | Method and Description |
---|---|
void |
setCreateInformation(String author,
BasicAuditable auditable)
Given an entity instance, set the create portion of
BasicAuditable . |
void |
setUpdateInformation(String author,
BasicAuditable auditable)
Given an entity instance, set the update portion of
BasicAuditable . |
void |
setUpdateInformation(String author,
BasicAuditable auditable,
BasicAuditable example)
Given an entity instance, set the update portion of
BasicAuditable . |
<D extends Trackable> |
touch(ContextInfo contextInfo,
String contextId,
Class<D> repositoryEntityType,
Trackable example)
Set the update portion of a
BasicAuditable identified by the type and contextId, and
then persist that change. |
public DefaultBasicAuditUtility(RepositoryUtility repositoryUtility, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
public void setUpdateInformation(@Nullable String author, BasicAuditable auditable)
BasicAuditUtility
BasicAuditable
. Usually leveraged
as part of another flow that is mutating and persisting an entity.setUpdateInformation
in interface BasicAuditUtility
author
- The creator of the update based on the authentication principalauditable
- The entity instance that exposes basic audit fieldspublic void setUpdateInformation(@Nullable String author, BasicAuditable auditable, @Nullable BasicAuditable example)
BasicAuditUtility
BasicAuditable
. Usually leveraged
as part of another flow that is mutating and persisting an entity.setUpdateInformation
in interface BasicAuditUtility
author
- The creator of the update based on the authentication principalauditable
- The entity instance that exposes basic audit fieldsexample
- a BasicAuditable
instance from which to derive the update date for the
touch. The operation will only complete if the example update or creation date is
newer than the update date already on the target.public void setCreateInformation(@Nullable String author, BasicAuditable auditable)
BasicAuditUtility
BasicAuditable
. Usually leveraged
as part of another flow that is mutating and persisting an entity.setCreateInformation
in interface BasicAuditUtility
author
- The creator of the update based on the authentication principalauditable
- The entity instance that exposes basic audit fieldspublic <D extends Trackable> D touch(@Nullable ContextInfo contextInfo, String contextId, Class<D> repositoryEntityType, @Nullable Trackable example)
BasicAuditUtility
BasicAuditable
identified by the type and contextId, and
then persist that change. This update also does not create sandbox state as a normal service
operation might. The update here merely alters the persisted state of the entity found
without further direct catalog propagation or sandbox support.
This method is generally used to arbitrarily mark entity instances as updated - usually in response to another entity update by the system. Most commonly, it is a response to an update of a subordinate entity, when the desire is to also mark a parent entity as updated (even though it was not itself directly impacted). For example, it may be desirable to touch a Customer entity when a related CustomerAddress instance is updated. Actions such as this are normally taken by listeners for the
InternalPersistenceEvent
.touch
in interface BasicAuditUtility
D
- The entity typecontextInfo
- Represents context information regarding the current API requestcontextId
- The Trackable
id associated with the entity.repositoryEntityType
- The class type for the entityexample
- a Trackable
instance from which to derive the update date for the
touch. The operation will only complete if the example update or creation date is
newer than the update date already on the target.Copyright © 2021. All rights reserved.