@RestResource(id="atg.commerce.catalog.restresources.SkuRestResource") public class SkuRestResource extends AbstractCatalogRestResource
This class provides endpoints for the sku resource. It will be called directly or may be embedded when a resource has a sku relationship, for example ProductRestResource's childSkus collection
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
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 |
---|
SkuRestResource() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getParentProductsRelationshipName()
Return the relationship name to the embedded product resource for parentProducts
|
protected RepresentationModel.Builder |
getRepresentationModelBuilder(java.lang.Object pState)
Gets the RepresentationModel.Builder with the given object acting as the state.
|
RepresentationModel |
getSku(java.lang.String pSkuId,
java.lang.Boolean pFilterByCatalogFlag,
java.lang.Boolean pFilterBySiteFlag,
java.lang.String pSiteId)
Get the sku matching the id passed, applying any filters set.
|
RepresentationModel |
listSkus(java.lang.String pParentItemId,
java.lang.String pParentItemType,
java.lang.String pParentPropertyName,
java.lang.String pSkuIds,
java.lang.String pOffset,
java.lang.String pLimit)
Gets a list of skus.
|
void |
setParentProductsRelationshipName(java.lang.String pParentProductsRelationshipName)
Configure the parentProducts relationship name to the product resource (collection).
|
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 void setParentProductsRelationshipName(java.lang.String pParentProductsRelationshipName)
pParentProductsRelationshipName
- the relationship name of the embedded product resourcepublic java.lang.String getParentProductsRelationshipName()
@Endpoint(id="/skus#GET", filterId="skus-Default") public RepresentationModel listSkus(java.lang.String pParentItemId, java.lang.String pParentItemType, java.lang.String pParentPropertyName, java.lang.String pSkuIds, java.lang.String pOffset, java.lang.String pLimit) throws RestException, RepositoryException, javax.servlet.ServletException
Retrieve the child sku 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.
Alternative a list of sku ids that make up the collection may be passed. This setting takes precedence over the parent collection settings. Note the length of this comma separated param can not exceed the maximum request length, therefor this param will not be suitable for very large collections.
This collection resource can be embedded in other resources, for example the product's childSkus. 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
pParentItemId
- the id of the item that contains the sku collection.pParentItemType
- the repository type of the item that contains the sku collection,
this will support a qualifying repository e.g. /atg/commerce/ProductCatalog:product.pParentPropertyName
- the property name containing the sku collection, this supports dot
notation for the collection to be displayed e.g. product.ancestorCategories.pSkuIds
- the comma separated list of sku ids that are members of this collection, takes precedence.pOffset
- the page start indexpLimit
- the page sizeRestException
- the rest exceptionRepositoryException
- a repository exception indicating a server errorjavax.servlet.ServletException
- a servlet exception indicating a server error@Endpoint(id="/skus/{skuId}#GET", isSingular=true, filterId="skus.id-Default") public RepresentationModel getSku(java.lang.String pSkuId, java.lang.Boolean pFilterByCatalogFlag, java.lang.Boolean pFilterBySiteFlag, java.lang.String pSiteId) throws RestException, RepositoryException
If this is a top-level resource sku retrieval we will filter the sku by the filterBySite, filterByCatalog & siteId query params but only if the underlying SKULookup droplet has its useParams set to true. If this is set to false then the query params are ignored and the corresponding SKULookup 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 sku 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 SKULookup config - useParams, filterBySite & filterByCatalog.
OOTB the sku representation includes the embedded relationship to the parentProducts @see ProductRestResource. The REST-Jersey framework 'expand' & 'maxDepth' params can be used to control the embedded items that get expanded.
pSkuId
- the id of the sku to findpFilterByCatalogFlag
- if true only find the sku if the sku's catalog matches the user's catalogpFilterBySiteFlag
- if true only find the sku if it matches the siteId or current site contextpSiteId
- site id sku should belong to. If not set current site will be used.RestException
- the rest exceptionRepositoryException
- if sku repository lookup failsprotected RepresentationModel.Builder getRepresentationModelBuilder(java.lang.Object pState)
Also embeds the product.
getRepresentationModelBuilder
in class AbstractItemLookupRestResource
pState
- the state that will be added to the representation model