atg.repository.seo
Class ItemLink

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.seo.ItemLink
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class ItemLink
extends DynamoServlet

Droplet that generates a Url String for a repository item.

The Url is created from on a template.

The template is retrieved based on the item descriptor and the browser type of the request. The template is populate by request parameters or by looking up the item and getting it's properties. This droplet takes 5 optional input request parameters-

If the template references item properties then either:

itemThe repository item, or
idThe ID of the repository item.

If the default descriptor name in the properties isn't correct:

itemDescriptorName The item descriptor name to lookup the template. If this isn't supplied then the item descriptor will be taken from the repository item. If the repository item isn't supplied then the descriptor will default to a value in the properties.

If the item needs to be looked up by id then a repository must be used. This can be specified using the one of the input parameters below. Otherwise the default repository in the parser will be used.

If the item isn't found there either then the default repository for the droplet will be used.

repositoryThe repository to use, or
repositoryNameThe name of the repository to use.

It is possible to use this droplet without specifying any input parameters in which case the itemDescriptorName will be the default from the properties file and the Url template cannot reference any item properties.

However it is more likely that a template will be used that references item properties in which case the 'item' property must be supplied or else the 'id' and usually the 'itemDescriptorName' and optionally the 'repository' or 'repositoryName'. However the 'itemDescriptorName' and 'repositoryName' can both default to values in the properties.

There are 2 output parameters:

urlThe string URL generated by this droplet
errorMessageA string error message if a problem occurred generating the url

There are 3 open parameters:

outputServiced if the url is generated successfully.
emptyIf there is no template defined for the browser type.
errorServices if a problem occurred generating the url.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  java.util.Map mItemDescriptorToNameMap
          Map of item descriptor objects to their names.
static ParameterName S_EMPTY
           
static ParameterName S_ERROR
           
static java.lang.String S_ERROR_MESSAGE
           
static ParameterName S_ID
           
static ParameterName S_ITEM
           
static ParameterName S_ITEM_DESCRIPTOR_NAME
           
static ParameterName S_OUTPUT
           
static ParameterName S_REPOSITORY
           
static ParameterName S_REPOSITORY_NAME
           
static ParameterName S_SITE_ID
           
static java.lang.String S_URL
           
 
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
ItemLink()
           
 
Method Summary
 void doStartService()
          Initializes the maps.
protected  UrlTemplateMapper getBestFitTemplateMapper(DynamoHttpServletRequest pRequest, java.lang.String pItemDescriptorName, UrlParameterLookup pLookup)
          Method to get the best fit UrlTemplateMapper object for the given item descriptor name.
 java.lang.String getDefaultItemDescriptorName()
          Gets the default item descriptor name property
 Repository getDefaultRepository()
          Gets the default repository property
 WebApp getDefaultWebApp()
           
protected  java.lang.String getItemDescriptorName(DynamoHttpServletRequest pRequest, UrlParameterLookup pLookup)
          This method obtains the repository item descriptor name from the request.
 ServiceMap getItemDescriptorNameToMapperMap()
          Gets the map of item descriptor names to UrlTemplateMapper instances
protected  UrlParameterLookup getItemLookup(DynamoHttpServletRequest pRequest)
          This method creates a lookup item for the item or id from the request.
protected  java.lang.String getRepositoryName(DynamoHttpServletRequest pRequest, UrlParameterLookup pLookup)
          This method obtains the repository name from the request.
protected  UrlParameterLookup getSiteLookup(DynamoHttpServletRequest pRequest)
          This method creates a lookup item for the item or id from the request.
 SiteManager getSiteManager()
          Gets the SiteManager property
 java.lang.String getSpaceMapping()
          Getter for the space mapping property.
protected  UrlTemplate getTemplate(DynamoHttpServletRequest pRequest, UrlTemplateMapper pMapper)
          Gets the UrlTemplate to use to format the Url to return to the caller.
protected  UrlTemplateMapper getTemplateMapper(DynamoHttpServletRequest pRequest, java.lang.String pItemDescriptorName, UrlParameterLookup pLookup)
          Method to get the UrlTemplateMapper object for the given item descriptor name.
protected  void populateParams(DynamoHttpServletRequest pRequest, UrlParameter[] pParams, UrlParameterLookup pLookup)
          This method populates the value of the parameters needed to create the Url string.
protected  void populateParams(DynamoHttpServletRequest pRequest, UrlParameter[] pParams, UrlParameterLookup[] pLookups)
          This method populates the value of the parameters needed to create the Url string.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Generates a url string based on a template populated by item properties and/or request properties.
 void setDefaultItemDescriptorName(java.lang.String pDefaultItemDescriptorName)
          Sets the default item descriptor name property
 void setDefaultRepository(Repository pDefaultRepository)
          Sets the default repository property
 void setDefaultWebApp(WebApp pDefaultWebApp)
           
 void setItemDescriptorNameToMapperMap(ServiceMap pItemDescriptorNameToMapperMap)
          Sets the map of item descriptor names to UrlTemplateMapper instances
 void setSiteManager(SiteManager pSiteManager)
          Sets the SiteManager property
 void setSpaceMapping(java.lang.String pSpaceMapping)
          Setter for the space mapping property.
 
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, 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
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, 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


S_ITEM

public static final ParameterName S_ITEM

S_ITEM_DESCRIPTOR_NAME

public static final ParameterName S_ITEM_DESCRIPTOR_NAME

S_ID

public static final ParameterName S_ID

S_REPOSITORY

public static final ParameterName S_REPOSITORY

S_REPOSITORY_NAME

public static final ParameterName S_REPOSITORY_NAME

S_SITE_ID

public static final ParameterName S_SITE_ID

S_ERROR_MESSAGE

public static final java.lang.String S_ERROR_MESSAGE
See Also:
Constant Field Values

S_URL

public static final java.lang.String S_URL
See Also:
Constant Field Values

S_OUTPUT

public static final ParameterName S_OUTPUT

S_EMPTY

public static final ParameterName S_EMPTY

S_ERROR

public static final ParameterName S_ERROR

mItemDescriptorToNameMap

protected java.util.Map mItemDescriptorToNameMap
Map of item descriptor objects to their names.

Constructor Detail

ItemLink

public ItemLink()
Method Detail

getSpaceMapping

public java.lang.String getSpaceMapping()
Getter for the space mapping property.

Returns:
String mapping

setSpaceMapping

public void setSpaceMapping(java.lang.String pSpaceMapping)
Setter for the space mapping property. Sets the static space mapping in the UrlParameter class. Defaults to null which will use dash to map spaces.

Parameters:
pSpaceMapping - String mapping

setDefaultRepository

public void setDefaultRepository(Repository pDefaultRepository)
Sets the default repository property

Parameters:
pDefaultRepository - The default repository to set.

getDefaultRepository

public Repository getDefaultRepository()
Gets the default repository property

Returns:
The Repository instance that has been configured as the default repository.

setDefaultItemDescriptorName

public void setDefaultItemDescriptorName(java.lang.String pDefaultItemDescriptorName)
Sets the default item descriptor name property

Parameters:
pDefaultItemDescriptorName - The default item descriptor name to set

getDefaultItemDescriptorName

public java.lang.String getDefaultItemDescriptorName()
Gets the default item descriptor name property

Returns:
The default item descriptor name property

setItemDescriptorNameToMapperMap

public void setItemDescriptorNameToMapperMap(ServiceMap pItemDescriptorNameToMapperMap)
Sets the map of item descriptor names to UrlTemplateMapper instances

Parameters:
pItemDescriptorNameToMapperMap - The map to set.

getItemDescriptorNameToMapperMap

public ServiceMap getItemDescriptorNameToMapperMap()
Gets the map of item descriptor names to UrlTemplateMapper instances

Returns:
The Map of item descriptor names to UrlTemplateMapper instances that is a property of this droplet.

getDefaultWebApp

public WebApp getDefaultWebApp()
Returns:
The default WebApp that is configured for this jump servlet instance.

setDefaultWebApp

public void setDefaultWebApp(WebApp pDefaultWebApp)
Parameters:
pDefaultWebApp - The default WebApp to set.

setSiteManager

public void setSiteManager(SiteManager pSiteManager)
Sets the SiteManager property

Parameters:
pSiteManager - The Site Manager

getSiteManager

public SiteManager getSiteManager()
Gets the SiteManager property

Returns:
The SiteManager property

doStartService

public void doStartService()
                    throws ServiceException
Initializes the maps.

Overrides:
doStartService in class GenericService
Throws:
ServiceException
See Also:
GenericService.doStartService()

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
Generates a url string based on a template populated by item properties and/or request properties. The template is dependant on the item descriptor and the request user-agent browser type.

Overrides:
service in class DynamoServlet
Parameters:
pRequest - DynamoHttpSevletRequest
pResponse - DynamoHttpServletResponse
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.

getTemplateMapper

protected UrlTemplateMapper getTemplateMapper(DynamoHttpServletRequest pRequest,
                                              java.lang.String pItemDescriptorName,
                                              UrlParameterLookup pLookup)
Method to get the UrlTemplateMapper object for the given item descriptor name. If the item descriptor name isn't in the map then the getBestFitMapper() method will be used to try to get a match. If that fails then a default mapper will be tried.

Parameters:
pRequest - DynamoHttpServletRequest object
pItemDescriptorName - String item descriptor name to map to a UrlTemplateMapper.
pLookup - UrlParameterLookup object containing some request parameter info.
Returns:
UrlTemplateMapper object matched to that descriptor name.

getBestFitTemplateMapper

protected UrlTemplateMapper getBestFitTemplateMapper(DynamoHttpServletRequest pRequest,
                                                     java.lang.String pItemDescriptorName,
                                                     UrlParameterLookup pLookup)
Method to get the best fit UrlTemplateMapper object for the given item descriptor name. This method will iterate through the known mappers and check whether the given item descriptor is a sub type of the mapped item descriptor. If it is then the given item descriptor will be added to the end of the map and it will be returned

Parameters:
pRequest - DynamoHttpServletRequest object
pItemDescriptorName - String item descriptor name to map to a mapper.
pLookup - UrlParameterLookup object containing some request parameter info
Returns:
UrlTemplateMapper object mapped to a super type of the given item descriptor name.

getTemplate

protected UrlTemplate getTemplate(DynamoHttpServletRequest pRequest,
                                  UrlTemplateMapper pMapper)
                           throws atg.repository.seo.ItemLinkException
Gets the UrlTemplate to use to format the Url to return to the caller. It gets the template from a template mapper which looks it up by the browser type for the user-agent this request is from.

If the user needs to override where the template is obtained this should be done here.

Parameters:
pRequest - DynamoHttpServletRequest object
pMapper - UrlTemplateMapper to get the template from
Returns:
UrlTemplate
Throws:
atg.repository.seo.ItemLinkException

populateParams

protected void populateParams(DynamoHttpServletRequest pRequest,
                              UrlParameter[] pParams,
                              UrlParameterLookup pLookup)
This method populates the value of the parameters needed to create the Url string. The values are obtained either from the repository item or as request parameters. If the user needs to override where the parameters are populated this should be done here.

Parameters:
pRequest - DynamoHttpServletRequest object
pParams - array of UrlParameter needing set
pLookup - UrlParameterLookup object of the item passed into this request, may be null

populateParams

protected void populateParams(DynamoHttpServletRequest pRequest,
                              UrlParameter[] pParams,
                              UrlParameterLookup[] pLookups)
This method populates the value of the parameters needed to create the Url string. The values are obtained either from the repository item or as request parameters. If the user needs to override where the parameters are populated this should be done here.

Parameters:
pRequest - DynamoHttpServletRequest object
pParams - array of UrlParameter needing set
pLookups - array of UrlParameterLookup to use for populating parameters with values

getItemDescriptorName

protected java.lang.String getItemDescriptorName(DynamoHttpServletRequest pRequest,
                                                 UrlParameterLookup pLookup)
This method obtains the repository item descriptor name from the request.

It will first check for the name in the lookup object. If not found then it will check it as a request property.

If it still isn't found then the default descriptor name from the properties will be used.

If the user needs to override where the descriptor name is obtained this should be done here.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
pLookup - UrlParameterLookup object containing some request parameter info
Returns:
the String repository item descriptor name

getRepositoryName

protected java.lang.String getRepositoryName(DynamoHttpServletRequest pRequest,
                                             UrlParameterLookup pLookup)
This method obtains the repository name from the request.

If the user needs to override where the repository name is obtained this should be done here.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
pLookup - UrlParameterLookup containing parameter request info
Returns:
the String repository name

getItemLookup

protected UrlParameterLookup getItemLookup(DynamoHttpServletRequest pRequest)
This method creates a lookup item for the item or id from the request.

If the user needs to override where the lookup item is obtained this should be done here.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
Returns:
the UrlParameterLookup object

getSiteLookup

protected UrlParameterLookup getSiteLookup(DynamoHttpServletRequest pRequest)
This method creates a lookup item for the item or id from the request.

If the user needs to override where the lookup item is obtained this should be done here.

Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
Returns:
the UrlParameterLookup object