Package org.apache.wiki.ui

# Class DefaultTemplateManager

java.lang.Object
org.apache.wiki.modules.BaseModuleManager
org.apache.wiki.ui.DefaultTemplateManager

All Implemented Interfaces:
  `ModuleManager`, `TemplateManager`

public class DefaultTemplateManager extends BaseModuleManager implements TemplateManager
This class takes care of managing JSPWiki templates. This class also provides the ResourceRequest mechanism.

Since:
  2.1.62

## Field Summary

### Fields inherited from class org.apache.wiki.modules.BaseModuleManager

`m_engine`

### Fields inherited from interface org.apache.wiki.modules.ModuleManager

`PLUGIN_RESOURCE_LOCATION`

### Fields inherited from interface org.apache.wiki.ui.TemplateManager

`DEFAULT_TEMPLATE, DIRECTORY, I18NDEFAULT_LOCALE, I18NRESOURCE_EN, I18NRESOURCE_EN_ID, I18NRESOURCE_PREFIX, I18NRESOURCE_SUFFIX, I18NSERVER_TIMEZONE, PROPERTYFILE, RESOURCE_HTTPHEADER, RESOURCE_INCLUDES, RESOURCE_INLINECSS, RESOURCE_JSFUNCTION, RESOURCE_JSLOCALIZEDSTRINGS, RESOURCE_SCRIPT, RESOURCE_STYLESHEET, SKIN_DIRECTORY, TIMEFORMATPROPERTIES`

## Constructor Summary

Constructors
Constructor
Description
`DefaultTemplateManager(Engine engine, Properties properties)`
Creates a new TemplateManager.

## Method Summary

Modifier and Type
Method
Description
`String`
`findJSP(javax.servlet.jsp.PageContext pageContext, String name)`
A utility method for finding a JSP page.
`String`
`findJSP(javax.servlet.jsp.PageContext pageContext, String template, String name)`
Attempts to locate a resource under the given template.
`String`
`findResource(Context ctx, String template, String name)`
Attempts to locate a resource under the given template.
`WikiModuleInfo`
`getModuleInfo(String moduleName)`
Returns the `WikiModuleInfo` information about the provided moduleName.
`Set<String>`
`listSkins(javax.servlet.jsp.PageContext pageContext, String template)`
Lists the skins available under this template.
`Map<String,String>`
`listTimeFormats(javax.servlet.jsp.PageContext pageContext)`
List all available timeformats, read from the jspwiki.properties
`Collection<WikiModuleInfo>`
`modules()`
Returns a collection of modules currently managed by this ModuleManager.
`boolean`
`templateExists(String templateName)`
Check the existence of a template.

### Methods inherited from class org.apache.wiki.modules.BaseModuleManager

`checkCompatibility, modules`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.wiki.modules.ModuleManager

`checkCompatibility`

### Methods inherited from interface org.apache.wiki.ui.TemplateManager

`listLanguages, listTimeZones`

## Constructor Details

### DefaultTemplateManager

public DefaultTemplateManager(Engine engine, Properties properties)
Creates a new TemplateManager. There is typically one manager per engine.

Parameters:
  `engine` - The owning engine.
  `properties` - The property list used to initialize this.

## Method Details

### templateExists

public boolean templateExists(String templateName)
Check the existence of a template.

Specified by:
  `templateExists` in interface `TemplateManager`

### findJSP

public String findJSP(javax.servlet.jsp.PageContext pageContext, String name)
A utility method for finding a JSP page. It searches only under either current context or by the absolute name.

Specified by:
  `findJSP` in interface `TemplateManager`
Parameters:
  `pageContext` - the JSP PageContext
  `name` - The name of the JSP page to look for (e.g "Wiki.jsp")
Returns:
  The context path to the resource

### findJSP

public String findJSP(javax.servlet.jsp.PageContext pageContext, String template, String name)
Attempts to locate a resource under the given template. If that template does not exist, or the page does not exist under that template, will attempt to locate a similarly named file under the default template.

Even though the name suggests only JSP files can be located, but in fact this method can find also other resources than JSP files.

Specified by:
  `findJSP` in interface `TemplateManager`
Parameters:
  `pageContext` - The JSP PageContext
  `template` - From which template we should seek initially?
  `name` - Which resource are we looking for (e.g. "ViewTemplate.jsp")
Returns:
  path to the JSP page; null, if it was not found.

### findResource

public String findResource(Context ctx, String template, String name)
Attempts to locate a resource under the given template. This matches the functionality findJSP(), but uses the WikiContext as the argument. If there is no servlet context (i.e. this is embedded), will just simply return a best-guess.

This method is typically used to locate any resource, including JSP pages, images, scripts, etc.

Specified by:
  `findResource` in interface `TemplateManager`
Parameters:
  `ctx` - the wiki context
  `template` - the name of the template to use
  `name` - the name of the resource to fine
Returns:
  the path to the resource

### listSkins

public Set<String> listSkins(javax.servlet.jsp.PageContext pageContext, String template)
Lists the skins available under this template. Returns an empty Set, if there are no extra skins available. Note that this method does not check whether there is anything actually in the directories, it just lists them. This may change in the future.

Specified by:
  `listSkins` in interface `TemplateManager`
Parameters:
  `pageContext` - the JSP PageContext
  `template` - The template to search
Returns:
  Set of Strings with the skin names.

### listTimeFormats

public Map<String,String> listTimeFormats(javax.servlet.jsp.PageContext pageContext)
List all available timeformats, read from the jspwiki.properties

Specified by:
  `listTimeFormats` in interface `TemplateManager`
Parameters:
  `pageContext` - page context
Returns:
  map of TimeFormats

### modules

public Collection<WikiModuleInfo> modules()
Returns a collection of modules currently managed by this ModuleManager. Each entry is an instance of the WikiModuleInfo class. This method should return something which is safe to iterate over, even if the underlying collection changes.

Specified by:
  `modules` in interface `ModuleManager`
Returns:
  A Collection of WikiModuleInfo instances.

### getModuleInfo

public WikiModuleInfo getModuleInfo(String moduleName)
Returns the `WikiModuleInfo` information about the provided moduleName.

Specified by:
  `getModuleInfo` in interface `ModuleManager`
Returns:
  The wikiModuleInfo