org.alfresco.web.app.servlet
Class GuestTemplateContentServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.alfresco.web.app.servlet.BaseServlet
              extended by org.alfresco.web.app.servlet.BaseTemplateContentServlet
                  extended by org.alfresco.web.app.servlet.GuestTemplateContentServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class GuestTemplateContentServlet
extends BaseTemplateContentServlet

Servlet responsible for streaming content from a template processed against a node directly to the response stream.

The URL to the servlet should be generated thus:

/alfresco/template/workspace/SpacesStore/0000-0000-0000-0000
or
/alfresco/template/workspace/SpacesStore/0000-0000-0000-0000/workspace/SpacesStore/0000-0000-0000-0000
or
/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/doc_info.ftl&contextPath=/Company%20Home/mydoc.txt

The store protocol, followed by the store ID, followed by the content Node Id used to identify the node to execute the default template for. The second set of elements encode the store and node Id of the template to used if a default is not set or not requested. Instead of using NodeRef references to the template and context, path arguments can be used. The URL args of 'templatePath' and 'contextPath' can be used instead to specify name based encoded Paths to the template and its context.

The URL may be followed by a 'mimetype' argument specifying the mimetype to return the result as on the stream. Otherwise it is assumed that HTML is the default response mimetype.

Like most Alfresco servlets, the URL may be followed by a valid 'ticket' argument for authentication: ?ticket=1234567890

And/or also followed by the "?guest=true" argument to force guest access login for the URL. If the guest=true parameter is used the current session will be logged out and the guest user logged in. Therefore upon completion of this request the current user will be "guest".

This servlet only accesses content available to the guest user. If the guest user does not have access to the requested a 401 Forbidden response is returned to the caller.

This servlet does not effect the current session, therefore if guest access is required to a resource this servlet can be used without logging out the current user.

See Also:
Serialized Form

Nested Class Summary
 class GuestTemplateContentServlet.TemplateContentWork
          Class to wrap the call to processTemplateRequest.
 
Nested classes/interfaces inherited from class org.alfresco.web.app.servlet.BaseTemplateContentServlet
BaseTemplateContentServlet.URLHelper
 
Nested classes/interfaces inherited from class org.alfresco.web.app.servlet.BaseServlet
BaseServlet.PathRefInfo
 
Field Summary
 
Fields inherited from class org.alfresco.web.app.servlet.BaseTemplateContentServlet
imageResolver
 
Fields inherited from class org.alfresco.web.app.servlet.BaseServlet
FACES_SERVLET, KEY_ROOT_PATH, KEY_STORE
 
Constructor Summary
GuestTemplateContentServlet()
           
 
Method Summary
protected  java.util.Map buildModel(org.alfresco.service.ServiceRegistry services, javax.servlet.http.HttpServletRequest req, org.alfresco.service.cmr.repository.NodeRef templateRef)
          Builds the FreeMarker model
static java.lang.String generateURL(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.cmr.repository.NodeRef templateRef)
          Helper to generate a URL to process a template against a node.
protected  org.apache.commons.logging.Log getLogger()
          Gets the logger to use for this request.
protected  void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
Methods inherited from class org.alfresco.web.app.servlet.BaseTemplateContentServlet
processTemplateRequest
 
Methods inherited from class org.alfresco.web.app.servlet.BaseServlet
checkAccess, getServiceRegistry, redirectToLoginPage, resolveNamePath, resolveWebDAVPath, resolveWebDAVPath, resolveWebDAVPath, resolveWebDAVPath, servletAuthenticate, servletAuthenticate, setNoCacheHeaders, validRedirectJSP
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuestTemplateContentServlet

public GuestTemplateContentServlet()
Method Detail

getLogger

protected org.apache.commons.logging.Log getLogger()
Description copied from class: BaseTemplateContentServlet
Gets the logger to use for this request.

This will show all debug entries from this class as though they came from the subclass.

Specified by:
getLogger in class BaseTemplateContentServlet
Returns:
The logger

buildModel

protected java.util.Map buildModel(org.alfresco.service.ServiceRegistry services,
                                   javax.servlet.http.HttpServletRequest req,
                                   org.alfresco.service.cmr.repository.NodeRef templateRef)
Description copied from class: BaseTemplateContentServlet
Builds the FreeMarker model

Specified by:
buildModel in class BaseTemplateContentServlet
Parameters:
services - Service Registry instance
req - Http request
templateRef - The node ref of the template to process
Returns:
The FreeMarker model

service

protected void service(javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res)
                throws javax.servlet.ServletException,
                       java.io.IOException
Overrides:
service in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

generateURL

public static final java.lang.String generateURL(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                 org.alfresco.service.cmr.repository.NodeRef templateRef)
Helper to generate a URL to process a template against a node.

The result of the template is supplied returned as the response.

Parameters:
nodeRef - NodeRef of the content node to generate URL for (cannot be null)
templateRef - NodeRef of the template to process against, or null to use default
Returns:
URL to process the template


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.