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, java.util.Properties properties)
Creates a new TemplateManager. -
Method Summary
Modifier and Type Method Description java.lang.String
findJSP(javax.servlet.jsp.PageContext pageContext, java.lang.String name)
An utility method for finding a JSP page.java.lang.String
findJSP(javax.servlet.jsp.PageContext pageContext, java.lang.String template, java.lang.String name)
Attempts to locate a resource under the given template.java.lang.String
findResource(Context ctx, java.lang.String template, java.lang.String name)
Attempts to locate a resource under the given template.WikiModuleInfo
getModuleInfo(java.lang.String moduleName)
Returns theWikiModuleInfo
information about the provided moduleName.java.util.Set<java.lang.String>
listSkins(javax.servlet.jsp.PageContext pageContext, java.lang.String template)
Lists the skins available under this template.java.util.Map<java.lang.String,java.lang.String>
listTimeFormats(javax.servlet.jsp.PageContext pageContext)
List all available timeformats, read from the jspwiki.propertiesjava.util.Collection<WikiModuleInfo>
modules()
Returns a collection of modules currently managed by this ModuleManager.boolean
templateExists(java.lang.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
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
Check the existence of a template.- Specified by:
templateExists
in interfaceTemplateManager
-
findJSP
An utility method for finding a JSP page. It searches only under either current context or by the absolute name.- Specified by:
findJSP
in interfaceTemplateManager
- Parameters:
pageContext
- the JSP PageContextname
- The name of the JSP page to look for (e.g "Wiki.jsp")- Returns:
- The context path to the resource
-
findJSP
public java.lang.String findJSP(javax.servlet.jsp.PageContext pageContext, java.lang.String template, java.lang.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 interfaceTemplateManager
- Parameters:
pageContext
- The JSP PageContexttemplate
- 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 java.lang.String findResource(Context ctx, java.lang.String template, java.lang.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 interfaceTemplateManager
- Parameters:
ctx
- the wiki contexttemplate
- the name of the template to usename
- the name of the resource to fine- Returns:
- the path to the resource
-
listSkins
public java.util.Set<java.lang.String> listSkins(javax.servlet.jsp.PageContext pageContext, java.lang.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 interfaceTemplateManager
- Parameters:
pageContext
- the JSP PageContexttemplate
- The template to search- Returns:
- Set of Strings with the skin names.
-
listTimeFormats
public java.util.Map<java.lang.String,java.lang.String> listTimeFormats(javax.servlet.jsp.PageContext pageContext)List all available timeformats, read from the jspwiki.properties- Specified by:
listTimeFormats
in interfaceTemplateManager
- Parameters:
pageContext
- page context- Returns:
- map of TimeFormats
-
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 interfaceModuleManager
- Returns:
- A Collection of WikiModuleInfo instances.
-
getModuleInfo
Returns theWikiModuleInfo
information about the provided moduleName.- Specified by:
getModuleInfo
in interfaceModuleManager
- Returns:
- The wikiModuleInfo
-