atg.endeca.assembler
Class AssemblerPipelineServlet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.servlet.pipeline.PipelineableServletImpl
                  extended by atg.servlet.pipeline.InsertableServletImpl
                      extended by atg.endeca.assembler.AssemblerPipelineServlet
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, InsertableServlet, PipelineableServlet, java.util.EventListener, javax.servlet.Servlet

public class AssemblerPipelineServlet
extends InsertableServletImpl

A pipline servlet that invokes the Assembler to return content from Experience Manager or Guided Search. This servlet is added to the pipline by default after the CookieBufferServlet.

For the servlet to invoke the Assembler its enabled property must be set to true, the web application must specify an atg.assembler context-param that is set to true, the request mime type must not be included in a list of ignored mime types and the URL must not match an ignore regular expression.

The AssemblerPipelineServlet can return two types of content from the Assembler, a ContentInclude and a ContentSlotConfig. A ContentInclude represents a 'page' in the Endeca world. A ContentSlotConfig returns an Endeca content collection. A ContentSlotConfig is returned by making a request to /assembler and having an assemblerContentCollection parameter which specifies the name of the content collection to return. The assemblerRuleLimit parameter may also be used in conjunction with the assemblerContentCollection parameter to indicate how many rules can fire within the particular content collection. A ContentInclude is returned by making a request to the path of a 'page' in Experience Manager or a service in Guided Search. For example, if a "browse" page exists in Experience Manager we may make a request to (webapproot)/browse.

The returned content may be in the form of a ContentItem, JSON or XML. A format parameter can be specified in the request. Valid values for this parameter are json or xml. If specified, the ContentItem will be serialized accordingly. If no format is specified an attempt is made to determine a suitable page (for example JSP) that can render the ContentItem. The ContentItem is set as a contentItem parameter on the request and the request is forwarded to the page.


Field Summary
static java.lang.String ASSEMBLER
           
static java.lang.String ASSEMBLER_INTERCEPTED_LINK
          This will be used as a request attribute that when set to true will tell us to pass the request to the next pipeline servlet rather than forward it.
static java.lang.String ATG_ASSEMBLER
           
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String CONTENT_COLLECTION
           
static java.lang.String CONTENT_ITEM
           
static java.lang.String ENDECA_REDIRECT
          Endeca redirect key in response content item
static java.lang.String ROOT_CONTENT_ITEM
           
static java.lang.String RULE_LIMIT
           
 
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
AssemblerPipelineServlet()
           
 
Method Summary
protected  ContentItem createContentInclude(DynamoHttpServletRequest pRequest, java.lang.String pResourcePath)
          Create a new ContentInclude content item.
protected  ContentSlotConfig createContentSlotConfig(DynamoHttpServletRequest pRequest, java.lang.String pContent, int pRuleLimit)
          Create a new ContentSlotConfig content item
protected  void forwardRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, ContentItem pContentItem)
          Forwards the request to the jsp specified by the contentRenderer servlet context parameter set in the Web.xml.
 java.lang.String[] getAllowedMimeTypes()
          Sets property allowedMimeTypes.
 AssemblerTools getAssemblerTools()
           
 java.lang.String getDefaultContentRenderer()
           
 java.lang.String getFormatParamName()
          Name of the request parameter that controls the format of the returned content.
 java.util.regex.Pattern getIgnoreRequestURIPattern()
          Returns property ignoreRequestURIPattern.
protected  java.lang.String getMimeTypeForRequest(DynamoHttpServletRequest pRequest)
          Extract the mime type for the request.
 MimeTyper getMimeTyper()
          Returns property mimeTyper.
 atg.service.configuration.ResponseWrappingConfiguration getResponseWrappingConfiguration()
          Returns property responseWrappingConfiguration.
 boolean isAssembleUnknownMimeTypes()
          Returns property assembleUnknownMimeTypes.
protected  boolean isContentCollectionRequest(DynamoHttpServletRequest pRequest)
          Build what the request would look like to the special "/assembler" path which indicates we want a ContentSlotConfig.
 boolean isEnable()
          Returns property enable.
protected  boolean isMimeTypeAllowed(java.lang.String pMimeType)
          Return whether the specified mime type is allowed.
protected  void redirectRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse, ContentItem pContentItem, java.lang.String pRedirectURL)
          Redirect to the URL specified
protected  java.lang.String requestURIWithoutParams(DynamoHttpServletRequest pRequest)
          Get the request uri without params
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Services a DynamoHttpServletRequest/Response pair
 void setAllowedMimeTypes(java.lang.String[] pAllowedMimeTypes)
          Sets property allowedMimeTypes.
 void setAssemblerTools(AssemblerTools pAssemblerTools)
           
 void setAssembleUnknownMimeTypes(boolean pAssembleUnknownMimeTypes)
          Sets property assembleUnknownMimeTypes.
 void setDefaultContentRenderer(java.lang.String pDefaultContentRenderer)
          Set the location of a JSP that knows how to handle the rendering of returned content items.
 void setEnable(boolean pEnable)
          Sets property enable.
 void setFormatParamName(java.lang.String pFormatParamName)
           
 void setIgnoreRequestURIPattern(java.util.regex.Pattern pIgnoreRequestURIPattern)
          Sets property ignoreRequestURIPattern.
 void setMimeTyper(MimeTyper pMimeTyper)
          Sets property mimeTyper.
 void setResponseWrappingConfiguration(atg.service.configuration.ResponseWrappingConfiguration pResponseWrappingConfiguration)
          Sets property responseWrappingConfiguration.
protected  boolean shouldIgnoreRequest(DynamoHttpServletRequest pRequest)
          Whether we should ignore this request (as far as invoking the Assembler).
 
Methods inherited from class atg.servlet.pipeline.InsertableServletImpl
doStartService, getInsertAfterServlet, setInsertAfterServlet
 
Methods inherited from class atg.servlet.pipeline.PipelineableServletImpl
createAdminServlet, destroy, getAdminServlet, getNextServlet, getServletConfig, getServletInfo, init, isUsePathInfo, passRequest, passRequest, service, service, setNextServlet, setServletInfo, setUsePathInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStopService, getAbsoluteName, 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
 
Methods inherited from interface atg.servlet.pipeline.PipelineableServlet
getNextServlet, passRequest, setNextServlet
 
Methods inherited from interface javax.servlet.Servlet
destroy, getServletConfig, getServletInfo, init, service
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


ASSEMBLER

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

CONTENT_COLLECTION

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

RULE_LIMIT

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

ATG_ASSEMBLER

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

CONTENT_ITEM

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

ROOT_CONTENT_ITEM

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

ASSEMBLER_INTERCEPTED_LINK

public static final java.lang.String ASSEMBLER_INTERCEPTED_LINK
This will be used as a request attribute that when set to true will tell us to pass the request to the next pipeline servlet rather than forward it.

See Also:
Constant Field Values

ENDECA_REDIRECT

public static final java.lang.String ENDECA_REDIRECT
Endeca redirect key in response content item

See Also:
Constant Field Values
Constructor Detail

AssemblerPipelineServlet

public AssemblerPipelineServlet()
Method Detail

setEnable

public void setEnable(boolean pEnable)
Sets property enable. Whether this component is enabled.


isEnable

public boolean isEnable()
Returns property enable. Whether this component is enabled.


setAssembleUnknownMimeTypes

public void setAssembleUnknownMimeTypes(boolean pAssembleUnknownMimeTypes)
Sets property assembleUnknownMimeTypes. Whether to send unknown mime types to the Assembler for possible rendering. This is generally true, so that paths that look like directories can be handled by the Assembler.


isAssembleUnknownMimeTypes

public boolean isAssembleUnknownMimeTypes()
Returns property assembleUnknownMimeTypes. Whether to send unknown mime types to the Assembler for possible rendering. This is generally true, so that paths that look like directories can be handled by the Assembler.


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 -

getAssemblerTools

public AssemblerTools getAssemblerTools()
Returns:
The AssemblerTools bean

setAssemblerTools

public void setAssemblerTools(AssemblerTools pAssemblerTools)
Parameters:
pAssemblerTools - Set a new AssemblerTools

getFormatParamName

public java.lang.String getFormatParamName()
Name of the request parameter that controls the format of the returned content. Defaults to "format".

Returns:
formatParamName

setFormatParamName

public void setFormatParamName(java.lang.String pFormatParamName)
Parameters:
pFormatParamName - Set a new formatParamName

setIgnoreRequestURIPattern

public void setIgnoreRequestURIPattern(java.util.regex.Pattern pIgnoreRequestURIPattern)
Sets property ignoreRequestURIPattern. The pattern to be applied to ignore a request URI.


getIgnoreRequestURIPattern

public java.util.regex.Pattern getIgnoreRequestURIPattern()
Returns property ignoreRequestURIPattern. The pattern to be applied to ignore a request URI.


setAllowedMimeTypes

public void setAllowedMimeTypes(java.lang.String[] pAllowedMimeTypes)
Sets property allowedMimeTypes. The allow request mime types to allow. The null mimetype is always allowed. Has an effect only if MimeTyper is set.


getAllowedMimeTypes

public java.lang.String[] getAllowedMimeTypes()
Sets property allowedMimeTypes. The allow request mime types to allow. The null mimetype is always allowed. Has an effect only if MimeTyper is set.


setMimeTyper

public void setMimeTyper(MimeTyper pMimeTyper)
Sets property mimeTyper. The mime typer to use for mime typing the path of the request. If null, mime type associated with the request will have no effect.


getMimeTyper

public MimeTyper getMimeTyper()
Returns property mimeTyper. The mime typer to use for mime typing the path of the request. If null, mime type associated with the request will have no effect.


setResponseWrappingConfiguration

public void setResponseWrappingConfiguration(atg.service.configuration.ResponseWrappingConfiguration pResponseWrappingConfiguration)
Sets property responseWrappingConfiguration. The response wrapping configuration to use to potentially wrap the response output for filtering/modification.


getResponseWrappingConfiguration

public atg.service.configuration.ResponseWrappingConfiguration getResponseWrappingConfiguration()
Returns property responseWrappingConfiguration. The response wrapping configuration to use to potentially wrap the response output for filtering/modification.


isMimeTypeAllowed

protected boolean isMimeTypeAllowed(java.lang.String pMimeType)
Return whether the specified mime type is allowed. Returns true if pMimeType is null, or pMimeType is in allowedMimeTypes.

Parameters:
pMimeType - the mime type off the request.
Returns:
true if allowed, false if disallowed

getMimeTypeForRequest

protected java.lang.String getMimeTypeForRequest(DynamoHttpServletRequest pRequest)
Extract the mime type for the request. Returns null if no matching mime type was found.

Parameters:
pRequest - the current request
pResourcePath - the resource path as returned by AssemblerTools

shouldIgnoreRequest

protected boolean shouldIgnoreRequest(DynamoHttpServletRequest pRequest)
Whether we should ignore this request (as far as invoking the Assembler).

Parameters:
pRequest - the current request.
Returns:
true assembler shouldn't be invoked for this request, false if the assembler should.

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws java.io.IOException,
                    javax.servlet.ServletException
Description copied from class: PipelineableServletImpl
Services a DynamoHttpServletRequest/Response pair

Overrides:
service in class PipelineableServletImpl
Throws:
java.io.IOException - if an error occurred while reading or writing the servlet request
javax.servlet.ServletException - if an error occurred while processing the servlet request

createContentInclude

protected ContentItem createContentInclude(DynamoHttpServletRequest pRequest,
                                           java.lang.String pResourcePath)
Create a new ContentInclude content item. Returns an instance of RedirectAwareContentInclude if keyword redirects are enabled.

Parameters:
pRequest -
pResourcePath -
Returns:

createContentSlotConfig

protected ContentSlotConfig createContentSlotConfig(DynamoHttpServletRequest pRequest,
                                                    java.lang.String pContent,
                                                    int pRuleLimit)
Create a new ContentSlotConfig content item

Parameters:
pRequest - HttpRequest
pResourcePath - resource path
pRuleLimit - rule limit
Returns:

redirectRequest

protected void redirectRequest(DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse,
                               ContentItem pContentItem,
                               java.lang.String pRedirectURL)
                        throws java.io.IOException
Redirect to the URL specified

Parameters:
pRequest - HttpRequest
pResponse - HttpResponse
pContentItem - the content item
pRedirectURL - the redirect URL
Throws:
java.io.IOException

forwardRequest

protected void forwardRequest(DynamoHttpServletRequest pRequest,
                              DynamoHttpServletResponse pResponse,
                              ContentItem pContentItem)
                       throws javax.servlet.ServletException,
                              java.io.IOException
Forwards the request to the jsp specified by the contentRenderer servlet context parameter set in the Web.xml. If this is not set uses the defaultContentRenderer property.

Parameters:
pRequest - HttpRequest
pResponse - HttpResponse
pContentItem - The content item to make available on the page
ASSEMBLER_INTERCEPTED_LINK -
Throws:
javax.servlet.ServletException
java.io.IOException

isContentCollectionRequest

protected boolean isContentCollectionRequest(DynamoHttpServletRequest pRequest)
Build what the request would look like to the special "/assembler" path which indicates we want a ContentSlotConfig. If it is not to the "/assembler" path then we use a ContentInclude, regardless of the presence of an assemblerContentCollection.

Parameters:
pRequest -
Returns:

requestURIWithoutParams

protected java.lang.String requestURIWithoutParams(DynamoHttpServletRequest pRequest)
Get the request uri without params

Parameters:
pRequest -