atg.commerce.catalog.custom
Class CatalogItemLookupDroplet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.repository.servlet.ItemLookupDroplet
                              extended by atg.commerce.catalog.custom.CatalogItemLookupDroplet
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class CatalogItemLookupDroplet
extends ItemLookupDroplet

This servlet looks for a RepositoryItem by its id from within a Repository. If the item is found, then it will check whether the item belongs to the user's catalog in his current Profile. If it is, output is rendered. If the item is not found, empty is rendered. If it does not belong to the user's catalog, wrongCatalog is rendered. The repository and item descriptor type can be configured through properties. If the useParams property is true, then the repository and item descriptor can be resolved through input parameters. It checks this by looking at the items "catalogs" property. If the item has no "catalogs" property then this class behaves the same as the superclass.

One can configure this droplet to define a mapping from a key to an alternate set of repositories.
For example: ProductLookup.properties

 $class=atg.commerce.catalog.custom.CatalogItemLookupDroplet
 
 repository=/atg/commerce/catalog/ProductCatalog
 itemDescriptor=product
 
 alternateRepositories=\
      fr_FR=/atg/commerce/catalog/FrenchProductCatalog
      ja_JP=/atg/commerce/catalog/JapaneseProductCatalog
      de_DE=/atg/commerce/catalog/GermanProductCatalog
 
The invocation of the droplet can then be invoked with the following parameters:
 <DROPLET bean="ProductLookup">
 <PARAM NAME="id" VALUE="param:productId">
 <PARAM NAME="repositoryKey" value="bean:/OriginatingRequest.requestLocale.localeString">
 <PARAM name="elementName" value="product">
 <OPARAM NAME="output">
   <a href="param:product.template.url">
     <param name="prod_id" value="param:product.repositoryId">
     <valueof param="product.displayName"></valueof>
   </a>
 </OPARAM>
 </DROPLET>
 
If the mapping for the provided key is found that repository will be used, otherwise the system will fall back to the default repository and search for the item.

If the item cannot be found in the repository searched (e.g. the french product catalog), then the droplet will once again fall back to the default repository and attempt to find the item using the same id. Obviously this is only useful if the items have the exact same id in each repository.

In this example if you are french and attempt to look at product 1234, and product 1234 is defined in the french product catalog you will see that item. However if 1234 is not defined then you will see the default english version of 1234.

This behavior can be modified with use of the useDefaultRepository and getDefaultItem properties. If useDefaultRepository is false and an alternate repository cannot be found, then no repository is searched and empty is serviced. Like wise, if an alternative repository is selected, but the item cannot be found, and if getDefaultItem is false, then the default repository will not be searched and empty will be serviced.

The required input paramters for this servlet are:

id
The id of the item to lookup
The following parameters are optional:
repositoryKey
If specified this parameter will be used as a key to map to a secondary set of repositories.
elementName
This parameter can be used to change the default name of the element which is bound into the scope of the output oparam.
repository
The repository within which to look for the item. It is recommended to not use this parameter and to define different instances of the CatalogItemLookupDroplet for each set of repositories you wish to use.
itemDescriptor
The name of the Item Descriptor to use to load the item. It is recommended to not use this parameter and to setup the item descriptor through property configuration.
catalog
The catalog to look for the item in. This is normally not needed since the catalog that is in the current users profile will be used. If however, you want to search in a catalog other than the current catalog, or there is no current session (for example within the context of an email template) then you may want to explicitly provide the catalog. This must be a repository item.

The output parameters for this servlet are:

output
Rendered if the item was found in the repository
element
Set to the RepositoryItem corresponding to the id supplied
wrongCatalog
This gets rendered if the item being looked up is not accessible through the current users catalog. The item is still accessible if you need it.
error
Any exception that may have occured while looking up the item
empty
Rendered in all other cases, e.g. item not found, user did not specify a required parameter.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
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
CatalogItemLookupDroplet()
           
 
Method Summary
 RepositoryItem getProfile()
          Returns property Profile
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Look for the RepositoryItem and if found render the output oparam by binding the item as a parameter.
 
Methods inherited from class atg.repository.servlet.ItemLookupDroplet
commitTransaction, ensureTransaction, getAlternateRepositories, getItemDescriptor, getRepository, getTransactionManager, isEnsureTransaction, isGetDefaultItem, isUseDefaultRepository, isUseParams, setAlternateRepositories, setEnsureTransaction, setGetDefaultItem, setItemDescriptor, setRepository, setTransactionManager, setUseDefaultRepository, setUseParams
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, 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, 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

Constructor Detail

CatalogItemLookupDroplet

public CatalogItemLookupDroplet()
Method Detail

getProfile

public RepositoryItem getProfile()
Returns property Profile


service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
Look for the RepositoryItem and if found render the output oparam by binding the item as a parameter. If no item can be found render the empty oparam. If the RepositoryItem is found, but not belongs to the user's catalog, still render the empty oparam.

Overrides:
service in class ItemLookupDroplet
Parameters:
pRequest - the request to be processed
pResponse - the response object for this request
Throws:
javax.servlet.ServletException - an application specific error occurred processing this request
java.io.IOException - an error occurred reading data from the request or writing data to the response.