public class ContextInfo extends Object implements com.broadleafcommerce.common.extension.cache.temporal.TemporalIdentifier
@RestController
implementation before being passed as a parameter to an
internal data service.Modifier and Type | Class and Description |
---|---|
static class |
ContextInfo.QueryHint
This is a generic hint concept that is used to influence persistence tier queries.
|
static class |
ContextInfo.QueryHints
Container object for one or more
ContextInfo.QueryHint instances. |
static interface |
ContextInfo.QueryInfluencer
A dynamic component that the
NarrowExecutor will invoke to generate a Node
filter string that can be parsed and set as a predicate on the ultimate query it is
processing. |
Constructor and Description |
---|
ContextInfo() |
ContextInfo(ContextInfo contextInfo)
Create a copy of an existing ContextInfo, including a copy of its
ContextRequest . |
ContextInfo(OperationType operationType) |
ContextInfo(OperationType operationType,
boolean ignoreNarrowing)
Convenience constructor to set the operationType and ignoreNarrowing indicator
|
ContextInfo(OperationType operationType,
ContextRequest request)
Convenience method for operationType and contextRequest
|
ContextInfo(OperationType operationType,
ContextRequest request,
String author)
Convenience method for operationType and contextRequest
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
Map<String,Object> |
getAdditionalProperties()
This is a generic Map to support the ability for Broadleaf clients, specifically, to add
additional (typically transient) properties during a particular request flow to support
setting up and passing along additional state throughout a particular API invocation or web
request.
|
String |
getAuthor()
Returns the user principal for this request.
|
ContextIdOverwriteBehavior |
getContextIdOverwriteBehavior()
Used for
OperationType.CREATE requests for entities to determine whether
CreateSetupDomainMapperMember should autogenerate a context ID for the current
request. |
ContextRequest |
getContextRequest()
Specific sandbox and multitenant context information.
|
Currency |
getDefaultCurrency()
The default
Currency for this request. |
String |
getIpAddress()
The ip address of the remote caller
|
Locale |
getLocale()
The
Locale for this context, primarily used for translation. |
OperationType |
getOperationType()
The type of CRUD operation being requested
|
Instant |
getPreviewDate()
The date in which to preview data.
|
PreviewToken |
getPreviewToken()
The preview token for use when previewing sandbox data.
|
ContextInfo.QueryHints |
getQueryHints() |
List<ContextInfo.QueryInfluencer> |
getQueryInfluencers()
This field is not serialized or deserialized as
QueryInfluencers are
dynamic, functional components that execute logic rather than hold data. |
int |
hashCode() |
boolean |
hasPreviewDate()
Return true if this request is using a preview date.
|
boolean |
isClearOverride()
Used for
OperationType.DELETE requests of entities marked as
TrackableBehavior.CATALOG to indicate whether the record for deletion is an override
of a parent catalog that should be cleared instead of deleted. |
boolean |
isFilterByActiveDates()
Whether or not entities that implement
ActiveAware will be filtered by their active
dates during fetch narrowing. |
boolean |
isIgnoreDeleteFiltering()
Whether or not to ignore narrowing on deleted sandbox items.
|
boolean |
isIgnoreNarrowing()
Whether or not to turn off sandbox and multitenant narrowing behavior.
|
boolean |
isIgnoreTranslation()
Whether to ignore the process of translating fields while executing
DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo) for a given
request. |
boolean |
isIncludePendingCatalogs()
Whether or not pending catalogs should be included in this context.
|
Instant |
nowOrPreviewDate()
Returns the time to be used for the current request.
|
void |
setAuthor(String author)
Intended to be the current Spring Security principal (the logged in user)
|
void |
setClearOverride(boolean clearOverride)
Used for
OperationType.DELETE requests of entities marked as
TrackableBehavior.CATALOG to indicate whether the record for deletion is an override
of a parent catalog that should be cleared instead of deleted. |
void |
setContextIdOverwriteBehavior(ContextIdOverwriteBehavior contextIdOverwriteBehavior)
Used for
OperationType.CREATE requests for entities to determine whether
CreateSetupDomainMapperMember should autogenerate a context ID for the current
request. |
void |
setContextRequest(ContextRequest contextRequest)
Specific sandbox and multitenant context information.
|
void |
setDefaultCurrency(Currency defaultCurrency)
The default
Currency for this request. |
void |
setFilterByActiveDates(boolean filterByActiveDates) |
void |
setIgnoreDeleteFiltering(boolean ignoreDeleteFiltering)
Whether or not to ignore narrowing on deleted sandbox items.
|
void |
setIgnoreNarrowing(boolean ignoreNarrowing)
Whether or not to turn off sandbox and multitenant narrowing behavior.
|
void |
setIgnoreTranslation(boolean ignoreTranslation)
Whether to ignore the process of translating fields while executing
DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo) for a given
request. |
void |
setIncludePendingCatalogs(boolean includePendingCatalogs)
Whether or not pending catalogs should be included in this context.
|
void |
setIpAddress(String ipAddress)
The ip address of the remote caller
|
void |
setLocale(Locale locale)
The
Locale for this context, primarily used for translation. |
void |
setOperationType(OperationType operationType)
The type of CRUD operation being requested
|
void |
setPendingCatalogs(boolean includePendingCatalogs) |
void |
setPreviewDate(Instant previewDate)
The date in which to preview data.
|
void |
setPreviewToken(PreviewToken previewToken)
The preview token for use when previewing sandbox data.
|
void |
setQueryHints(ContextInfo.QueryHints queryHints) |
void |
setQueryInfluencers(List<ContextInfo.QueryInfluencer> queryInfluencers)
This field is not serialized or deserialized as
QueryInfluencers are
dynamic, functional components that execute logic rather than hold data. |
String |
toString() |
ContextInfo |
withOperationType(ContextInfo info,
OperationType type)
Creates a new ContextInfo and sets the operation type.
|
public ContextInfo(@NonNull OperationType operationType)
public ContextInfo(OperationType operationType, boolean ignoreNarrowing)
operationType
- ignoreNarrowing
- public ContextInfo(@NonNull OperationType operationType, ContextRequest request)
operationType
- public ContextInfo(@NonNull OperationType operationType, ContextRequest request, String author)
operationType
- public ContextInfo(@NonNull ContextInfo contextInfo)
ContextRequest
.contextInfo
- The ContextInfo to create the copy from.ContextRequest(ContextRequest)
public ContextInfo()
public void setFilterByActiveDates(boolean filterByActiveDates)
public String getAuthor()
If a previewToken
is present, and it matches the current context, this will return
PreviewToken.getAuthor()
instead. This is primarily engaged to allow anonymous
requests from an application to preview a user's sandbox data.
public Instant nowOrPreviewDate()
Instant.now()
, except for when a valid previewDate
is set, in which case the
preview date will be used.nowOrPreviewDate
in interface com.broadleafcommerce.common.extension.cache.temporal.TemporalIdentifier
public boolean hasPreviewDate()
public void setPendingCatalogs(boolean includePendingCatalogs)
public ContextInfo withOperationType(ContextInfo info, OperationType type)
type
- public String getIpAddress()
public boolean isIgnoreNarrowing()
Trackable
instance based on
other information within the ContextInfo
. See TrackableRepository
for more
information.public boolean isIgnoreDeleteFiltering()
public boolean isIncludePendingCatalogs()
public Locale getLocale()
Locale
for this context, primarily used for translation.Locale
for this context, primarily used for translationpublic Currency getDefaultCurrency()
Currency
for this request. This is typically set by a
ContextInfoCustomizer
implementation. This may be null if not otherwise resolved.public Map<String,Object> getAdditionalProperties()
public boolean isIgnoreTranslation()
DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo)
for a given
request.DomainMapperManager.fromRepositoryDomain(java.lang.Object, java.lang.Class<P>, com.broadleafcommerce.data.tracking.core.context.ContextInfo)
for a given requestpublic boolean isClearOverride()
OperationType.DELETE
requests of entities marked as
TrackableBehavior.CATALOG
to indicate whether the record for deletion is an override
of a parent catalog that should be cleared instead of deleted.TrackableBehavior.CATALOG
record for OperationType.DELETE
is an override that should be cleared.public ContextInfo.QueryHints getQueryHints()
public List<ContextInfo.QueryInfluencer> getQueryInfluencers()
QueryInfluencers
are
dynamic, functional components that execute logic rather than hold data. These are intended
to be added and used by internal service logic for internal use rather than transferred
between services.ContextInfo.QueryInfluencer
public ContextIdOverwriteBehavior getContextIdOverwriteBehavior()
OperationType.CREATE
requests for entities to determine whether
CreateSetupDomainMapperMember
should autogenerate a context ID for the current
request. This allows for different behavior on a request-by-request basis to override the
global system behavior defined in
CreateSetupDomainMapperMember.isAutogenerateContextIdIfUnset()
and
CreateSetupDomainMapperMember.isOverwriteExistingContextIdOnCreate()
.@NonNull public ContextRequest getContextRequest()
public PreviewToken getPreviewToken()
This token is expected to be validated to match the current request during policy validation and if it passes, will be used to inform the narrowing behavior for sandboxable entities.
for how this is resolves from a web request
public Instant getPreviewDate()
nowOrPreviewDate()
for their date filtering.
This will only be defined and applicable when a valid previewToken
exists on the
context.
This will be ignored if it is ever found to be before Instant.now()
, as this
functionality is only intended to support previewing future states, and never past states.
public boolean isFilterByActiveDates()
ActiveAware
will be filtered by their active
dates during fetch narrowing.isFilterByActiveDates
in interface com.broadleafcommerce.common.extension.cache.temporal.TemporalIdentifier
public void setAuthor(String author)
author
- The logged in userpublic void setIpAddress(String ipAddress)
ipAddress
- The ip addresspublic void setIgnoreNarrowing(boolean ignoreNarrowing)
Trackable
instance based on
other information within the ContextInfo
. See TrackableRepository
for more
information.ignoreNarrowing
- Whether or not to turn off narrowing behaviorpublic void setIgnoreDeleteFiltering(boolean ignoreDeleteFiltering)
ignoreDeleteFiltering
- Whether or not to ignore narrowing on deleted sandbox itemspublic void setIncludePendingCatalogs(boolean includePendingCatalogs)
includePendingCatalogs
- Whether or not pending catalogs should be included in this
contextpublic void setLocale(Locale locale)
Locale
for this context, primarily used for translation.locale
- The Locale
for this context, primarily used for translationpublic void setDefaultCurrency(Currency defaultCurrency)
Currency
for this request. This is typically set by a
ContextInfoCustomizer
implementation. This may be null if not otherwise resolved.The
- default currencypublic void setIgnoreTranslation(boolean ignoreTranslation)
DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo)
for a given
request.ignoreTranslation
- Whether to ignore the process of translating fields while executing
DomainMapperManager.fromRepositoryDomain(java.lang.Object, java.lang.Class<P>, com.broadleafcommerce.data.tracking.core.context.ContextInfo)
for a given requestpublic void setClearOverride(boolean clearOverride)
OperationType.DELETE
requests of entities marked as
TrackableBehavior.CATALOG
to indicate whether the record for deletion is an override
of a parent catalog that should be cleared instead of deleted.clearOverride
- Whether the TrackableBehavior.CATALOG
record for
OperationType.DELETE
is an override that should be cleared.public void setQueryHints(ContextInfo.QueryHints queryHints)
public void setQueryInfluencers(List<ContextInfo.QueryInfluencer> queryInfluencers)
QueryInfluencers
are
dynamic, functional components that execute logic rather than hold data. These are intended
to be added and used by internal service logic for internal use rather than transferred
between services.ContextInfo.QueryInfluencer
public void setContextIdOverwriteBehavior(ContextIdOverwriteBehavior contextIdOverwriteBehavior)
OperationType.CREATE
requests for entities to determine whether
CreateSetupDomainMapperMember
should autogenerate a context ID for the current
request. This allows for different behavior on a request-by-request basis to override the
global system behavior defined in
CreateSetupDomainMapperMember.isAutogenerateContextIdIfUnset()
and
CreateSetupDomainMapperMember.isOverwriteExistingContextIdOnCreate()
.public void setContextRequest(@NonNull ContextRequest contextRequest)
contextRequest
- Request context informationpublic void setPreviewToken(PreviewToken previewToken)
This token is expected to be validated to match the current request during policy validation and if it passes, will be used to inform the narrowing behavior for sandboxable entities.
previewToken
- the decoded preview token objectfor how this is resolves from a web request
public void setPreviewDate(Instant previewDate)
nowOrPreviewDate()
for their date filtering.
This will only be defined and applicable when a valid previewToken
exists on the
context.
This will be ignored if it is ever found to be before Instant.now()
, as this
functionality is only intended to support previewing future states, and never past states.
protected boolean canEqual(Object other)
@NonNull public OperationType getOperationType()
@NonNull public void setOperationType(OperationType operationType)
operationType
- The type of CRUD operationCopyright © 2021. All rights reserved.