atg.commerce.catalog
Class CatalogTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.catalog.CatalogTools
All Implemented Interfaces:
MessageTyper, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
CustomCatalogTools

public class CatalogTools
extends GenericService
implements MessageTyper

This class represents a series of helper methods and properties that are used in the management of accessing the product catalog.

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

 alternateRepositories=\
      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 useDefaultCatagory is false and an alternate repository cannot be found, that matches the pCatalogKey parameter then no repository is searched and null will be returned.


Field Summary
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
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CatalogTools()
          Constructs an instanceof CatalogTools
 
Method Summary
 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
 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 getParentCategoryPropertyName()
          Return the parentCategoryPropertyName property.
 java.util.Map getProductBeanInfos()
          Returns property ProductBeanInfos
 java.lang.String[] getProductItemTypes()
          Returns property ProductItemTypes
 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
 boolean isCategory(java.lang.Object pObj)
          Determines if the object provided is a category repository item
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 isProduct(java.lang.Object pObj)
          Determines if the object provided is a product repository item
 boolean isUseDefaultCatalog()
          Returns property useDefaultCatalog
 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 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 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.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


DEFAULT_PRODUCT_ITEM_TYPE

public static final java.lang.String DEFAULT_PRODUCT_ITEM_TYPE
The name of the item descriptor which represents the base definition of all products

See Also:
Constant Field Values

DEFAULT_CATEGORY_ITEM_TYPE

public static final java.lang.String DEFAULT_CATEGORY_ITEM_TYPE
The name of the item descriptor which represents the base definition of all categories

See Also:
Constant Field Values

DEFAULT_SKU_ITEM_TYPE

public static final java.lang.String DEFAULT_SKU_ITEM_TYPE
The name of the item descriptor which represents the base definition of all SKUs

See Also:
Constant Field Values
Constructor Detail

CatalogTools

public CatalogTools()
Constructs an instanceof CatalogTools

Method Detail

getTypeInfo

public CatalogTypeInfo getTypeInfo()
Return a serializable instance of CatalogTypeInfo that summarizes metadata usable in a client context


setCatalogServiceLockName

public void setCatalogServiceLockName(java.lang.String pCatalogServiceLockName)

getCatalogServiceLockName

public java.lang.String getCatalogServiceLockName()
Returns property CatalogServiceLockName


setCatalogServiceLockTimeOut

public void setCatalogServiceLockTimeOut(long pCatalogServiceLockTimeOut)
Set the maximum time we wait for a lock, in milliseconds.


getCatalogServiceLockTimeOut

public long getCatalogServiceLockTimeOut()
Get the maximum time we wait for a lock, in milliseconds. The default value is zero, meaning wait forever for the lock if necessary.


setBaseProductItemType

public void setBaseProductItemType(java.lang.String pBaseProductItemType)
Sets property BaseProductItemType


getBaseProductItemType

public java.lang.String getBaseProductItemType()
Returns property BaseProductItemType


setParentCategoryPropertyName

public void setParentCategoryPropertyName(java.lang.String pParentCategoryPropertyName)
Set the parentCategoryPropertyName property. This indicates the property of the repository item that hold parentCategory information. Used by the getAncestors method.


getParentCategoryPropertyName

public java.lang.String getParentCategoryPropertyName()
Return the parentCategoryPropertyName property.


setProductItemTypes

public void setProductItemTypes(java.lang.String[] pProductItemTypes)
Set property ProductItemTypes


getProductItemTypes

public java.lang.String[] getProductItemTypes()
Returns property ProductItemTypes


getProductBeanInfos

public java.util.Map getProductBeanInfos()
Returns property ProductBeanInfos


setBaseCategoryItemType

public void setBaseCategoryItemType(java.lang.String pBaseCategoryItemType)
Sets property BaseCategoryItemType


getBaseCategoryItemType

public java.lang.String getBaseCategoryItemType()
Returns property BaseCategoryItemType


setCategoryItemTypes

public void setCategoryItemTypes(java.lang.String[] pCategoryItemTypes)
Sets property CategoryItemTypes


getCategoryItemTypes

public java.lang.String[] getCategoryItemTypes()
Returns property CategoryItemTypes


getCategoryBeanInfos

public java.util.Map getCategoryBeanInfos()
Returns property CategoryBeanInfos


setBaseSKUItemType

public void setBaseSKUItemType(java.lang.String pBaseSKUItemType)
Sets property BaseSKUItemType


getBaseSKUItemType

public java.lang.String getBaseSKUItemType()
Returns property BaseSKUItemType


setSKUItemTypes

public void setSKUItemTypes(java.lang.String[] pSKUItemTypes)
Sets property SKUItemTypes


getSKUItemTypes

public java.lang.String[] getSKUItemTypes()
Returns property SKUItemTypes


getSKUBeanInfos

public java.util.Map getSKUBeanInfos()
Returns property SKUBeanInfos


setCatalog

public void setCatalog(Repository pCatalog)
Sets property Catalog


getCatalog

public Repository getCatalog()
Returns property Catalog


setAlternateCatalogs

public void setAlternateCatalogs(ServiceMap pAlternateCatalogs)
Sets property AlternateCatalogs


getAlternateCatalogs

public ServiceMap getAlternateCatalogs()
Returns property AlternateCatalogs


setUseDefaultCatalog

public void setUseDefaultCatalog(boolean pUseDefaultCatalog)
Sets property useDefaultCatalog. Set it to true if you want the default catalog to be used in case the requested catalog is unavailable. If set to false, then requesting an unavilable alternate catalog will result in an error.


isUseDefaultCatalog

public boolean isUseDefaultCatalog()
Returns property useDefaultCatalog


setBaseMediaItemType

public void setBaseMediaItemType(java.lang.String pBaseMediaItemType)

getBaseMediaItemType

public java.lang.String getBaseMediaItemType()
Returns property baseMediaItemType


doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

isProduct

public boolean isProduct(java.lang.Object pObj)
                  throws RepositoryException
Determines if the object provided is a product repository item

Returns:
true if object is a product repository item
Throws:
RepositoryException

isCategory

public boolean isCategory(java.lang.Object pObj)
                   throws RepositoryException
Determines if the object provided is a category repository item

Returns:
true if object is a category repository item
Throws:
RepositoryException

isItemType

protected boolean isItemType(java.lang.Object pObj,
                             java.lang.String pItemType)
                      throws RepositoryException
Determines if the given object is an instance of the given catalog repository item-descriptor.

Parameters:
pObj - The object to test.
pItemType - The name of the item descriptor to test against.
Returns:
True of the given item is an instance of the given item type or false if is not an instance or the given item-descriptor does not exist in the catalog repository.
Throws:
RepositoryException - If an error occurs getting the item-descriptor associated with the given item type.

findCatalog

public Repository findCatalog(java.lang.String pCatalogKey)
Finds the catalog in the alternateCatalogs that is identified by catalogKey.


getAncestors

public 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. Then it returns a LinkedList of category repository items. It obtains the name of the parentCategory property name from the parentCategoryPropertyName property. If you implementation of the catalog uses another name for the parentCategory property the parentCategoryPropertyName property should be changed.

Parameters:
pItem - The product or category item to get the ancestry from.
Returns:
A LinkedList of category repository items.
Throws:
PropertyNotFoundException - If the given item does not have a parentCategoryPropertyName property.

findCategory

public RepositoryItem findCategory(java.lang.String pId,
                                   java.lang.String pCatalogKey)
                            throws RepositoryException
With the given id return an object which represents the category

Throws:
RepositoryException - if there was an error attempting to find the item

findCategory

public RepositoryItem findCategory(java.lang.String pId)
                            throws RepositoryException
With the given id return an object which represents the category

Throws:
RepositoryException - if there was an error attempting to find the item

findCategories

public RepositoryItem[] findCategories(java.lang.String[] pIds,
                                       java.lang.String pCatalogKey)
                                throws RepositoryException
With the given id return an object which represents the category

Throws:
RepositoryException - if there was an error attempting to find the item

findCategories

public RepositoryItem[] findCategories(java.lang.String[] pIds)
                                throws RepositoryException
With the given id return an object which represents the category

Throws:
RepositoryException - if there was an error attempting to find the item

findProduct

public RepositoryItem findProduct(java.lang.String pId,
                                  java.lang.String pCatalogKey)
                           throws RepositoryException
With the given id return an object which represents the product

Throws:
RepositoryException - if there was an error attempting to find the item

findProduct

public RepositoryItem findProduct(java.lang.String pId)
                           throws RepositoryException
With the given id return an object which represents the product

Throws:
RepositoryException - if there was an error attempting to find the item

findProducts

public RepositoryItem[] findProducts(java.lang.String[] pIds,
                                     java.lang.String pCatalogKey)
                              throws RepositoryException
With the given id return an object which represents the product

Throws:
RepositoryException - if there was an error attempting to find the item

findProducts

public RepositoryItem[] findProducts(java.lang.String[] pIds)
                              throws RepositoryException
With the given id return an object which represents the product

Throws:
RepositoryException - if there was an error attempting to find the item

findSKU

public RepositoryItem findSKU(java.lang.String pId,
                              java.lang.String pCatalogKey)
                       throws RepositoryException
With the given id return an object which represents the sku

Throws:
RepositoryException - if there was an error attempting to find the item

findSKU

public RepositoryItem findSKU(java.lang.String pId)
                       throws RepositoryException
With the given id return an object which represents the sku

Throws:
RepositoryException - if there was an error attempting to find the item

findSKUs

public RepositoryItem[] findSKUs(java.lang.String[] pIds,
                                 java.lang.String pCatalogKey)
                          throws RepositoryException
With the given ids return an array of objects which represent the skus

Throws:
RepositoryException - if there was an error attempting to find the items

findSKUs

public RepositoryItem[] findSKUs(java.lang.String[] pIds)
                          throws RepositoryException
With the given ids return an array of objects which represent the skus

Throws:
RepositoryException - if there was an error attempting to find the items

getBeanInfo

public DynamicBeanInfo getBeanInfo(java.lang.String pJMSType,
                                   java.lang.Class pMessageClass)
Returns the DynamicBeanInfo associated with a JMS message type and optional message object class. If a class is provided, the MessageTyper can expect that it is the class to which an object message of this type will belong, and can introspect it to determine the non-dynamic portion of the message metadata.

Specified by:
getBeanInfo in interface MessageTyper
Parameters:
pJMSType - the JMS message type, which is required
pMessageClass - an optional class which will be used at runtime for an object message.