org.opencms.workplace.tools
Class CmsToolManager

java.lang.Object
  extended by 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
Version:
$Revision: 1.42 $
Author:
Michael Moossen

Field Summary
static String ADMINTOOLS_ROOT_LOCATION
          Root location for the tools.
static String ADMINVIEW_ROOT_LOCATION
          Root location of the administration view.
static String HANDLERCLASS_PROPERTY
          Property definition name to look for.
static String NAVBAR_SEPARATOR
          Navegation bar separator (html code).
static String TOOLPATH_SEPARATOR
          Tool path separator.
static String VIEW_JSPPAGE_LOCATION
          Location of the admin view jsp page.
 
Constructor Summary
CmsToolManager(CmsObject cms)
          Default Constructor, called by the CmsWorkplaceManager.initialize(CmsObject) method.
 
Method Summary
 String generateNavBar(String toolPath, CmsWorkplace wp)
          Returns the navegation bar html code for the given tool path.
 CmsTool getCurrentTool(CmsWorkplace wp)
          Returns the current tool.
 String getCurrentToolPath(CmsWorkplace wp)
          Returns the current tool path.
 String getParent(CmsWorkplace wp, String toolPath)
          Returns the path to the parent of the tool identified by the given tool path.
 String getRootToolPath(CmsWorkplace wp)
          Returns the root tool path for the active user.
 List getToolHandlers()
          Returns a list with all registered tools.
 String getToolPathForUrl(String url)
          Returns the tool path for the given url.
 List getToolsForPath(String toolPath, boolean includeSubtools)
          Returns a list of all tools in the given path.
 CmsToolUserData getUserData(CmsWorkplace wp)
          Returns the CmsToolUserData object for a given user.
 void initParams(CmsToolDialog wp, String toolPath, String rootToolPath)
          This method initializes the tool manager for the current user.
 void jspForwardPage(CmsWorkplace wp, String pagePath, Map params)
          Redirects to the given page with the given parameters.
 void jspForwardTool(CmsWorkplace wp, String toolPath, Map params)
          Redirects to the given tool with the given parameters.
static String linkForToolPath(CmsJspActionElement jsp, String toolPath)
          Returns the OpenCms link for the given tool path which requires no parameters.
static String linkForToolPath(CmsJspActionElement jsp, String toolPath, Map params)
          Returns the OpenCms link for the given tool path which requires parameters.
 CmsTool resolveAdminTool(String toolPath)
          Returns the admin tool corresponding to the given abstract path.
 void setCurrentToolPath(CmsWorkplace wp, String currentToolPath)
          Sets the current tool path.
 void setRootToolPath(CmsWorkplace wp, String rootToolPath)
          Sets the root tool path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADMINTOOLS_ROOT_LOCATION

public static final String ADMINTOOLS_ROOT_LOCATION
Root location for the tools.

See Also:
Constant Field Values

ADMINVIEW_ROOT_LOCATION

public static final String ADMINVIEW_ROOT_LOCATION
Root location of the administration view.

See Also:
Constant Field Values

HANDLERCLASS_PROPERTY

public static final String HANDLERCLASS_PROPERTY
Property definition name to look for.

See Also:
Constant Field Values

NAVBAR_SEPARATOR

public static final String NAVBAR_SEPARATOR
Navegation bar separator (html code).

See Also:
Constant Field Values

TOOLPATH_SEPARATOR

public static final String TOOLPATH_SEPARATOR
Tool path separator.

See Also:
Constant Field Values

VIEW_JSPPAGE_LOCATION

public static final String VIEW_JSPPAGE_LOCATION
Location of the admin view jsp page.

See Also:
Constant Field Values
Constructor Detail

CmsToolManager

public CmsToolManager(CmsObject cms)
Default Constructor, called by the CmsWorkplaceManager.initialize(CmsObject) method.

Parameters:
cms - the cms context
Method Detail

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 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

generateNavBar

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

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

getCurrentTool

public CmsTool getCurrentTool(CmsWorkplace wp)
Returns the current tool.

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

getCurrentToolPath

public String getCurrentToolPath(CmsWorkplace wp)
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

getRootToolPath

public String getRootToolPath(CmsWorkplace wp)
Returns the root tool path for the active user.

Parameters:
wp - the workplace object
Returns:
the root tool path for the active user

getToolHandlers

public List getToolHandlers()
Returns a list with all registered tools.

Returns:
list if CmsTool

getToolPathForUrl

public String getToolPathForUrl(String url)
Returns the tool path for the given url.

Parameters:
url - the url of the tool
Returns:
the associated tool path

getToolsForPath

public List getToolsForPath(String toolPath,
                            boolean includeSubtools)
Returns a list of all tools in the given path.

Parameters:
toolPath - the path
includeSubtools - if the tools in subfolders should be also returned
Returns:
a list of abstract tools paths

getUserData

public CmsToolUserData getUserData(CmsWorkplace wp)
Returns the CmsToolUserData object for a given user.

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

initParams

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

Parameters:
wp - the jsp page comming from
toolPath - the current tool path
rootToolPath - the root tool path

jspForwardPage

public void jspForwardPage(CmsWorkplace wp,
                           String pagePath,
                           Map params)
                    throws IOException,
                           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
ServletException - in case of errors during forwarding

jspForwardTool

public void jspForwardTool(CmsWorkplace wp,
                           String toolPath,
                           Map params)
                    throws IOException,
                           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
ServletException - in case of errors during forwarding

resolveAdminTool

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

Parameters:
toolPath - the path
Returns:
the corresponding tool, or null if not found

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

setRootToolPath

public void setRootToolPath(CmsWorkplace wp,
                            String rootToolPath)
Sets the root tool path.

Parameters:
wp - the workplace object
rootToolPath - the root tool path to set