atg.endeca.assembler
Class AssemblerTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.endeca.assembler.AssemblerTools
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, java.util.EventListener

public class AssemblerTools
extends GenericService

Tools class for the Assembler. Provides a means of invoking the assembler, finding associated services and contains useful and reusable methods.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String CONTENT_ITEM_TO_RENDERER_PATH_MAPPER
          Mapper from ContentItem to a rendering path to include to (typically a JSP).
static java.lang.String CONTENT_PREFIX
          Custom content prefix "contentPrefix" request parameter name.
static java.lang.String CONTENT_RENDERER
          The default contentRenderer path to fall back on, specified by an init parameter in the web-app.
static java.lang.String JSON_FORMAT
          JSON output serialization format ("json").
static java.lang.String XML_FORMAT
          XML output serialization format ("xml").
 
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
AssemblerTools()
           
 
Method Summary
 void doStartService()
          Makes a VariableArgumentApplicationLogging component available as a static property for use by other classes that do not have their own logging support.
static VariableArgumentApplicationLogging getApplicationLogging()
           
 AssemblerFactory getAssemblerFactory()
           
 AssemblerSettings getAssemblerSettings()
           
 atg.service.filter.bean.BeanFilterService getBeanFilterService()
          Returns the BeanFilterService component used for filtering content items.
 InvokeAssemblerCallback[] getCallbacks()
           
 ContentItemToRendererPath getContentItemToRendererPathForRequest(javax.servlet.ServletContext pServletContext)
          Return the CatridgerRenderingMapper to use for the specified request.
 java.lang.String getContentPath(DynamoHttpServletRequest pRequest)
          Returns the full path used to query for content in the Java Content Repository.
 java.lang.String getContentPathPrefix()
          Firstly check the request for a "contentPath" parameter, if its not set return the default prefix for either Experience Manager or Guided Search.
 ContentItemToRendererPath getDefaultContentItemToRendererPath()
          Returns property defaultContentItemToRendererPath.
 java.lang.String getDefaultContentRenderer()
           
 java.lang.String getRendererPathForContentItem(DynamoHttpServletRequest pRequest, ContentItem pContentItem)
          Get the renderer path (typically a path to a JSP file) that can render the specified ContentItem.
 atg.service.response.output.ResponseGenerator getResponseGenerator()
           
 ContentItem invokeAssembler(ContentItem pContentItem)
          Query the Endeca Java Content Repository for content using the assembler API.
 ContentItem invokeAssembler(java.lang.String pContentItem)
          Invokes the handler belonging to the passed in content item type.
 boolean isExperienceManager()
          Returns the value of NucleusAssemblerSettings.isExperienceManager.
 boolean isRemoveContextRoot()
           
 boolean isRemoveSiteBaseURL()
           
 boolean isUseMapper()
          Returns property useMapper.
protected  boolean removeContextRoot(java.lang.StringBuilder pResourceBuilder)
          Removes the context root
protected  boolean removeSiteBaseURL(java.lang.StringBuilder pResourceBuilder)
          Removes the site base url.
 void serializeContentItemToResponse(java.lang.Object pContentItem, DynamoHttpServletResponse pResponse, java.io.Writer pWriter, java.lang.String pFormat)
          Serialize pContentItem to the format specified by pFormat ( ("xml" or "json").
static void setApplicationLogging(VariableArgumentApplicationLogging pApplicationLogging)
          Set a component that can be used for logging by related classes.
 void setAssemblerFactory(AssemblerFactory pAssemblerFactory)
           
 void setAssemblerSettings(AssemblerSettings pAssemblerSettings)
           
 void setBeanFilterService(atg.service.filter.bean.BeanFilterService pBeanFilterService)
          Sets the BeanFilterService component used for filtering content items.
 void setCallbacks(InvokeAssemblerCallback[] pCallbacks)
           
 void setDefaultContentItemToRendererPath(ContentItemToRendererPath pDefaultContentItemToRendererPath)
          Sets property defaultContentItemToRendererPath.
 void setDefaultContentRenderer(java.lang.String pDefaultContentRenderer)
          Set the location of a JSP that knows how to handle the rendering of returned content items.
 void setRemoveContextRoot(boolean pRemoveContextRoot)
           
 void setRemoveSiteBaseURL(boolean pRemoveSiteBaseURL)
           
 void setResponseGenerator(atg.service.response.output.ResponseGenerator pResponseGenerator)
           
 void setUseMapper(boolean pUseMapper)
          Sets property useMapper.
 
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


CONTENT_PREFIX

public static final java.lang.String CONTENT_PREFIX
Custom content prefix "contentPrefix" request parameter name. This will be prepended to the request made by the assembler.

See Also:
Constant Field Values

CONTENT_ITEM_TO_RENDERER_PATH_MAPPER

public static final java.lang.String CONTENT_ITEM_TO_RENDERER_PATH_MAPPER
Mapper from ContentItem to a rendering path to include to (typically a JSP).

See Also:
Constant Field Values

CONTENT_RENDERER

public static final java.lang.String CONTENT_RENDERER
The default contentRenderer path to fall back on, specified by an init parameter in the web-app.

See Also:
Constant Field Values

JSON_FORMAT

public static final java.lang.String JSON_FORMAT
JSON output serialization format ("json").

See Also:
Constant Field Values

XML_FORMAT

public static final java.lang.String XML_FORMAT
XML output serialization format ("xml").

See Also:
Constant Field Values
Constructor Detail

AssemblerTools

public AssemblerTools()
Method Detail

getAssemblerSettings

public AssemblerSettings getAssemblerSettings()
Returns:
AssemblerSettings A bean that contains settings common to assembler components.

setAssemblerSettings

public void setAssemblerSettings(AssemblerSettings pAssemblerSettings)
Parameters:
pAssemblerSettings - Set a new AssemblerSettings bean.

getAssemblerFactory

public AssemblerFactory getAssemblerFactory()
Returns:
A factory responsible for creating an Assembler instance.

setAssemblerFactory

public void setAssemblerFactory(AssemblerFactory pAssemblerFactory)
Parameters:
pAssemblerFactory - Set a new assemblerFactory

isRemoveSiteBaseURL

public boolean isRemoveSiteBaseURL()
Returns:
If true the site base url (productionURL) is to be removed from the path passed to the assembler. For example, if set to true and the URL is /crs/storeus/browse only /browse will be used in the URL passed to the assembler.

setRemoveSiteBaseURL

public void setRemoveSiteBaseURL(boolean pRemoveSiteBaseURL)
Parameters:
pRemoveSiteBaseURL - Set a new removeSiteBaseURL property

isRemoveContextRoot

public boolean isRemoveContextRoot()
Returns:
If true the context root is to be removed from the path passed to the assembler. For example if set to true and the URL is /crs/storeus/browse only /storeus/browse will be used in the URL passed to the assembler.

setRemoveContextRoot

public void setRemoveContextRoot(boolean pRemoveContextRoot)
Parameters:
pRemoveContextRoot - Set a new removeContextRoot property.

setDefaultContentItemToRendererPath

public void setDefaultContentItemToRendererPath(ContentItemToRendererPath pDefaultContentItemToRendererPath)
Sets property defaultContentItemToRendererPath. The default cartridge rendering mapper to use.


getDefaultContentItemToRendererPath

public ContentItemToRendererPath getDefaultContentItemToRendererPath()
Returns property defaultContentItemToRendererPath. The default cartridge rendering mapper to use.


getDefaultContentRenderer

public java.lang.String getDefaultContentRenderer()
Returns:
The location of a JSP that knows how to handle the rendering of returned content items.

setDefaultContentRenderer

public void setDefaultContentRenderer(java.lang.String pDefaultContentRenderer)
Set the location of a JSP that knows how to handle the rendering of returned content items.

Parameters:
pDefaultContentRenderer -

getApplicationLogging

public static VariableArgumentApplicationLogging getApplicationLogging()
Returns:
A component that can be used for logging by related classes

setApplicationLogging

public static void setApplicationLogging(VariableArgumentApplicationLogging pApplicationLogging)
Set a component that can be used for logging by related classes.

Parameters:
pApplicationLogging - a logging component

setUseMapper

public void setUseMapper(boolean pUseMapper)
Sets property useMapper. Whether to attempt to use the ContentItemToRendererPath via AssemblerTools.


isUseMapper

public boolean isUseMapper()
Returns property useMapper. Whether to attempt to use the ContentItemToRendererPath via AssemblerTools.


setBeanFilterService

public void setBeanFilterService(atg.service.filter.bean.BeanFilterService pBeanFilterService)
Sets the BeanFilterService component used for filtering content items.

Parameters:
pBeanFilterService - The BeanFilterService component used for filtering content items.

getBeanFilterService

public atg.service.filter.bean.BeanFilterService getBeanFilterService()
Returns the BeanFilterService component used for filtering content items.

Returns:
The BeanFilterService component used for filtering content items.

getCallbacks

public InvokeAssemblerCallback[] getCallbacks()
Returns:
An array of callbacks that will be called just prior to calling assemble() and just after calling assemble. This is a hook to initialize pre-conditions prior to calling assemble() and corresponding hook to cleanup afterwards.
See Also:
atg.endeca.assembler.InvokeAssemblerCallback, invokeAssembler(ContentItem)

setCallbacks

public void setCallbacks(InvokeAssemblerCallback[] pCallbacks)
See Also:
atg.endeca.assembler.InvokeAssemblerCallback, invokeAssembler(ContentItem)

getResponseGenerator

public atg.service.response.output.ResponseGenerator getResponseGenerator()
See Also:
ResponseGenerator

setResponseGenerator

public void setResponseGenerator(atg.service.response.output.ResponseGenerator pResponseGenerator)
See Also:
ResponseGenerator

invokeAssembler

public ContentItem invokeAssembler(java.lang.String pContentItem)
                            throws AssemblerException
Invokes the handler belonging to the passed in content item type.

Parameters:
pContentItem - A content item type
Returns:
The content item produced as a result of invoking the handler belonging to pContentItem.
Throws:
AssemblerException

invokeAssembler

public ContentItem invokeAssembler(ContentItem pContentItem)
                            throws AssemblerException
Query the Endeca Java Content Repository for content using the assembler API. The passed in ContentItem pContentItem is passed in to the Assemblers assembler method. The ContentItem returned from this invocation is returned.

Parameters:
pContentItem - The ContentItem used in the assembler invocation.
Returns:
ContentItem The ContentItem returned from the assembler invocation.
Throws:
AssemblerException - If an error occurs invoking the assembler.

getContentPath

public java.lang.String getContentPath(DynamoHttpServletRequest pRequest)
Returns the full path used to query for content in the Java Content Repository. The content path is determined as follows:

Returns:
The path to query for content in the Java Content Repository

getContentPathPrefix

public java.lang.String getContentPathPrefix()
Firstly check the request for a "contentPath" parameter, if its not set return the default prefix for either Experience Manager or Guided Search. The default prefix is set on the assemblerSettings bean.

Returns:
The content path prefix.

isExperienceManager

public boolean isExperienceManager()
Returns the value of NucleusAssemblerSettings.isExperienceManager. This should be set to true when Experience Manager is in use, it should be set to false when Guided Search is in use.

Returns:
A boolean indicating if Experience Manager is available

removeSiteBaseURL

protected boolean removeSiteBaseURL(java.lang.StringBuilder pResourceBuilder)
Removes the site base url. For example for storeSiteUS this would be /crs/storeus

Parameters:
pResourceBuilder -

removeContextRoot

protected boolean removeContextRoot(java.lang.StringBuilder pResourceBuilder)
Removes the context root

Parameters:
pResourceBuilder -

getContentItemToRendererPathForRequest

public ContentItemToRendererPath getContentItemToRendererPathForRequest(javax.servlet.ServletContext pServletContext)
Return the CatridgerRenderingMapper to use for the specified request. Will generally be the value of our defaultContentItemToRendererPath property, unless the current web-app has an override init-param value for "contentItemToRendererPath".

Returns:
pRequest the request to use.

getRendererPathForContentItem

public java.lang.String getRendererPathForContentItem(DynamoHttpServletRequest pRequest,
                                                      ContentItem pContentItem)
Get the renderer path (typically a path to a JSP file) that can render the specified ContentItem.

Parameters:
pRequest - the current request
pContentItem - the content item to return a

serializeContentItemToResponse

public void serializeContentItemToResponse(java.lang.Object pContentItem,
                                           DynamoHttpServletResponse pResponse,
                                           java.io.Writer pWriter,
                                           java.lang.String pFormat)
                                    throws java.io.IOException,
                                           javax.servlet.ServletException
Serialize pContentItem to the format specified by pFormat ( ("xml" or "json").

Parameters:
pContentItem - the ContentItem to serialize
pResponse - the current response (may be null if pWriter is non-null). If pResponse is not null, will set the content type of the response appropriately.
pWriter - the write to write the serialized form to. If null will write the response to pResponse.
pFormat - the format to serialize pContentItem as. Currently must be "xml" or "json".
Throws:
java.io.IOException
javax.servlet.ServletException

doStartService

public void doStartService()
                    throws ServiceException
Makes a VariableArgumentApplicationLogging component available as a static property for use by other classes that do not have their own logging support.

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