org.opencms.loader
Class CmsTemplateContextManager

java.lang.Object
  extended by org.opencms.loader.CmsTemplateContextManager

public class CmsTemplateContextManager
extends java.lang.Object

Manager class for template context providers.


Field Summary
static java.lang.String ATTR_TEMPLATE_BEAN
          A bean containing information about the selected template.
static java.lang.String ATTR_TEMPLATE_CONTEXT
          The request attribute in which the template context is stored.
static java.lang.String ATTR_TEMPLATE_NAME
          Attribute name which contains the template name for non-dynamically selected templates.
static java.lang.String ATTR_TEMPLATE_RESOURCE
          Attribute name for the template resource.
static java.lang.String DYNAMIC_TEMPLATE_PREFIX
          The prefix used in the template property to activate dynamic template selection.
 
Constructor Summary
CmsTemplateContextManager(CmsObject cms)
          Creates a new instance.
 
Method Summary
protected  CmsXmlContentProperty createTemplateContextsPropertyDefinition(I_CmsTemplateContextProvider contextProvider, java.util.Locale locale)
          Creates the setting definition for the templateContexts setting.
 CmsTemplateContextInfo getContextInfoBean(CmsObject cms, javax.servlet.http.HttpServletRequest request)
          Creates a bean with information about the current template context, for use in the client-side code.
 CmsTemplateContext getTemplateContext(java.lang.String providerName, CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
          Gets the template context to use.
 I_CmsTemplateContextProvider getTemplateContextProvider(CmsObject cms, java.lang.String path)
          Gets the template context provider for a given path.
 I_CmsTemplateContextProvider getTemplateContextProvider(java.lang.String providerName)
          Retrieves an instance of a template context provider given its name (optionally prefixed by the 'dynamic:' prefix).
protected  java.util.Map<java.lang.String,CmsDefaultSet<java.lang.String>> safeGetAllowedContextMap()
          Helper method for getting the forbidden contexts from the resource manager without a try-catch block.
 boolean shouldShowType(CmsTemplateContext context, java.lang.String typeName)
          Helper method to check whether a given type should not be shown in a context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_TEMPLATE_BEAN

public static final java.lang.String ATTR_TEMPLATE_BEAN
A bean containing information about the selected template.

See Also:
Constant Field Values

ATTR_TEMPLATE_CONTEXT

public static final java.lang.String ATTR_TEMPLATE_CONTEXT
The request attribute in which the template context is stored.

See Also:
Constant Field Values

ATTR_TEMPLATE_NAME

public static final java.lang.String ATTR_TEMPLATE_NAME
Attribute name which contains the template name for non-dynamically selected templates.

See Also:
Constant Field Values

ATTR_TEMPLATE_RESOURCE

public static final java.lang.String ATTR_TEMPLATE_RESOURCE
Attribute name for the template resource.

See Also:
Constant Field Values

DYNAMIC_TEMPLATE_PREFIX

public static final java.lang.String DYNAMIC_TEMPLATE_PREFIX
The prefix used in the template property to activate dynamic template selection.

See Also:
Constant Field Values
Constructor Detail

CmsTemplateContextManager

public CmsTemplateContextManager(CmsObject cms)
Creates a new instance.

Parameters:
cms - the CMS context to use
Method Detail

getContextInfoBean

public CmsTemplateContextInfo getContextInfoBean(CmsObject cms,
                                                 javax.servlet.http.HttpServletRequest request)
Creates a bean with information about the current template context, for use in the client-side code.

Parameters:
cms - the current CMS context
request - the current request
Returns:
the bean with the template context information

getTemplateContext

public CmsTemplateContext getTemplateContext(java.lang.String providerName,
                                             CmsObject cms,
                                             javax.servlet.http.HttpServletRequest request,
                                             CmsResource resource)
Gets the template context to use.

Parameters:
providerName - the name of the template context provider
cms - the current CMS context
request - the current request
resource - the current resource
Returns:
the current template context

getTemplateContextProvider

public I_CmsTemplateContextProvider getTemplateContextProvider(CmsObject cms,
                                                               java.lang.String path)
                                                        throws CmsException
Gets the template context provider for a given path.

Parameters:
cms - the current CMS context
path - the path for which the template context provider should be determined
Returns:
the template context provider for the given path
Throws:
CmsException - if something goes wrong

getTemplateContextProvider

public I_CmsTemplateContextProvider getTemplateContextProvider(java.lang.String providerName)
Retrieves an instance of a template context provider given its name (optionally prefixed by the 'dynamic:' prefix).

Parameters:
providerName - the name of the provider
Returns:
an instance of the provider class

shouldShowType

public boolean shouldShowType(CmsTemplateContext context,
                              java.lang.String typeName)
Helper method to check whether a given type should not be shown in a context.

Parameters:
context - the template context
typeName - the type name
Returns:
true if the context does not prohibit showing the type

createTemplateContextsPropertyDefinition

protected CmsXmlContentProperty createTemplateContextsPropertyDefinition(I_CmsTemplateContextProvider contextProvider,
                                                                         java.util.Locale locale)
Creates the setting definition for the templateContexts setting.

Parameters:
contextProvider - the context provider
locale - the current locale
Returns:
the setting definition

safeGetAllowedContextMap

protected java.util.Map<java.lang.String,CmsDefaultSet<java.lang.String>> safeGetAllowedContextMap()
Helper method for getting the forbidden contexts from the resource manager without a try-catch block.

Returns:
the forbidden context map