Package org.opencms.workplace.tools
Class CmsToolManager
- java.lang.Object
-
- org.opencms.workplace.tools.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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ADMINVIEW_ROOT_LOCATION
Root location of the administration view.static java.lang.String
HANDLERCLASS_PROPERTY
Property definition name to look for.static java.lang.String
NAVBAR_SEPARATOR
Navigation bar separator (html code).static java.lang.String
ROOT_SEPARATOR
Tool root separator.static java.lang.String
ROOTKEY_DEFAULT
Key for the default tool root, if there is no configured root with this a key, a new one will be configured.static java.lang.String
TOOLPATH_SEPARATOR
Tool path separator.static java.lang.String
VIEW_JSPPAGE_LOCATION
Location of the default admin view jsp page.
-
Constructor Summary
Constructors Constructor Description CmsToolManager()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToolRoot(CmsToolRootHandler toolRoot)
Adds a new tool root to the tool manager.void
configure(CmsObject cms)
Called by the
method.CmsWorkplaceManager.initialize(CmsObject)
java.lang.String
generateNavBar(java.lang.String toolPath, CmsWorkplace wp)
Returns the navigation bar html code for the given tool path.java.lang.String
getBaseToolPath(CmsWorkplace wp)
Returns the base tool path for the active user.CmsToolRootHandler
getCurrentRoot(CmsWorkplace wp)
Returns the current user's root handler.CmsTool
getCurrentTool(CmsWorkplace wp)
Returns the current tool.java.lang.String
getCurrentToolPath(CmsWorkplace wp)
Returns the current tool path.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.java.util.List<CmsTool>
getToolHandlers()
Returns a list with all registered tools.java.util.List<CmsToolRootHandler>
getToolRoots()
Returns a list of tool roots.java.util.List<CmsTool>
getToolsForPath(CmsWorkplace wp, java.lang.String baseTool, boolean includeSubtools)
Returns a list of all tools in the given path.CmsToolUserData
getUserData(CmsWorkplace wp)
Returns the
object for a given user.CmsToolUserData
boolean
hasToolPathForUrl(java.lang.String url)
Returnstrue
if there is at least one tool registered using the given url.void
initParams(CmsToolDialog wp)
This method initializes the tool manager for the current user.void
jspForwardPage(CmsWorkplace wp, java.lang.String pagePath, java.util.Map<java.lang.String,java.lang.String[]> params)
Redirects to the given page with the given parameters.void
jspForwardTool(CmsWorkplace wp, java.lang.String toolPath, java.util.Map<java.lang.String,java.lang.String[]> params)
Redirects to the given tool with the given parameters.static java.lang.String
linkForToolPath(CmsJspActionElement jsp, java.lang.String toolPath)
Returns the OpenCms link for the given tool path which requires no parameters.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.CmsTool
resolveAdminTool(java.lang.String rootKey, java.lang.String toolPath)
Returns the admin tool corresponding to the given abstract path.void
setBaseToolPath(CmsWorkplace wp, java.lang.String baseToolPath)
Sets the base tool path.void
setCurrentRoot(CmsWorkplace wp, java.lang.String key)
Sets the current user's root key.void
setCurrentToolPath(CmsWorkplace wp, java.lang.String currentToolPath)
Sets the current tool path.
-
-
-
Field Detail
-
ADMINVIEW_ROOT_LOCATION
public static final java.lang.String ADMINVIEW_ROOT_LOCATION
Root location of the administration view.- See Also:
- Constant Field Values
-
HANDLERCLASS_PROPERTY
public static final java.lang.String HANDLERCLASS_PROPERTY
Property definition name to look for.- See Also:
- Constant Field Values
-
NAVBAR_SEPARATOR
public static final java.lang.String NAVBAR_SEPARATOR
Navigation bar separator (html code).- See Also:
- Constant Field Values
-
ROOT_SEPARATOR
public static final java.lang.String ROOT_SEPARATOR
Tool root separator.- See Also:
- Constant Field Values
-
ROOTKEY_DEFAULT
public static final java.lang.String ROOTKEY_DEFAULT
Key for the default tool root, if there is no configured root with this a key, a new one will be configured.- See Also:
- Constant Field Values
-
TOOLPATH_SEPARATOR
public static final java.lang.String TOOLPATH_SEPARATOR
Tool path separator.- See Also:
- Constant Field Values
-
VIEW_JSPPAGE_LOCATION
public static final java.lang.String VIEW_JSPPAGE_LOCATION
Location of the default admin view jsp page.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsToolManager
public CmsToolManager()
Default constructor.
-
-
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 elementtoolPath
- 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 elementtoolPath
- the tool pathparams
- 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)
Called by the
method.CmsWorkplaceManager.initialize(CmsObject)
- Parameters:
cms
- the admin cms context
-
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 pathwp
- 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
-
getCurrentRoot
public CmsToolRootHandler getCurrentRoot(CmsWorkplace wp)
Returns the current user's root handler.- Parameters:
wp
- the workplace context- Returns:
- the current user's root handler
-
getCurrentTool
public CmsTool getCurrentTool(CmsWorkplace wp)
Returns the current tool.- Parameters:
wp
- the workplace object- Returns:
- the current tool
-
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 objecttoolPath
- the abstract tool path- Returns:
- his parent
-
getToolHandlers
public java.util.List<CmsTool> getToolHandlers()
Returns a list with all registered tools.- Returns:
- list if
CmsTool
-
getToolRoots
public java.util.List<CmsToolRootHandler> getToolRoots()
Returns a list of tool roots.- Returns:
- a list of
CmsToolRootHandler
objects
-
getToolsForPath
public java.util.List<CmsTool> getToolsForPath(CmsWorkplace wp, java.lang.String baseTool, boolean includeSubtools)
Returns a list of all tools in the given path.- Parameters:
wp
- the workplace contextbaseTool
- the pathincludeSubtools
- if the tools in subfolders should be also returned- Returns:
- a list of
CmsTool
objects
-
getUserData
public CmsToolUserData getUserData(CmsWorkplace wp)
Returns the
object for a given user.CmsToolUserData
- Parameters:
wp
- the workplace object- Returns:
- the current user data
-
hasToolPathForUrl
public boolean hasToolPathForUrl(java.lang.String url)
Returnstrue
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 objectpagePath
- the path to the page to redirect toparams
- the parameters to send- Throws:
java.io.IOException
- in case of errors during forwardingjavax.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 objecttoolPath
- the path to the tool to redirect toparams
- the parameters to send- Throws:
java.io.IOException
- in case of errors during forwardingjavax.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 roottoolPath
- 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 objectbaseToolPath
- 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 contextkey
- 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 objectcurrentToolPath
- the current tool path to set
-
-