Class CmsToolManager

java.lang.Object
org.opencms.workplace.tools.CmsToolManager

public class CmsToolManager extends Object
Manages the registered tools, actualizing its state every time the workplace is reinitialize.

Manages also the configuration settings for the administration view, and provides several tool related methods.

Since:
6.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • linkForToolPath

      public static String linkForToolPath(CmsJspActionElement jsp, String toolPath)
      Returns the OpenCms link for the given tool path which requires no parameters.

      Parameters:
      jsp - the jsp action element
      toolPath - the tool path
      Returns:
      the OpenCms link for the given tool path which requires parameters
    • linkForToolPath

      public static String linkForToolPath(CmsJspActionElement jsp, String toolPath, Map<String,String[]> params)
      Returns the OpenCms link for the given tool path which requires parameters.

      Please note: Don't overuse the parameter map because this will likely introduce issues with encoding. If possible, don't pass parameters at all, or only very simple parameters with no special chars that can easily be parsed.

      Parameters:
      jsp - the jsp action element
      toolPath - the tool path
      params - the map of required tool parameters
      Returns:
      the OpenCms link for the given tool path which requires parameters
    • addToolRoot

      public void addToolRoot(CmsToolRootHandler toolRoot)
      Adds a new tool root to the tool manager.

      Parameters:
      toolRoot - the tool root to add
    • configure

      public void configure(CmsObject cms)
      Parameters:
      cms - the admin cms context
    • generateNavBar

      public String generateNavBar(String toolPath, CmsWorkplace wp)
      Returns the navigation bar html code for the given tool path.

      Parameters:
      toolPath - the path
      wp - the jsp page
      Returns:
      the html code
    • getBaseToolPath

      Returns the base tool path for the active user.

      Parameters:
      wp - the workplace object
      Returns:
      the base tool path for the active user
    • getCurrentRoot

      Returns the current user's root handler.

      Parameters:
      wp - the workplace context
      Returns:
      the current user's root handler
    • getCurrentTool

      Returns the current tool.

      Parameters:
      wp - the workplace object
      Returns:
      the current tool
    • getCurrentToolPath

      Returns the current tool path.

      Parameters:
      wp - the workplace object
      Returns:
      the current tool path
    • getParent

      public String getParent(CmsWorkplace wp, String toolPath)
      Returns the path to the parent of the tool identified by the given tool path.

      The parent of the root is the same root.

      Parameters:
      wp - the workplace object
      toolPath - the abstract tool path
      Returns:
      his parent
    • getToolHandlers

      Returns a list with all registered tools.

      Returns:
      list if CmsTool
    • getToolRoots

      Returns a list of tool roots.

      Returns:
      a list of CmsToolRootHandler objects
    • getToolsForPath

      public List<CmsTool> getToolsForPath(CmsWorkplace wp, String baseTool, boolean includeSubtools)
      Returns a list of all tools in the given path.

      Parameters:
      wp - the workplace context
      baseTool - the path
      includeSubtools - if the tools in subfolders should be also returned
      Returns:
      a list of CmsTool objects
    • getUserData

      Returns the CmsToolUserData object for a given user.

      Parameters:
      wp - the workplace object
      Returns:
      the current user data
    • hasToolPathForUrl

      public boolean hasToolPathForUrl(String url)
      Returns true if there is at least one tool registered using the given url.

      Parameters:
      url - the url of the tool
      Returns:
      true if there is at least one tool registered using the given url
    • initParams

      public void initParams(CmsToolDialog wp)
      This method initializes the tool manager for the current user.

      Parameters:
      wp - the jsp page coming from
    • jspForwardPage

      public void jspForwardPage(CmsWorkplace wp, String pagePath, Map<String,String[]> params) throws IOException, javax.servlet.ServletException
      Redirects to the given page with the given parameters.

      Parameters:
      wp - the workplace object
      pagePath - the path to the page to redirect to
      params - the parameters to send
      Throws:
      IOException - in case of errors during forwarding
      javax.servlet.ServletException - in case of errors during forwarding
    • jspForwardTool

      public void jspForwardTool(CmsWorkplace wp, String toolPath, Map<String,String[]> params) throws IOException, javax.servlet.ServletException
      Redirects to the given tool with the given parameters.

      Parameters:
      wp - the workplace object
      toolPath - the path to the tool to redirect to
      params - the parameters to send
      Throws:
      IOException - in case of errors during forwarding
      javax.servlet.ServletException - in case of errors during forwarding
    • resolveAdminTool

      public CmsTool resolveAdminTool(String rootKey, String toolPath)
      Returns the admin tool corresponding to the given abstract path.

      Parameters:
      rootKey - the tool root
      toolPath - the path
      Returns:
      the corresponding tool, or null if not found
    • setBaseToolPath

      public void setBaseToolPath(CmsWorkplace wp, String baseToolPath)
      Sets the base tool path.

      Parameters:
      wp - the workplace object
      baseToolPath - the base tool path to set
    • setCurrentRoot

      public void setCurrentRoot(CmsWorkplace wp, String key)
      Sets the current user's root key.

      Parameters:
      wp - the workplace context
      key - the current user's root key to set
    • setCurrentToolPath

      public void setCurrentToolPath(CmsWorkplace wp, String currentToolPath)
      Sets the current tool path.

      Parameters:
      wp - the workplace object
      currentToolPath - the current tool path to set