public class CatalogTools extends GenericService implements MessageTyper
One can configure this component to define a mapping from a key to a set of alternate
catalogs. This is particularly useful for internationalization.
For example: CatalogTools.properties
$class=atg.commerce.catalog.CatalogTools catalog=ProductCatalog baseProductItemType=product baseCategoryItemType=category baseSKUItemType=sku baseMediaItemType=media productItemTypes=product categoryItemTypes=category SKUItemTypes=sku alternateCatalogs=\ en_US=/atg/commerce/catalog/ProductCatalog fr_FR=/atg/commerce/catalog/FrenchProductCatalog ja_JP=/atg/commerce/catalog/JapaneseProductCatalog de_DE=/atg/commerce/catalog/GermanProductCatalog useDefaultCatalog=true
The behavior of the findProduct(), findCategory(), and findSku() methods can be
modified with use of the useDefaultCatalog
property. If
useDefaultCatalog
is false and an alternate catalog repository cannot be found
that matches the pCatalogKey parameter, then no repository is searched and null will
be returned.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
DEFAULT_CATEGORY_ITEM_TYPE
The name of the item descriptor which represents the base definition of all categories
|
static java.lang.String |
DEFAULT_PRODUCT_ITEM_TYPE
The name of the item descriptor which represents the base definition of all products
|
static java.lang.String |
DEFAULT_SKU_ITEM_TYPE
The name of the item descriptor which represents the base definition of all SKUs
|
CatalogProperties |
mCatalogProperties |
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 |
---|
CatalogTools()
Constructs an instanceof CatalogTools
|
Modifier and Type | Method and Description |
---|---|
void |
doStartService()
This is called after a Service has been created, placed into the
naming hierarchy, and initialized with its configured property
values.
|
Repository |
findCatalog(java.lang.String pCatalogKey)
Finds the catalog in the alternateCatalogs that is identified by catalogKey.
|
RepositoryItem[] |
findCategories(java.lang.String[] pIds)
With the given id return an object which represents the category
|
RepositoryItem[] |
findCategories(java.lang.String[] pIds,
java.lang.String pCatalogKey)
With the given id return an object which represents the category
|
RepositoryItem |
findCategory(java.lang.String pId)
With the given id return an object which represents the category
|
RepositoryItem |
findCategory(java.lang.String pId,
java.lang.String pCatalogKey)
With the given id return an object which represents the category
|
RepositoryItem |
findProduct(java.lang.String pId)
With the given id return an object which represents the product
|
RepositoryItem |
findProduct(java.lang.String pId,
java.lang.String pCatalogKey)
With the given id return an object which represents the product
|
RepositoryItem[] |
findProducts(java.lang.String[] pIds)
With the given id return an object which represents the product
|
RepositoryItem[] |
findProducts(java.lang.String[] pIds,
java.lang.String pCatalogKey)
With the given id return an object which represents the product
|
RepositoryItem |
findSKU(java.lang.String pId)
With the given id return an object which represents the sku
|
RepositoryItem |
findSKU(java.lang.String pId,
java.lang.String pCatalogKey)
With the given id return an object which represents the sku
|
RepositoryItem[] |
findSKUs(java.lang.String[] pIds)
With the given ids return an array of objects which represent the skus
|
RepositoryItem[] |
findSKUs(java.lang.String[] pIds,
java.lang.String pCatalogKey)
With the given ids return an array of objects which represent the skus
|
ServiceMap |
getAlternateCatalogs()
Returns property AlternateCatalogs
|
java.util.LinkedList |
getAncestors(RepositoryItem pItem)
This method gets the parentCategory property of the repository item passed in, and gets the parentCategory's
parentCategory and so forth until there is no more parent.
|
java.lang.String |
getBaseCategoryItemType()
Returns property BaseCategoryItemType
|
java.lang.String |
getBaseMediaItemType()
Returns property baseMediaItemType
|
java.lang.String |
getBaseProductItemType()
Returns property BaseProductItemType
|
java.lang.String |
getBaseSKUItemType()
Returns property BaseSKUItemType
|
DynamicBeanInfo |
getBeanInfo(java.lang.String pJMSType,
java.lang.Class pMessageClass)
Returns the DynamicBeanInfo associated with a JMS message type
and optional message object class.
|
Repository |
getCatalog()
Returns property Catalog
|
CatalogProperties |
getCatalogProperties()
A class that stores the names of various items and properties in
the repository
|
java.lang.String |
getCatalogServiceLockName()
Returns property CatalogServiceLockName
|
long |
getCatalogServiceLockTimeOut()
Get the maximum time we wait for a lock, in milliseconds.
|
java.util.Map |
getCategoryBeanInfos()
Returns property CategoryBeanInfos
|
java.lang.String[] |
getCategoryItemTypes()
Returns property CategoryItemTypes
|
java.lang.String |
getOnlineOnlyPropertyName() |
java.lang.String |
getParentCategoryPropertyName()
Return the parentCategoryPropertyName property.
|
java.util.Map |
getProductBeanInfos()
Returns property ProductBeanInfos
|
java.lang.String[] |
getProductItemTypes()
Returns property ProductItemTypes
|
java.util.Collection |
getProductSkus(RepositoryItem pProduct)
Get a collection of SKU items from the specified product.
|
java.util.Map |
getSKUBeanInfos()
Returns property SKUBeanInfos
|
java.lang.String[] |
getSKUItemTypes()
Returns property SKUItemTypes
|
CatalogTypeInfo |
getTypeInfo()
Return a serializable instance of CatalogTypeInfo that summarizes
metadata usable in a client context
|
java.lang.String |
getUnitOfMeasure(java.lang.String pProductId,
java.lang.String pSkuId)
Returns the unit of measure.
|
boolean |
isCategory(java.lang.Object pObj)
Determines if the object provided is a category repository item
|
boolean |
isFractionalQuantityAllowed(java.lang.String pProductId,
java.lang.String pSkuId)
Validates if the SKU/Product is marked with fractional quantities allowed.
|
protected boolean |
isItemType(java.lang.Object pObj,
java.lang.String pItemType)
Determines if the given object is an instance of the given catalog repository item-descriptor.
|
boolean |
isOnlineOnly(java.util.Collection<RepositoryItem> pItems)
Determines whether are not the provided items are only available online
|
boolean |
isOnlineOnly(RepositoryItem pProduct,
RepositoryItem pSku)
Determines whether or not the provided sku/product combo is only available online
|
boolean |
isProduct(java.lang.Object pObj)
Determines if the object provided is a product repository item
|
boolean |
isSku(java.lang.Object pObj)
Determines if the object provided is a SKU repository item
|
boolean |
isUseDefaultCatalog()
Returns property useDefaultCatalog
|
boolean |
productContainsSku(RepositoryItem pProduct,
java.lang.String pSkuId)
Verify that a specified sku ID is an ID of a child sku of the
specified product.
|
boolean |
productContainsSku(java.lang.String pCatalogId,
java.lang.String pProductId,
RepositoryItem pProduct,
java.lang.String pSkuId,
java.lang.Object pSku)
Verify that a specified sku is actually a child sku of the specified product.
|
void |
setAlternateCatalogs(ServiceMap pAlternateCatalogs)
Sets property AlternateCatalogs
|
void |
setBaseCategoryItemType(java.lang.String pBaseCategoryItemType)
Sets property BaseCategoryItemType
|
void |
setBaseMediaItemType(java.lang.String pBaseMediaItemType) |
void |
setBaseProductItemType(java.lang.String pBaseProductItemType)
Sets property BaseProductItemType
|
void |
setBaseSKUItemType(java.lang.String pBaseSKUItemType)
Sets property BaseSKUItemType
|
void |
setCatalog(Repository pCatalog)
Sets property Catalog
|
void |
setCatalogProperties(CatalogProperties pCatalogProperties) |
void |
setCatalogServiceLockName(java.lang.String pCatalogServiceLockName) |
void |
setCatalogServiceLockTimeOut(long pCatalogServiceLockTimeOut)
Set the maximum time we wait for a lock, in milliseconds.
|
void |
setCategoryItemTypes(java.lang.String[] pCategoryItemTypes)
Sets property CategoryItemTypes
|
void |
setOnlineOnlyPropertyName(java.lang.String pOnlineOnlyPropertyName) |
void |
setParentCategoryPropertyName(java.lang.String pParentCategoryPropertyName)
Set the parentCategoryPropertyName property.
|
void |
setProductItemTypes(java.lang.String[] pProductItemTypes)
Set property ProductItemTypes
|
void |
setSKUItemTypes(java.lang.String[] pSKUItemTypes)
Sets property SKUItemTypes
|
void |
setUseDefaultCatalog(boolean pUseDefaultCatalog)
Sets property useDefaultCatalog.
|
addLogListener, createAdminServlet, 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 java.lang.String CLASS_VERSION
public static final java.lang.String DEFAULT_PRODUCT_ITEM_TYPE
public static final java.lang.String DEFAULT_CATEGORY_ITEM_TYPE
public static final java.lang.String DEFAULT_SKU_ITEM_TYPE
public CatalogProperties mCatalogProperties
public CatalogTypeInfo getTypeInfo()
public void setCatalogServiceLockName(java.lang.String pCatalogServiceLockName)
public java.lang.String getCatalogServiceLockName()
public void setCatalogServiceLockTimeOut(long pCatalogServiceLockTimeOut)
public long getCatalogServiceLockTimeOut()
public void setBaseProductItemType(java.lang.String pBaseProductItemType)
public java.lang.String getBaseProductItemType()
public void setParentCategoryPropertyName(java.lang.String pParentCategoryPropertyName)
public java.lang.String getParentCategoryPropertyName()
public java.lang.String getOnlineOnlyPropertyName()
public void setOnlineOnlyPropertyName(java.lang.String pOnlineOnlyPropertyName)
pOnlineOnlyPropertyName
- the onlineOnlyPropertyName to setpublic void setProductItemTypes(java.lang.String[] pProductItemTypes)
public java.lang.String[] getProductItemTypes()
public java.util.Map getProductBeanInfos()
public void setBaseCategoryItemType(java.lang.String pBaseCategoryItemType)
public java.lang.String getBaseCategoryItemType()
public void setCategoryItemTypes(java.lang.String[] pCategoryItemTypes)
public java.lang.String[] getCategoryItemTypes()
public java.util.Map getCategoryBeanInfos()
public void setBaseSKUItemType(java.lang.String pBaseSKUItemType)
public java.lang.String getBaseSKUItemType()
public void setSKUItemTypes(java.lang.String[] pSKUItemTypes)
public java.lang.String[] getSKUItemTypes()
public java.util.Map getSKUBeanInfos()
public void setCatalog(Repository pCatalog)
public Repository getCatalog()
public void setAlternateCatalogs(ServiceMap pAlternateCatalogs)
public ServiceMap getAlternateCatalogs()
public void setUseDefaultCatalog(boolean pUseDefaultCatalog)
public boolean isUseDefaultCatalog()
public void setBaseMediaItemType(java.lang.String pBaseMediaItemType)
public java.lang.String getBaseMediaItemType()
public void setCatalogProperties(CatalogProperties pCatalogProperties)
public CatalogProperties getCatalogProperties()
public void doStartService() throws ServiceException
GenericService
doStartService
in class GenericService
ServiceException
- if the Service had a problem starting uppublic boolean isSku(java.lang.Object pObj) throws RepositoryException
RepositoryException
public boolean isProduct(java.lang.Object pObj) throws RepositoryException
RepositoryException
public boolean isCategory(java.lang.Object pObj) throws RepositoryException
RepositoryException
protected boolean isItemType(java.lang.Object pObj, java.lang.String pItemType) throws RepositoryException
pObj
- The object to test.pItemType
- The name of the item descriptor to test against.RepositoryException
- If an error occurs getting the item-descriptor associated with the given item type.public boolean isOnlineOnly(RepositoryItem pProduct, RepositoryItem pSku) throws RepositoryException
pProduct
- The productpSku
- The skuRepositoryException
public boolean isOnlineOnly(java.util.Collection<RepositoryItem> pItems) throws RepositoryException
pItems
- The itemsRepositoryException
public Repository findCatalog(java.lang.String pCatalogKey)
public java.util.LinkedList getAncestors(RepositoryItem pItem)
pItem
- The product or category item to get the ancestry from.PropertyNotFoundException
- If the given item does not have a parentCategoryPropertyName property.public RepositoryItem findCategory(java.lang.String pId, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem findCategory(java.lang.String pId) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem[] findCategories(java.lang.String[] pIds, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem[] findCategories(java.lang.String[] pIds) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem findProduct(java.lang.String pId, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem findProduct(java.lang.String pId) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem[] findProducts(java.lang.String[] pIds, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem[] findProducts(java.lang.String[] pIds) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem findSKU(java.lang.String pId, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem findSKU(java.lang.String pId) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itempublic RepositoryItem[] findSKUs(java.lang.String[] pIds, java.lang.String pCatalogKey) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itemspublic RepositoryItem[] findSKUs(java.lang.String[] pIds) throws RepositoryException
RepositoryException
- if there was an error attempting to find the itemspublic DynamicBeanInfo getBeanInfo(java.lang.String pJMSType, java.lang.Class pMessageClass)
getBeanInfo
in interface MessageTyper
pJMSType
- the JMS message type, which is requiredpMessageClass
- an optional class which will be used at
runtime for an object message.public boolean isFractionalQuantityAllowed(java.lang.String pProductId, java.lang.String pSkuId) throws RepositoryException
A product being marked with fractional quantities allowed will override any SKU setting. If a product is marked as a fractional quantities allowed all SKUs associated with this product will become fractional quantities allowed even if the individual SKUs have been marked as non-fractional.
A fractional quantity SKU in a non-fractional product is a fractional quantity. If a SKU has been marked as a fractional quantity allowed this SKU will be treated as a fractional quantity and can ignore the product flag.
pProductId
- the product Id. This is mandatorypSkuId
- the sku IdRepositoryException
- if there was an error during repository lookuppublic java.lang.String getUnitOfMeasure(java.lang.String pProductId, java.lang.String pSkuId) throws RepositoryException
If a SKU is associated with a unit of measure value, the SKU uses its own unit of measure value and configuration otherwise it uses that of the product.
pProductId
- the product IdpSkuId
- the sku IdRepositoryException
- if there was an error during repository lookuppublic java.util.Collection getProductSkus(RepositoryItem pProduct) throws CommerceException
pProduct
- the productCommerceException
public boolean productContainsSku(RepositoryItem pProduct, java.lang.String pSkuId) throws CommerceException
pProduct
- The productpSkuId
- The sku id to testCommerceException
- if unable to find or recognize the type
of the product's child SKU propertypublic boolean productContainsSku(java.lang.String pCatalogId, java.lang.String pProductId, RepositoryItem pProduct, java.lang.String pSkuId, java.lang.Object pSku)
pCatalogId
- The catalog id of the particular catalog from which a commerce item
is being created. May be null if custom catalogs are not in use.pProductId
- The product id of the product being examined. May be null if no
product id was supplied in the call to createCommerceItem
.pProduct
- The product object corresponding to pProductId
, which
may be null if pProductId
is null.pSkuId
- The sku id of the sku being examined. This value should never be null.pSku
- The sku object corresponding to pSkuId