com.arsdigita.cms.dispatcher
Class CMSDispatcher

java.lang.Object
  extended bycom.arsdigita.cms.dispatcher.CMSDispatcher
All Implemented Interfaces:
com.arsdigita.dispatcher.ChainedDispatcher, com.arsdigita.dispatcher.Dispatcher

public class CMSDispatcher
extends Object
implements com.arsdigita.dispatcher.Dispatcher, com.arsdigita.dispatcher.ChainedDispatcher

The CMS Dispatcher serves all request made within a content section. This dispatcher is called by the Subsite dispatcher.

Here are the steps for a request to http://yourserver/cms/cheese in excruciating detail:

  1. A client sends a request to the web server, which passes it on to the global ACS dispatcher.

  2. The global ACS dispatcher examines the first part of the URL, notices that CMS is mounted at /cms and hands the request to the CMS dispatcher.

  3. The CMS dispatcher determines whether a Page has been registered to the URL /cheese in this section via its PageResolver.

  4. Since no page is registered to the URL, the CMS dispatcher asks the content section (via its ItemResolver) for a content item for /cheese in this content section. The result of this process is a ContentItem object.

  5. The CMS dispatcher asks the content section for a Page to use as the "master template" for this item. The content section may apply item-, type-, or request-specific rules to make this decision (for example, check a user preference for normal or accessible style, or a query parameter for a printable version).

  6. The CMS dispatcher hands the master Page object to the SiteNodePresentationManager to serve the page.

  7. The presentation manager asks the master Page object for an XML document representing the data for the page.

  8. The master template begins walking through its component hierarchy, converting each component to XML by calling its generateXML method. The component responsible for rendering the content item uses an XMLGenerator to convert the content item to XML.

  9. The presentation manager receives the completed XML document, and selects an XSL transformer to use for generating the HTML. The stylesheet on which the transformer is based contains templates for all styles and all content types in the content section, in particular those from the file cms-item.xsl.

Version:
$Revision: #25 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Michael Pih (pihman@arsdigita.com), Uday Mathur (umathur@arsdigita.com), Jack Chung (flattop@arsdigita.com)

Field Summary
static String ADMIN_URL
           
static String CONTENT_ITEM
           
static String CONTENT_SECTION
           
static String[] INDEX_FILES
           
static String PREVIEW
          The context for previewing items
static String versionId
           
 
Fields inherited from interface com.arsdigita.dispatcher.ChainedDispatcher
DISPATCH_BREAK, DISPATCH_CONTINUE
 
Constructor Summary
CMSDispatcher()
           
CMSDispatcher(boolean adminOnly)
           
 
Method Summary
 int chainedDispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
           
protected  void checkUserAccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
          Verify that the user is logged in and is able to view the page.
 void dispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
          Handles requests made to a CMS package instance.
protected  ContentSection findContentSection(String url)
          Looks up the current content section using the remaining URL stored in the request context object and the SiteNode class.
protected  ContentItem getContentItem(ContentSection section, String url, String context)
          Lookup a content item by section and URL.
static ContentItem getContentItem(javax.servlet.http.HttpServletRequest request)
          Fetches the content item from the request attributes.
static ContentSection getContentSection(javax.servlet.http.HttpServletRequest request)
          Fetches the content section from the request attributes.
static ItemResolver getItemResolver(ContentSection section)
          Fetches the ItemResolver for a content section.
static PageResolver getPageResolver(ContentSection section)
          Fetches the PageResolver for a content section.
protected  ResourceHandler getResource(ContentSection section, String url)
          Fetch a resource based on the URL stub.
protected  SecurityManager getSecurityManager(ContentSection section)
          Returns the Security Manager to use for the specified section.
static XMLGenerator getXMLGenerator(ContentSection section)
          Fetches the XMLGenerator for a content section.
protected  boolean isAdminPage(String url)
          Does this URL correspond to an admin page?
protected  void preview(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
          Preview the current content item.
protected  void redirectToLoginPage(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Redirects the client to the login page, setting the return url to the current request URI.
static void releaseResource(ContentSection section, String url)
          Flushes the page resolver cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

CONTENT_SECTION

public static final String CONTENT_SECTION
See Also:
Constant Field Values

CONTENT_ITEM

public static final String CONTENT_ITEM
See Also:
Constant Field Values

INDEX_FILES

public static final String[] INDEX_FILES

ADMIN_URL

public static final String ADMIN_URL
See Also:
Constant Field Values

PREVIEW

public static final String PREVIEW
The context for previewing items

See Also:
Constant Field Values
Constructor Detail

CMSDispatcher

public CMSDispatcher()

CMSDispatcher

public CMSDispatcher(boolean adminOnly)
Method Detail

dispatch

public void dispatch(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     com.arsdigita.dispatcher.RequestContext actx)
              throws IOException,
                     javax.servlet.ServletException
Handles requests made to a CMS package instance. 1) fetches the current content section 2) fetches the resource mapped to the current section/URL 3) if no resource, fetches the item associated with the current section/URL 4) if no item, passes request to the JSP dispatcher, which serves JSP's, HTML pages, and media from the cms/packages/www directory

Specified by:
dispatch in interface com.arsdigita.dispatcher.Dispatcher
Parameters:
request - The request
response - The response
actx - The request context
Throws:
IOException
javax.servlet.ServletException

chainedDispatch

public int chainedDispatch(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           com.arsdigita.dispatcher.RequestContext actx)
                    throws IOException,
                           javax.servlet.ServletException
Specified by:
chainedDispatch in interface com.arsdigita.dispatcher.ChainedDispatcher
Throws:
IOException
javax.servlet.ServletException

getSecurityManager

protected SecurityManager getSecurityManager(ContentSection section)
Returns the Security Manager to use for the specified section.

Parameters:
section - The current ContentSection

checkUserAccess

protected void checkUserAccess(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               com.arsdigita.dispatcher.RequestContext actx)
                        throws javax.servlet.ServletException,
                               AccessDeniedException
Verify that the user is logged in and is able to view the page. Subclasses can override this method if they need to, but should always be sure to call super.checkUserAccess(...)

Parameters:
request - The HTTP request
response - The HTTP response
actx - The request context
Throws:
AccessDeniedException - if the user does not have access.
javax.servlet.ServletException

getContentSection

public static ContentSection getContentSection(javax.servlet.http.HttpServletRequest request)
Fetches the content section from the request attributes.

Parameters:
request - The HTTP request
Returns:
The content section

getContentItem

public static ContentItem getContentItem(javax.servlet.http.HttpServletRequest request)
Fetches the content item from the request attributes.

Parameters:
request - The HTTP request
Returns:
The content item

findContentSection

protected ContentSection findContentSection(String url)
                                     throws com.arsdigita.domain.DataObjectNotFoundException
Looks up the current content section using the remaining URL stored in the request context object and the SiteNode class.

Parameters:
url - The section URL stub
Returns:
The current Content Section
Throws:
com.arsdigita.domain.DataObjectNotFoundException

getResource

protected ResourceHandler getResource(ContentSection section,
                                      String url)
                               throws javax.servlet.ServletException
Fetch a resource based on the URL stub.

Parameters:
section - The current content section
url - The section-relative URL
Returns:
A ResourceHandler resource or null if none exists.
Throws:
javax.servlet.ServletException

getContentItem

protected ContentItem getContentItem(ContentSection section,
                                     String url,
                                     String context)
                              throws javax.servlet.ServletException
Lookup a content item by section and URL.

Parameters:
section - The content section
url - The URL relative to the content section
context - The use context
Returns:
The item associated with the URL, or null if no such item exists
Throws:
javax.servlet.ServletException

preview

protected void preview(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       com.arsdigita.dispatcher.RequestContext actx)
                throws IOException,
                       javax.servlet.ServletException
Preview the current content item.

Parameters:
request - The HTTP request
response - The HTTP response
actx - The request context
Throws:
IOException
javax.servlet.ServletException

releaseResource

public static void releaseResource(ContentSection section,
                                   String url)
Flushes the page resolver cache.

Parameters:
section - The current content section
url - The section-relative URL

getPageResolver

public static PageResolver getPageResolver(ContentSection section)
Fetches the PageResolver for a content section. Checks cache first.

Parameters:
section - The content section
Returns:
The PageResolver associated with the content section

getItemResolver

public static ItemResolver getItemResolver(ContentSection section)
Fetches the ItemResolver for a content section. Checks cache first.

Parameters:
section - The content section
Returns:
The ItemResolver associated with the content section

getXMLGenerator

public static XMLGenerator getXMLGenerator(ContentSection section)
Fetches the XMLGenerator for a content section. Checks cache first.

Parameters:
section - The content section
Returns:
The XMLGenerator associated with the content section

isAdminPage

protected boolean isAdminPage(String url)
Does this URL correspond to an admin page?


redirectToLoginPage

protected void redirectToLoginPage(javax.servlet.http.HttpServletRequest req,
                                   javax.servlet.http.HttpServletResponse resp)
                            throws javax.servlet.ServletException
Redirects the client to the login page, setting the return url to the current request URI.

Throws:
javax.servlet.ServletException - If there is an exception thrown while trying to redirect, wrap that exception in a ServletException


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC