Class ContextRequest

java.lang.Object
com.broadleafcommerce.data.tracking.core.context.ContextRequest

public class ContextRequest extends Object
Specific context information related to sandbox and/or multitenant state. This information is generally harvested from an API request over HTTP in the form of the X-Context-Request header. This header value is expressed as a json string and conversion is generally performed automatically by Spring in any MVC Controller implementations using the ContextRequestConverter and included inside of ContextInfo by ContextInfoHandlerMethodArgumentResolver. Therefore, you can simply include ContextInfo as a parameter to method in your request mapping method Spring will construct a valid instance for you.
Author:
Jeff Fischer
  • Constructor Details

    • ContextRequest

      public ContextRequest(@NonNull ContextRequest contextRequest)
      Create a copy of an existing ContextRequest.

      Note that catalog and application are not deep copies.

      Parameters:
      contextRequest - The ContextRequest to copy from.
    • ContextRequest

      public ContextRequest()
  • Method Details

    • withSandBoxName

      public ContextRequest withSandBoxName(String sandBoxName)
    • withSandBoxId

      public ContextRequest withSandBoxId(String sandBoxId)
    • withCatalogId

      public ContextRequest withCatalogId(String catalogId)
    • withApplicationId

      public ContextRequest withApplicationId(String applicationId)
    • withCustomerContextId

      public ContextRequest withCustomerContextId(String customerContextId)
    • withApplication

      public ContextRequest withApplication(Application application)
    • withCatalog

      public ContextRequest withCatalog(Catalog catalog)
    • withCatalogHierarchy

      public ContextRequest withCatalogHierarchy(InheritanceLines catalogHierarchy)
    • withCatalogLevel

      public ContextRequest withCatalogLevel(Long catalogLevel)
    • withTenantId

      public ContextRequest withTenantId(String tenantId)
    • withAccountId

      public ContextRequest withAccountId(String accountId)
    • withChangeContainer

      public ContextRequest withChangeContainer(ChangeContainer changeContainer)
    • isForceCatalogForFetch

      public boolean isForceCatalogForFetch()
      Delegates to forceFilterByCatalogIncludeInheritance as forceCatalogForFetch is deprecated.
    • setForceCatalogForFetch

      public void setForceCatalogForFetch(boolean forceCatalogForFetch)
      Delegates to forceFilterByCatalogIncludeInheritance as forceCatalogForFetch is deprecated.
    • getSandboxId

      public String getSandboxId()
      The id for the current user sandbox. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity. Multiple versions will share the same context id.
      Returns:
      The id for the current user sandbox
    • getSandboxName

      public String getSandboxName()
      The friendly name for the current user sandbox.
      Returns:
      The friendly name for the current user sandbox
    • getCatalogId

      public String getCatalogId()
      A multitenant concept, the id for the current catalog. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity.
      Returns:
      The id for the current catalog
    • isForceFilterByCatalogIncludeInheritance

      public boolean isForceFilterByCatalogIncludeInheritance()
      Whether to force include sandbox and production records for the explicitly targeted catalog (catalogId), while including the production records inherited from the catalogHierarchy.

      Only one of forceFilterByCatalogIncludeInheritance or forceFilterByCatalogExcludeInheritance should be set to true, not both

      Returns:
      Whether to force include sandbox and production records for the explicitly targeted catalog (catalogId), while including the production records inherited from the catalogHierarchy
    • isForceFilterByCatalogExcludeInheritance

      public boolean isForceFilterByCatalogExcludeInheritance()
      Whether to force include all records (both sandbox and production) for the explicitly targeted catalog (catalogId) only, excluding any records inherited from the catalogHierarchy.

      Only one of forceFilterByCatalogIncludeInheritance or forceFilterByCatalogExcludeInheritance should be set to true, not both

      Returns:
      Whether to force catalog criteria for all records to be built off the catalogId only
    • getApplicationId

      public String getApplicationId()
      A multitenant concept, the id for the current application. Catalogs are generally associated with applications. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity.
      Returns:
      The id for the current application
    • getTenantId

      public String getTenantId()
      A multitenant concept, the id for the current tenant. Represents the distinct, completely independent contexts, for example owned by separate companies. Applications always belong to a tenant.
      Returns:
      The id for the current tenant
    • getCustomerContextId

      public String getCustomerContextId()
      Returns the customer context id that is used to discriminate entities with TrackableBehavior.CUSTOMER_CONTEXT.
      Returns:
      the customer context id
    • getAccountId

      public String getAccountId()
      If in an account context, this represents the current account ID.
      Returns:
      the account id
    • getChangeContainer

      public ChangeContainer getChangeContainer()
      Metadata used to populate any ChangeEvent created from this request.
      Returns:
      Metadata used to populate any ChangeEvent created from this request
    • getApplication

      public Application getApplication()
      Context instance of the Application entity related to this applicationId. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of application using applicationId in the ContextRequestConverter.
      Returns:
      Context instance of the Application entity related to this applicationId
    • getCatalog

      public Catalog getCatalog()
      Context instance of the Catalog entity related to this catalogId. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of catalog using catalogId in the ContextRequestHydrator.
      Returns:
      Context instance of the Catalog entity related to this catalogId or null if there was no catalogId given
    • getCatalogHierarchy

      public InheritanceLines getCatalogHierarchy()
      Each level within the explicit catalog hierarchy made from resolving a catalog via the catalogId. This can be used to obtain the a list of the contextIds for the deep catalog tree parents. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of catalog using catalogId in the ContextRequestHydrator.
      Returns:
      the deep catalog tree parenting the catalogId
    • getCatalogLevel

      public Long getCatalogLevel()
      If the catalogId is set, catalogLevel represents the sorting level of that catalog in the overall hierarchy. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of application using applicationId in the ContextRequestHydrator.
      Returns:
      Represents the sorting level of that catalog in the overall hierarchy
    • setSandboxId

      public void setSandboxId(String sandboxId)
      The id for the current user sandbox. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity. Multiple versions will share the same context id.
      Parameters:
      sandboxId - The id for the current user sandbox
    • setSandboxName

      public void setSandboxName(String sandboxName)
      The friendly name for the current user sandbox.
      Parameters:
      sandboxName - The friendly name for the current user sandbox
    • setCatalogId

      public void setCatalogId(String catalogId)
      A multitenant concept, the id for the current catalog. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity.
      Parameters:
      catalogId - The id for the current catalog
    • setForceFilterByCatalogIncludeInheritance

      public void setForceFilterByCatalogIncludeInheritance(boolean forceFilterByCatalogIncludeInheritance)
      Whether to force include sandbox and production records for the explicitly targeted catalog (catalogId), while including the production records inherited from the catalogHierarchy.

      Only one of forceFilterByCatalogIncludeInheritance or forceFilterByCatalogExcludeInheritance should be set to true, not both

      Parameters:
      forceFilterByCatalogIncludeInheritance - Whether to force include sandbox and production records for the explicitly targeted catalog (catalogId), while including the production records inherited from the catalogHierarchy
    • setForceFilterByCatalogExcludeInheritance

      public void setForceFilterByCatalogExcludeInheritance(boolean forceFilterByCatalogExcludeInheritance)
      Whether to force include all records (both sandbox and production) for the explicitly targeted catalog (catalogId) only, excluding any records inherited from the catalogHierarchy.

      Only one of forceFilterByCatalogIncludeInheritance or forceFilterByCatalogExcludeInheritance should be set to true, not both

      Parameters:
      forceFilterByCatalogExcludeInheritance - Whether to force catalog criteria for all records to be built off the catalogId only
    • setApplicationId

      public void setApplicationId(String applicationId)
      A multitenant concept, the id for the current application. Catalogs are generally associated with applications. This is used to discriminate results in order to make sure CRUD operations are executed against the right version of an entity.
      Parameters:
      applicationId - The id for the current application
    • setTenantId

      public void setTenantId(String tenantId)
      A multitenant concept, the id for the current tenant. Represents the distinct, completely independent contexts, for example owned by separate companies. Applications always belong to a tenant.
      Parameters:
      tenantId - The id for the current tenant
    • setCustomerContextId

      public void setCustomerContextId(String customerContextId)
      Returns the customer context id that is used to discriminate entities with TrackableBehavior.CUSTOMER_CONTEXT.
      Parameters:
      customerContextId - the customer context id
    • setAccountId

      public void setAccountId(String accountId)
      If in an account context, this represents the current account ID.
      Parameters:
      accountId - the account id
    • setChangeContainer

      public void setChangeContainer(ChangeContainer changeContainer)
      Metadata used to populate any ChangeEvent created from this request.
      Parameters:
      changeContainer - Metadata used to populate any ChangeEvent created from this request
    • setApplication

      public void setApplication(Application application)
      Context instance of the Application entity related to this applicationId. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of application using applicationId in the ContextRequestConverter.
      Parameters:
      application - Context instance of the Application entity related to this applicationId
    • setCatalog

      public void setCatalog(Catalog catalog)
      Context instance of the Catalog entity related to this catalogId. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of catalog using catalogId in the ContextRequestHydrator.
      Parameters:
      catalog - Context instance of the Catalog entity related to this catalogId
    • setCatalogHierarchy

      public void setCatalogHierarchy(InheritanceLines catalogHierarchy)
      Each level within the explicit catalog hierarchy made from resolving a catalog via the catalogId. This can be used to obtain the a list of the contextIds for the deep catalog tree parents. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of catalog using catalogId in the ContextRequestHydrator.
      Parameters:
      catalogHierarchy - the deep catalog tree parenting the catalogId
    • setCatalogLevel

      public void setCatalogLevel(Long catalogLevel)
      If the catalogId is set, catalogLevel represents the sorting level of that catalog in the overall hierarchy. This is not a value that is generally populated via JSON. Rather, this variable is generally calculated via lookup of application using applicationId in the ContextRequestHydrator.
      Parameters:
      catalogLevel - Represents the sorting level of that catalog in the overall hierarchy
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object