com.arsdigita.cms.dispatcher
Class SimpleItemResolver

java.lang.Object
  extended bycom.arsdigita.cms.dispatcher.AbstractItemResolver
      extended bycom.arsdigita.cms.dispatcher.SimpleItemResolver
All Implemented Interfaces:
ItemResolver

public class SimpleItemResolver
extends AbstractItemResolver
implements ItemResolver

This is the default implementation of ItemResolver.

The getItem method of the default implementation of ItemResolver, SimpleItemResolver runs a simple query using the passed in information to retrieve the content item with a name that matches the URL stub, in our example it looks for a content item with name cheese. If no such item exists, or if there is such an item, but without a live version, even though one has been requested, getItem returns null.

After the CMS Dispatcher received the content item from the ItemResolver, it also asks it for the MasterPage for that item in the current request. With the content item and the master page in hand, the dispatcher calls service on the page.

Version:
$Revision: #14 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Michael Pih (pihman@arsdigita.com)

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.cms.dispatcher.AbstractItemResolver
TEMPLATE_CONTEXT_PREFIX
 
Constructor Summary
SimpleItemResolver()
           
 
Method Summary
 String generateItemURL(com.arsdigita.bebop.PageState state, BigDecimal itemId, String name, ContentSection section, String context)
          Generates a URL for a content item.
 String generateItemURL(com.arsdigita.bebop.PageState state, BigDecimal itemId, String name, ContentSection section, String context, String templateContext)
          Generates a URL for a content item.
 String generateItemURL(com.arsdigita.bebop.PageState state, ContentItem item, ContentSection section, String context)
          Generates a URL for a content item.
 String generateItemURL(com.arsdigita.bebop.PageState state, ContentItem item, ContentSection section, String context, String templateContext)
          Generates a URL for a content item.
 String getCurrentContext(com.arsdigita.bebop.PageState state)
          Fetches the current context based on the page state.
 ContentItem getItem(ContentSection section, String url, String context)
          Return a content item based on page state (and content section).
 ContentItem getItem(String url, Folder rootFolder)
          Return the content item at the specified path, or null if no such item exists.
 CMSPage getMasterPage(ContentItem item, javax.servlet.http.HttpServletRequest request)
          Return a master page based on page state (and content section).
 
Methods inherited from class com.arsdigita.cms.dispatcher.AbstractItemResolver
getTemplateFromURL, stripTemplateFromURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.cms.dispatcher.ItemResolver
getTemplateFromURL, stripTemplateFromURL
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

SimpleItemResolver

public SimpleItemResolver()
Method Detail

getItem

public ContentItem getItem(ContentSection section,
                           String url,
                           String context)
Return a content item based on page state (and content section).

Specified by:
getItem in interface ItemResolver
Specified by:
getItem in class AbstractItemResolver
Parameters:
section - The current content section
url - The section-relative URL
context - The LIVE/DRAFT context (*not* the template use context)
Returns:
The content item mapped to the content section and URL, or null if no such item exists

getCurrentContext

public String getCurrentContext(com.arsdigita.bebop.PageState state)
Description copied from interface: ItemResolver
Fetches the current context based on the page state.

Specified by:
getCurrentContext in interface ItemResolver
Specified by:
getCurrentContext in class AbstractItemResolver
Parameters:
state - the current page state
Returns:
the context of the current URL, such as "live" or "admin"

getItem

public ContentItem getItem(String url,
                           Folder rootFolder)
Return the content item at the specified path, or null if no such item exists. The path is interpreted as a series of folders; for example, "/foo/bar/baz" will look for an item named "baz" in a folder named "bar" in a folder named "foo" under the specified root folder.

Parameters:
url - the URL to the item
rootFolder - The root folder where the item search will start
Returns:
the item on success, null if no such item exists

generateItemURL

public String generateItemURL(com.arsdigita.bebop.PageState state,
                              BigDecimal itemId,
                              String name,
                              ContentSection section,
                              String context)
Generates a URL for a content item.

Specified by:
generateItemURL in interface ItemResolver
Specified by:
generateItemURL in class AbstractItemResolver
Parameters:
itemId - The item ID
name - The name of the content page
state - The page state
section - the content section to which the item belongs
context - the context of the URL, such as "LIVE" or "DRAFT"
Returns:
The URL of the item

generateItemURL

public String generateItemURL(com.arsdigita.bebop.PageState state,
                              BigDecimal itemId,
                              String name,
                              ContentSection section,
                              String context,
                              String templateContext)
Generates a URL for a content item.

Specified by:
generateItemURL in interface ItemResolver
Specified by:
generateItemURL in class AbstractItemResolver
Parameters:
itemId - The item ID
name - The name of the content page
state - The page state
section - the content section to which the item belongs
context - the context of the URL, such as "live" or "admin"
templateContext - the context for the URL, such as "public"
Returns:
The URL of the item

generateItemURL

public String generateItemURL(com.arsdigita.bebop.PageState state,
                              ContentItem item,
                              ContentSection section,
                              String context)
Generates a URL for a content item.

Specified by:
generateItemURL in interface ItemResolver
Specified by:
generateItemURL in class AbstractItemResolver
Parameters:
item - The item
state - The page state
section - the content section to which the item belongs
context - the context of the URL, such as "LIVE" or "DRAFT"
Returns:
The URL of the item
See Also:
getCurrentContext(com.arsdigita.bebop.PageState)

generateItemURL

public String generateItemURL(com.arsdigita.bebop.PageState state,
                              ContentItem item,
                              ContentSection section,
                              String context,
                              String templateContext)
Generates a URL for a content item.

Specified by:
generateItemURL in interface ItemResolver
Specified by:
generateItemURL in class AbstractItemResolver
Parameters:
item - The item
state - The page state
section - the content section to which the item belongs
context - the context of the URL, such as "live" or "admin"
templateContext - the context for the URL, such as "public"
Returns:
The URL of the item
See Also:
getCurrentContext(com.arsdigita.bebop.PageState)

getMasterPage

public CMSPage getMasterPage(ContentItem item,
                             javax.servlet.http.HttpServletRequest request)
                      throws javax.servlet.ServletException
Return a master page based on page state (and content section).

Specified by:
getMasterPage in interface ItemResolver
Specified by:
getMasterPage in class AbstractItemResolver
Parameters:
item - The content item
request - The HTTP request
Throws:
javax.servlet.ServletException


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