|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.nucleus.TimedOperationService atg.nucleus.servlet.ServletService atg.nucleus.servlet.HttpServletService atg.servlet.DynamoServlet atg.repository.servlet.ItemLookupDroplet atg.commerce.catalog.custom.CatalogItemLookupDroplet
public class CatalogItemLookupDroplet
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 and if the
item belongs to the current site. If it does, output
is
rendered. If the item is not found, empty
is rendered. If
it is not found on the current site then wrongSite
is rendered.
If it does not belong to the user's catalog, wrongCatalog
is
rendered.
It checks this by looking at the item's "catalogs"
property and "sites" property. If the item has no "catalogs" and no "sites"
property then this class behaves the same as the superclass.
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.
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/GermanProductCatalogThe 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:
The output parameters for this servlet are:
catalog
input parameter was not specified.
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 | |
---|---|
protected RepositoryItem |
findItem(java.lang.String pId,
java.lang.String pItemDescriptorName,
Repository pRepository)
Attempts to find an item in the given repository based on Id and Item descriptor. |
protected java.util.Collection<RepositoryItem> |
getCatalogs(DynamoHttpServletRequest pRequest)
Returns catalogs from request parameters. |
RepositoryItem |
getProfile()
Returns property Profile |
protected Repository |
getRepository(DynamoHttpServletRequest pRequest)
Returns repository. |
protected Repository |
getRepositoryForCatalogItemLookup(java.lang.String pRepositoryKey)
Gets the specified alternate repository if available, otherwise returns the defaults repository. |
protected java.util.Collection<atg.multisite.Site> |
getSites(DynamoHttpServletRequest pRequest)
If we have collection of sites in request parameter, then returns them, otherwise returns null . |
java.lang.String |
getSitesPropertyName()
Returns property SitesPropertyName |
boolean |
isFilterByCatalog()
Returns property FilterByCatalog |
protected boolean |
isFilterByCatalog(DynamoHttpServletRequest pRequest)
Returns true if item should filter by catalog. |
boolean |
isFilterBySite()
Returns property FilterBySite |
protected boolean |
isFilterBySite(DynamoHttpServletRequest pRequest)
Determines if we are filtering by sites. |
protected boolean |
isItemInCatalogs(RepositoryItem pItem,
java.util.Collection<RepositoryItem> pCatalogs)
Determines if a given item is part of any catalog in the given collection. |
protected boolean |
isItemInSites(RepositoryItem pItem,
java.util.Collection<atg.multisite.Site> pSites)
Determines if a given item is a part of any sites from the given set or the current site. |
void |
service(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
Look for the RepositoryItem and if found render the output oparam by binding the item as a parameter. |
void |
setFilterByCatalog(boolean pFilterByCatalogs)
Sets property FilterByCatalog |
void |
setFilterBySite(boolean pFilterBySite)
Sets property FilterBySite |
void |
setSitesPropertyName(java.lang.String pSitesPropertyName)
Sets property SitesPropertyName |
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.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 |
---|
public static java.lang.String CLASS_VERSION
Constructor Detail |
---|
public CatalogItemLookupDroplet()
Method Detail |
---|
public RepositoryItem getProfile()
public void setFilterByCatalog(boolean pFilterByCatalogs)
public boolean isFilterByCatalog()
public void setFilterBySite(boolean pFilterBySite)
public boolean isFilterBySite()
public void setSitesPropertyName(java.lang.String pSitesPropertyName)
public java.lang.String getSitesPropertyName()
public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
service
in class ItemLookupDroplet
pRequest
- the request to be processedpResponse
- the response object for this request
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.protected RepositoryItem findItem(java.lang.String pId, java.lang.String pItemDescriptorName, Repository pRepository) throws RepositoryException
pId
- - Id of the item to findpItemDescriptorName
- ItemDescriptor for the itempRepository
- Repository to look for the item before using the default repository.
RepositoryException
protected Repository getRepositoryForCatalogItemLookup(java.lang.String pRepositoryKey)
pRepositoryKey
- Alternate repository to get
protected boolean isItemInCatalogs(RepositoryItem pItem, java.util.Collection<RepositoryItem> pCatalogs)
pItem
- Repository Item to check for membership in a catalogpCatalogs
- Catalogs to check membership for
protected boolean isItemInSites(RepositoryItem pItem, java.util.Collection<atg.multisite.Site> pSites)
true
.
pItem
- repository itempSites
- set of sites
protected boolean isFilterBySite(DynamoHttpServletRequest pRequest)
pRequest
- Dynamo http request
protected boolean isFilterByCatalog(DynamoHttpServletRequest pRequest)
pRequest
- Dynamo http request
protected Repository getRepository(DynamoHttpServletRequest pRequest)
useParams
is true,
retrieves repository from request parameters, otherwise
calls getRepositoryForCatalogItemLookup
method
pRequest
- Dynamo http request
protected java.util.Collection<RepositoryItem> getCatalogs(DynamoHttpServletRequest pRequest)
null
.
pRequest
- Dynamo http request
null
protected java.util.Collection<atg.multisite.Site> getSites(DynamoHttpServletRequest pRequest)
null
.
pRequest
- Dynamo http request
null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |