Class CmsToolManager


  • public class CmsToolManager
    extends java.lang.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
    • Constructor Detail

    • Method Detail

      • linkForToolPath

        public static java.lang.String linkForToolPath​(CmsJspActionElement jsp,
                                                       java.lang.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 java.lang.String linkForToolPath​(CmsJspActionElement jsp,
                                                       java.lang.String toolPath,
                                                       java.util.Map<java.lang.String,​java.lang.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
      • generateNavBar

        public java.lang.String generateNavBar​(java.lang.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

        public java.lang.String getBaseToolPath​(CmsWorkplace wp)
        Returns the base tool path for the active user.

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

        public java.lang.String getCurrentToolPath​(CmsWorkplace wp)
        Returns the current tool path.

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

        public java.lang.String getParent​(CmsWorkplace wp,
                                          java.lang.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
      • getToolsForPath

        public java.util.List<CmsToolgetToolsForPath​(CmsWorkplace wp,
                                                       java.lang.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
      • hasToolPathForUrl

        public boolean hasToolPathForUrl​(java.lang.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,
                                   java.lang.String pagePath,
                                   java.util.Map<java.lang.String,​java.lang.String[]> params)
                            throws java.io.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:
        java.io.IOException - in case of errors during forwarding
        javax.servlet.ServletException - in case of errors during forwarding
      • jspForwardTool

        public void jspForwardTool​(CmsWorkplace wp,
                                   java.lang.String toolPath,
                                   java.util.Map<java.lang.String,​java.lang.String[]> params)
                            throws java.io.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:
        java.io.IOException - in case of errors during forwarding
        javax.servlet.ServletException - in case of errors during forwarding
      • resolveAdminTool

        public CmsTool resolveAdminTool​(java.lang.String rootKey,
                                        java.lang.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,
                                    java.lang.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,
                                   java.lang.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,
                                       java.lang.String currentToolPath)
        Sets the current tool path.

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