public class UpdateValidationDomainMapperMember extends Object implements DomainMapperMember, IdAware
A special DomainMapperMember
which is responsible for validating the id variable state
for update requests. Update requests (including replace) include a path parameter in the API that
identifies the entity receiving the update. However, the payload may also contain an id value
that may end up being applied during the mapping phase to the repository state. This mapper
member performs some lightweight checks and mitigations:
ValidationException
.CrudEntityService.replace(String, Object, ContextInfo)
and
CrudEntityService.update(String, Object, ContextInfo)
, and is used to find the entity
which will be replaced or updated. If found, this is the entity that becomes the
repositoryDomain
argument to fromBusinessDomain(Object, Object, ContextInfo)
.
Thus, its contextId
can be reliably used as the "path parameter" source of truth on what
the ID should be, and this implementation uses it as such.IdAware.Id
Constructor and Description |
---|
UpdateValidationDomainMapperMember() |
Modifier and Type | Method and Description |
---|---|
<D> D |
fromBusinessDomain(Object businessDomain,
D repositoryDomain,
ContextInfo contextInfo)
Validates the identifier value state for a mutation request.
|
String |
getDataRoutePartition() |
int |
getOrder() |
<D,P> D |
modifyMap(D repositoryDomain,
P businessDomain,
ContextInfo contextInfo,
boolean allowNull)
Validates the identifier value state for a mutation request.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromRepositoryDomain
deleteMap, getBusinessDomainType
public String getDataRoutePartition()
getDataRoutePartition
in interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
public <D> D fromBusinessDomain(@Nullable Object businessDomain, @Nullable D repositoryDomain, @Nullable ContextInfo contextInfo)
fromBusinessDomain
in interface DomainMapperMember
D
- The repository entity typebusinessDomain
- The business instance containing the relevant property informationrepositoryDomain
- The repository specific instance to affect and returncontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns. See TrackableRepository
for more info on
persistence behavior based on context.public <D,P> D modifyMap(D repositoryDomain, P businessDomain, ContextInfo contextInfo, boolean allowNull)
modifyMap
in interface DomainMapper
D
- The repository entity typeP
- The projection typerepositoryDomain
- The persistence domain instance to modifybusinessDomain
- The business instance containing changes to map to the repository
domaincontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns. See TrackableRepository
for more info on
persistence behavior based on context.allowNull
- Whether or not null values in properties in the payload instance should be
ignored during the mapping operation.public int getOrder()
getOrder
in interface DomainMapperMember
getOrder
in interface org.springframework.core.Ordered
Copyright © 2021. All rights reserved.