@RestResource(id="atg.commerce.catalog.restresources.ProductRestResource") public class ProductRestResource extends AbstractCatalogRestResource
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ARTICLE_RESOURCE_ID |
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
MEDIACONTENT_RESOURCE_ID |
protected java.lang.String |
mGiftWithPurchaseProductOverrideFilterId |
protected GWPManager |
mGwpManager |
protected java.lang.String |
mSelectableSkusRelationshipName |
static java.lang.String |
REL_NAME_PRICE |
COLLECTION_MISSING_INPUT_PARAMS, COLLECTION_PARENT_ITEM_NOT_FOUND, COLLECTION_PARENT_REPOSITORY_NOT_FOUND, COLLECTION_PROPERTY_INVALID, COLLECTION_PROPERTY_NOT_FOUND, COLLECTION_SORT_SIZE, COMMA, DEFAULT_PAGE_SIZE, ID, INVALID_QUERY_PARAMS, ITEM, ITEM_DESCRIPTOR_NOT_SUPPLIED, ITEM_NOT_FOUND, mEmbeddedRelationshipToResourceId, mRepository, PARENT_ITEM_ID, PARENT_ITEM_TYPE, PARENT_PROPERTY_NAME, REQUEST_DATA_KEY_PREFIX, RESOURCE_NAME, SEPARATOR, sResourceBundle, UNEXPECTED_ERROR
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
ProductRestResource() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getChildSkusRelationshipName()
Return the property name of the sku collection resource link, defaults to 'childSkus'
|
protected java.lang.String |
getGiftWithPurchaseParamsString(java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId)
This method returns a string representation of the three parameters,
e.g.
|
java.lang.String |
getGiftWithPurchaseProductOverrideFilterId()
Returns the GiftWithPurchaseProductOverrideFilterId property, used when
gift with purchase params passed to the GET endpoints.
|
GWPManager |
getGwpManager()
Returns property GwpManager
|
java.lang.String |
getParentCategoriesRelationshipName()
Return the relationship name to the embedded category resource for parentCategories
|
java.lang.String |
getParentCategoryRelationshipName()
Return the relationship name to the embedded category resource for parentCategory
|
java.lang.Object |
getPrice(java.lang.String pProductId,
java.lang.Boolean pFilterByCatalogFlag,
java.lang.Boolean pFilterBySiteFlag,
java.lang.String pSiteId)
Price subresource locator method
|
java.lang.String |
getPriceRelationshipName()
Get the relationship name used when embedding the price subresource.
|
RepresentationModel |
getProduct(java.lang.String pProductId,
java.lang.Boolean pFilterByCatalogFlag,
java.lang.Boolean pFilterBySiteFlag,
java.lang.String pSiteId,
java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId)
Returns a representation of a product, either for the given product id or
for a particular GWP selectable product (i.e.
|
java.lang.String |
getRelatedArticlesRelationshipName()
Return the relationship name to the embedded articles resource for relatedArticles.
|
java.lang.String |
getRelatedMediaContentRelationshipName()
Return the relationship name to the embedded articles resource for relatedMediaContent.
|
java.lang.String |
getRelatedProductsRelationshipName()
Return the relationship name to the embedded products resource for relatedProducts.
|
protected RepresentationModel.Builder |
getRepresentationModelBuilder(GiftWithPurchaseSelectionChoice pChoice,
java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId)
Gets the RepresentationModel.Builder with the given gift choice's product
acting as the state.
|
protected RepresentationModel.Builder |
getRepresentationModelBuilder(java.lang.Object pState)
Gets the RepresentationModel.Builder with the given object acting as the state.
|
java.lang.String |
getSelectableSkusRelationshipName()
Return the relationship name of the skus (collection) resource link.
|
java.lang.String |
getUpsellProductsRelationshipName()
Return the relationship name to the embedded products resource for UpsellProducts.
|
protected RepresentationModel.Builder |
listGiftProducts(java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId)
Returns a products (collection) representation model, by fetching the gift with purchase
options available, based on the parameters passed
|
RepresentationModel |
listProducts(java.lang.String pParentItemId,
java.lang.String pParentItemType,
java.lang.String pParentPropertyName,
java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId,
java.lang.String pOffset,
java.lang.String pLimit,
java.lang.String pOrderBy)
Gets a list of products.
|
void |
setChildSkusRelationshipName(java.lang.String pChildSkusRelationshipName)
Configure the relationship name used for the embedded sku collection resource, which will be
output in the (json) response.
|
void |
setEngineOverrideFilterId(java.lang.String pGiftWithPurchaseProductOverrideFilterId)
Returns the GiftWithPurchaseProductOverrideFilterId property, used when
gift with purchase params passed to the GET endpoints.
|
void |
setGwpManager(GWPManager pGwpManager)
Sets property GWPManager
|
void |
setParentCategoriesRelationshipName(java.lang.String pParentCategoriesRelationshipName)
Configure the parentCategories relationship name to the category resource (collection).
|
void |
setParentCategoryRelationshipName(java.lang.String pParentCategoryRelationshipName)
Configure the parentCategory relationship name to the category resource (singular).
|
void |
setPriceRelationshipName(java.lang.String pPriceRelationshipName)
Configure the relationship name used for the embedded price subresource, which will be output
in the (json) response.
|
void |
setRelatedArticlesRelationshipName(java.lang.String pRelatedArticlesRelationshipName)
Configure the relatedArticles relationship name to the articles collection resource.
|
void |
setRelatedMediaContentRelationshipName(java.lang.String pRelatedMediaContentRelationshipName)
Configure the relatedMediaContent relationship name to the articles collection resource.
|
void |
setRelatedProductsRelationshipName(java.lang.String pRelatedProductsRelationshipName)
Configure the relatedProducts relationship name to the products collection resource.
|
void |
setSelectableSkusRelationshipName(java.lang.String pSelectableSkusRelationshipName)
Configure the relationship name used for the embedded skus (collection) resource
used for selectable (gift) skus.
|
void |
setUpsellProductsRelationshipName(java.lang.String pUpsellProductsRelationshipName)
Configure the upsellProducts relationship name to the products collection resource.
|
protected void |
validateGiftWithPurchaseParameters(java.lang.String pGiftWithPurchaseType,
java.lang.String pGiftWithPurchaseDetail,
java.lang.String pPromotionId)
Validates the given gift with purchase parameters.
|
buildInputs, embedParentCategory, getCatalogTools, getItem, postInvoker, preInvoker, retrieveItem, setCatalogTools
addEmbeddedCollectionResource, addEmbeddedCollectionResources, buildInputs, generateRequestDataKey, getCollectionSortLimit, getDefaultLimit, getDroplet, getEmbeddedRelationshipToResourceId, getItem, getItemDescriptor, getParentRepositoryItem, getRepository, listItems, listItems, listItems, retrieveRequestData, setCollectionSortLimit, setDefaultLimit, setDroplet, setEmbeddedRelationshipToResourceId, setItemDescriptor, setRepository, validateProperty
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toString
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
public static final java.lang.String REL_NAME_PRICE
public static final java.lang.String ARTICLE_RESOURCE_ID
public static final java.lang.String MEDIACONTENT_RESOURCE_ID
protected java.lang.String mSelectableSkusRelationshipName
protected GWPManager mGwpManager
protected java.lang.String mGiftWithPurchaseProductOverrideFilterId
public void setPriceRelationshipName(java.lang.String pPriceRelationshipName)
pPriceRelationshipName
- the name of the embedded price subresource resource relationpublic java.lang.String getPriceRelationshipName()
public void setParentCategoryRelationshipName(java.lang.String pParentCategoryRelationshipName)
pParentCategoryRelationshipName
- the relationship name of the embedded category resourcepublic java.lang.String getParentCategoryRelationshipName()
public void setParentCategoriesRelationshipName(java.lang.String pParentCategoriesRelationshipName)
pParentCategoriesRelationshipName
- the relationship name of the embedded category resourcepublic java.lang.String getParentCategoriesRelationshipName()
public void setChildSkusRelationshipName(java.lang.String pChildSkusRelationshipName)
pChildSkusRelationshipName
- the name of the embedded sku colletionpublic java.lang.String getChildSkusRelationshipName()
public void setSelectableSkusRelationshipName(java.lang.String pSelectableSkusRelationshipName)
pSelectableSkusRelationshipName
- the name of the embedded sku colletionpublic java.lang.String getSelectableSkusRelationshipName()
public void setRelatedProductsRelationshipName(java.lang.String pRelatedProductsRelationshipName)
pRelatedProductsRelationshipName
- the relationship name of the embedded product resourcepublic java.lang.String getRelatedProductsRelationshipName()
public void setUpsellProductsRelationshipName(java.lang.String pUpsellProductsRelationshipName)
pUpsellProductsRelationshipName
- the relationship name of the embedded product resourcepublic java.lang.String getUpsellProductsRelationshipName()
public void setRelatedArticlesRelationshipName(java.lang.String pRelatedArticlesRelationshipName)
pRelatedArticlesRelationshipName
- the relationship name of the embedded article resourcepublic java.lang.String getRelatedArticlesRelationshipName()
public void setRelatedMediaContentRelationshipName(java.lang.String pRelatedMediaContentRelationshipName)
pRelatedMediaContentRelationshipName
- the relationship name of the embedded article resourcepublic java.lang.String getRelatedMediaContentRelationshipName()
public void setGwpManager(GWPManager pGwpManager)
pGwpManager
- the GWPManager
component property.public GWPManager getGwpManager()
GWPManager
component property.public void setEngineOverrideFilterId(java.lang.String pGiftWithPurchaseProductOverrideFilterId)
pGiftWithPurchaseProductOverrideFilterId
- set the GiftWithPurchaseProductOverrideFilterId property to this valuepublic java.lang.String getGiftWithPurchaseProductOverrideFilterId()
@Endpoint(id="/products#GET", filterId="products-Default") public RepresentationModel listProducts(java.lang.String pParentItemId, java.lang.String pParentItemType, java.lang.String pParentPropertyName, java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId, java.lang.String pOffset, java.lang.String pLimit, java.lang.String pOrderBy) throws RestException, CommerceException, RepositoryException, javax.servlet.ServletException
Retrieve the child product collection of a repository item. The parent item's property name referencing the child collection, alongside the id & item type identifying the parent item are passed as query parameters.
This top-level collection resource can be embedded in other resources, for example the category's childProducts. When embedded we support the parent item object being passed via the request data map for performance. The property name along with the item passed will be used to identify the collection.
This collection may be large, therefore it will be paged to return a manageable set of data. Paging can be controlled using the REST-Jersey framework's pagination-supported query parameter, offset & limit. If no limit (i.e.page size) is set the defaultLimit property will be used.
The collection order may be controlled using the orderBy param. Format is orderBy=propertyName:asc|desc
Alternatively, it is possible to generate the product collection by passing gift with purchase information
(pGiftWithPurchaseType, pGiftWithPurchaseDetail, pPromotionId
into this endpoint, so that a collection of gift (products) options for a qualified promotion are retrieved.
Note: If any of these (gift with purchase) parameters are passed, they must ALL be passed.
pParentItemId
- the id of the item that contains the product collection.pParentItemType
- the repository type of the item that contains the product collection,
this will support a qualifying repository e.g. /atg/commerce/ProductCatalog:product.pParentPropertyName
- the property name containing the product collection, this supports dot
notation for the collection to be displayed e.g. product.ancestorCategories.pGiftWithPurchaseType
- the type of the gift, e.g. productpGiftWithPurchaseDetail
- the detail of the gift, e.g. productHatpPromotionId
- the promotion id that offers the giftpOffset
- the page start indexpLimit
- the page sizepOrderBy
- the repository item properties to sort results by. Direction
defaults to ascending.RestException
- the rest exceptionCommerceException
- if gift with purchase data passed is invalid or backend error occursRepositoryException
- a repository exception indicating a server errorjavax.servlet.ServletException
- a servlet exception indicating a server error@Endpoint(id="/products/{productId}#GET", isSingular=true, filterId="products.id-Default") public RepresentationModel getProduct(java.lang.String pProductId, java.lang.Boolean pFilterByCatalogFlag, java.lang.Boolean pFilterBySiteFlag, java.lang.String pSiteId, java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId) throws RestException, CommerceException, RepositoryException
If any of the GWP query parameters
giftWithPurchaseType, giftWithPurchaseDetail, promotionId
are
passed, they must ALL be passed. If so the filter used for the representation
will be explicitly set to 'gwpProducts.id-Default'. This can be configured
getGiftWithPurchaseProductOverrideFilterId() setting. This representation
includes an embedded skus (collection) resource named 'selectableSkus',
which are the selectable gift skus for a particular (gift) product.
If this is a top-level resource product retrieval we will filter the product by the filterBySite, filterByCatalog & siteId query params but only if the underlying ProductLookup droplet has its useParams set to true. If this is set to false then the query params are ignored and the corresponding ProductLookup properties are always used.
If this is a sub-resource retrieval, i.e. embedded via another resource, we will first check the request data map to see if the parent resource had the item and passed it through. Otherwise we will check if the parent resource has indicated a direct retrieval should be done. For all the ootb resources embedding product(s) this is set as we always want the embedded resource to be shown. nb potential for this embedded item's self link to not work, if the top-level call is configured to be filtered by current site/catalog based on customer's ProductLookup config - useParams, filterBySite & filterByCatalog.
OOTB the product representation includes the prices sub resource @see PriceRestSubresource and the embedded relationship to the product's childSkus @see SkuRestResource; parentCategory @see CategoryRestResource; parentCategories; relatedProducts; upsellProducts; relatedArticles @see ArticleRestResource & relatedMediaContent @see MediaContentRestResource. The REST-Jersey framework 'expand' & 'maxDepth' params can be used to control the embedded items that get expanded.
pProductId
- the id of the product to findpFilterByCatalogFlag
- if true only find the product if the product's catalog matches the users catalog.pFilterBySiteFlag
- if true only find the product if it matches siteId or the current site contextpSiteId
- site id product should belong to. If not set current site context will be used.pGiftWithPurchaseType
- the type of the gift, e.g. productpGiftWithPurchaseDetail
- the detail of the gift, e.g. productHatpPromotionId
- the promotion id that offers the giftRestException
- the rest exceptionCommerceException
- if gift with purchase data passed is invalid or backend error occursRepositoryException
- if product repository lookup fails@SubresourceLocator(subresourceIds="atg.commerce.pricing.restresources.PriceRestSubresource") public java.lang.Object getPrice(java.lang.String pProductId, java.lang.Boolean pFilterByCatalogFlag, java.lang.Boolean pFilterBySiteFlag, java.lang.String pSiteId) throws RestException
pProductId
- the id of the product to findpFilterByCatalogFlag
- if true only find the product if the product's catalog matches the users catalog.pFilterBySiteFlag
- if true only find the product if it matches siteId or the current site contextpSiteId
- site id product should belong to. If not set current site context will be used.RestException
- if a problem occurs obtaining the subresourceprotected java.lang.String getGiftWithPurchaseParamsString(java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId)
pGiftWithPurchaseType
- the type of gift, e.g. productpGiftWithPurchaseDetail
- the gift detail, e.g. productHatpPromotionId
- the promotion id that offers the gift, e.g. promo123protected void validateGiftWithPurchaseParameters(java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId) throws RestException
pGiftWithPurchaseType
- the gift type, e.g. productpGiftWithPurchaseDetail
- the gift detail, e.g. product123pPromotionId
- the promotion id that qualifies the giftRestException
- if any of the supplied parameters are nullprotected RepresentationModel.Builder getRepresentationModelBuilder(java.lang.Object pState)
Also embeds child skus, related products, upsell products, articles and media.
getRepresentationModelBuilder
in class AbstractItemLookupRestResource
pState
- the state that will be added to the representation modelprotected RepresentationModel.Builder getRepresentationModelBuilder(GiftWithPurchaseSelectionChoice pChoice, java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId) throws RestException
The method overrides the default filter to that configured in
getGiftWithPurchaseProductOverrideFilterId
method.
pChoice
- gift with purchase choicepGiftWithPurchaseType
- the gift type, e.g. productpGiftWithPurchaseDetail
- the gift detail, e.g. product123pPromotionId
- the promotion id that qualifies the giftRestException
- if an exception occurs building the resource URIsprotected RepresentationModel.Builder listGiftProducts(java.lang.String pGiftWithPurchaseType, java.lang.String pGiftWithPurchaseDetail, java.lang.String pPromotionId) throws CommerceException
pGiftWithPurchaseType
- the gift type, e.g. productpGiftWithPurchaseDetail
- the gift detail, e.g. product123pPromotionId
- the promotion id that qualifies the giftCommerceException