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
  • Constructor Details

    • DefaultTemplateManager

      public DefaultTemplateManager​(Engine engine, java.util.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​(java.lang.String templateName)
      Check the existence of a template.
      Specified by:
      templateExists in interface TemplateManager
    • findJSP

      public java.lang.String findJSP​(javax.servlet.jsp.PageContext pageContext, java.lang.String name)
      An 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 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 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 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 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 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 interface TemplateManager
      Parameters:
      pageContext - the JSP PageContext
      template - 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 interface TemplateManager
      Parameters:
      pageContext - page context
      Returns:
      map of TimeFormats
    • modules

      public java.util.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​(java.lang.String moduleName)
      Returns the WikiModuleInfo information about the provided moduleName.
      Specified by:
      getModuleInfo in interface ModuleManager
      Returns:
      The wikiModuleInfo