## com.arsdigita.cms.docmgr.dispatcher
Class MultilingualDocumentResolver

    java.lang.Object
      com.arsdigita.cms.dispatcher.AbstractItemResolver
          com.arsdigita.cms.docmgr.dispatcher.MultilingualDocumentResolver

All Implemented Interfaces:
  com.arsdigita.cms.dispatcher.ItemResolver

public class MultilingualDocumentResolver
extends com.arsdigita.cms.dispatcher.AbstractItemResolver
implements com.arsdigita.cms.dispatcher.ItemResolver

Adapted from MultilingualItemResolver. Unlike MultilingualItemResolver, this resolver needs to account for Documents that have file extensions.

Version:
  $Id: //apps/docmgr-cms/dev/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java#1 $
Author:
  Crag Wolfe Resolves items to URLs and URLs to items for multiple language variants. Created Mon Jan 20 14:30:03 2003., Michael Hanisch

Field Summary
`protected static String` `ITEM_ID` The string identifying an item's ID in the query string of a URL.
`protected static String` `SEPARATOR` The separator used in URL query strings; should be either "&" or ";".
`static String` `versionId`

Fields inherited from class com.arsdigita.cms.dispatcher.AbstractItemResolver
`TEMPLATE_CONTEXT_PREFIX`

Constructor Summary
`MultilingualDocumentResolver()`

Method Summary
`protected String` `generateDraftURL(com.arsdigita.cms.ContentSection section, BigDecimal itemId)` Returns content item's draft version URL
`String` `generateItemURL(com.arsdigita.bebop.PageState state, BigDecimal itemId, String name, com.arsdigita.cms.ContentSection section, String context)` Generates a URL for a content item.
`String` `generateItemURL(com.arsdigita.bebop.PageState state, BigDecimal itemId, String name, com.arsdigita.cms.ContentSection section, String context, String templateContext)` Generates a URL for a content item.
`String` `generateItemURL(com.arsdigita.bebop.PageState state, com.arsdigita.cms.ContentItem item, com.arsdigita.cms.ContentSection section, String context)` Generates a URL for a content item.
`String` `generateItemURL(com.arsdigita.bebop.PageState state, com.arsdigita.cms.ContentItem item, com.arsdigita.cms.ContentSection section, String context, String templateContext)` Generates a URL for a content item.
`protected String` `generateLiveURL(com.arsdigita.cms.ContentSection section, com.arsdigita.cms.ContentItem item, String templateContext)` Generate a language-independent URL to the `item` in the given section.
`protected String` `generatePreviewURL(com.arsdigita.cms.ContentSection section, com.arsdigita.cms.ContentItem item, String templateContext)` Generate a URL which can be used to preview the `item`, using the given `templateContext`.
`String` `getCurrentContext(com.arsdigita.bebop.PageState state)` Fetches the current context based on the page state.
`com.arsdigita.cms.ContentItem` `getItem(com.arsdigita.cms.ContentSection section, String url, String context)` Returns a content item based on section, url, and use context.
`protected com.arsdigita.cms.ContentItem` `getItemFromDraftURL(String url)` Retrieves `ITEM_ID` parameter from URL and instantiates item according to this ID.
`protected com.arsdigita.cms.ContentItem` `getItemFromLangAndBundle(String lang, com.arsdigita.cms.ContentItem item)` Finds a language instance of a content item given the bundle, name, and lang string
`protected com.arsdigita.cms.ContentItem` `getItemFromLiveURL(String url, com.arsdigita.cms.Folder parentFolder)` Returns a content item based on URL relative to the root folder.
`com.arsdigita.cms.dispatcher.CMSPage` `getMasterPage(com.arsdigita.cms.ContentItem item, HttpServletRequest request)` Returns a master page based on page state (and content section).
`protected String[]` `getNameAndLangFromURLFrag(String url)` Returns an array containing the the item's name and lang based on the URL fragment.

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

### ITEM_ID

    protected static final String ITEM_ID

  The string identifying an item's ID in the query string of a URL.

  See Also:
    Constant Field Values

### SEPARATOR

    protected static final String SEPARATOR

  The separator used in URL query strings; should be either "&" or ";".

  See Also:
    Constant Field Values

Constructor Detail

### MultilingualDocumentResolver

    public MultilingualDocumentResolver()

Method Detail

### getItem

    public com.arsdigita.cms.ContentItem getItem(com.arsdigita.cms.ContentSection section,
                                                 String url,
                                                 String context)

  Returns a content item based on section, url, and use context.

  Specified by:
    `getItem` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  Parameters:
    `section` - The current content section
    `url` - The section-relative URL
    `context` - The use context, e.g. `ContentItem.LIVE`, `CMSDispatcher.PREVIEW` or `ContentItem.DRAFT`. See `getCurrentContext(com.arsdigita.bebop.PageState)`.
  Returns:
    The content item, or null if no such item exists

### getCurrentContext

    public String getCurrentContext(com.arsdigita.bebop.PageState state)

  Fetches the current context based on the page state.

  Specified by:
    `getCurrentContext` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  Parameters:
    `state` - the current page state
  Returns:
    the context of the current URL, such as `ContentItem.LIVE` or `ContentItem.DRAFT`
  See Also:
    `ContentItem.LIVE`, `ContentItem.DRAFT`

### generateItemURL

    public String generateItemURL(com.arsdigita.bebop.PageState state,
                                  BigDecimal itemId,
                                  String name,
                                  com.arsdigita.cms.ContentSection section,
                                  String context)

  Generates a URL for a content item.

  Specified by:
    `generateItemURL` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  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"
  Returns:
    The URL of the item
  See Also:
    `getCurrentContext(com.arsdigita.bebop.PageState)`

### generateItemURL

    public String generateItemURL(com.arsdigita.bebop.PageState state,
                                  BigDecimal itemId,
                                  String name,
                                  com.arsdigita.cms.ContentSection section,
                                  String context,
                                  String templateContext)

  Generates a URL for a content item.

  Specified by:
    `generateItemURL` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  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
  See Also:
    `getCurrentContext(com.arsdigita.bebop.PageState)`

### generateItemURL

    public String generateItemURL(com.arsdigita.bebop.PageState state,
                                  com.arsdigita.cms.ContentItem item,
                                  com.arsdigita.cms.ContentSection section,
                                  String context)

  Generates a URL for a content item.

  Specified by:
    `generateItemURL` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  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"
  Returns:
    The URL of the item
  See Also:
    `getCurrentContext(com.arsdigita.bebop.PageState)`

### generateItemURL

    public String generateItemURL(com.arsdigita.bebop.PageState state,
                                  com.arsdigita.cms.ContentItem item,
                                  com.arsdigita.cms.ContentSection section,
                                  String context,
                                  String templateContext)

  Generates a URL for a content item.

  Specified by:
    `generateItemURL` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  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 com.arsdigita.cms.dispatcher.CMSPage getMasterPage(com.arsdigita.cms.ContentItem item,
                                                              HttpServletRequest request)
                                                       throws ServletException

  Returns a master page based on page state (and content section).

  Specified by:
    `getMasterPage` in interface `com.arsdigita.cms.dispatcher.ItemResolver`
  Parameters:
    `item` - The content item
    `request` - The HTTP request
  Returns:
    The master page
  Throws:
    `ServletException`

### generateDraftURL

    protected String generateDraftURL(com.arsdigita.cms.ContentSection section,
                                      BigDecimal itemId)

  Returns content item's draft version URL

  Parameters:
    `section` - The content section to which the item belongs
    `itemId` - The content item's ID
  Returns:
    generated URL string

### generateLiveURL

    protected String generateLiveURL(com.arsdigita.cms.ContentSection section,
                                     com.arsdigita.cms.ContentItem item,
                                     String templateContext)

  Generate a language-independent URL to the `item` in the given section.

  When a client retrieves this URL, the URL is resolved to point to a specific language instance of the item referenced here, i.e. this URL will be resolved to a language-specific URL internally.

  Parameters:
    `section` - the `ContentSection` that contains this item
    `item` - `ContentItem` for which a URL should be constructed.
    `templateContext` - template context; will be ignored if `null`
  Returns:
    a language-independent URL to the `item` in the given `section`, which will be presented within the given `templateContext`

### generatePreviewURL

    protected String generatePreviewURL(com.arsdigita.cms.ContentSection section,
                                        com.arsdigita.cms.ContentItem item,
                                        String templateContext)

  Generate a URL which can be used to preview the `item`, using the given `templateContext`.

  Only a specific language instance can be previewed, meaning there no language negotiation is involved when a request is made to a URL that has been generated by this method.

  Parameters:
    `section` - The `ContentSection` which contains the `item`
    `item` - The `ContentItem` for which a URL should be generated.
    `templateContext` - the context that determines which template should render the item when it is previewed; ignored if the argument given here is `null`
  Returns:
    a URL which can be used to preview the given `item`

### getItemFromDraftURL

    protected com.arsdigita.cms.ContentItem getItemFromDraftURL(String url)

  Retrieves `ITEM_ID` parameter from URL and instantiates item according to this ID.

  Parameters:
    `url` - URL that indicates which item should be retrieved; must contain the `ITEM_ID` parameter
  Returns:
    the `ContentItem` the given `url` points to, or `null` if no ID has been found in the `url`

### getItemFromLiveURL

    protected com.arsdigita.cms.ContentItem getItemFromLiveURL(String url,
                                                               com.arsdigita.cms.Folder parentFolder)

  Returns a content item based on URL relative to the root folder.

  Parameters:
    `url` - The content item url
    `parentFolder` - The parent folder object, url must be relevant to it
  Returns:
    The Content Item instance, it can also be either Bundle or Folder objects, depending on URL and file language extension

### getNameAndLangFromURLFrag

    protected String[] getNameAndLangFromURLFrag(String url)

  Returns an array containing the the item's name and lang based on the URL fragment.

  Returns:
    a two-element string array, the first element containing the bundle name, and the second element containing the lang string

### getItemFromLangAndBundle

    protected com.arsdigita.cms.ContentItem getItemFromLangAndBundle(String lang,
                                                                     com.arsdigita.cms.ContentItem item)

  Finds a language instance of a content item given the bundle, name, and lang string

  Parameters:
    `lang` - The lang string from the URL
    `item` - The content bundle
  Returns:
    The negotiated lang instance for the current request.

Copyright (c) 2006 Red Hat, Inc. Corporation. All Rights Reserved. Generated at June 1 2006:1113 UTC