Class CmsWorkplace

  • Direct Known Subclasses:
    CmsToolDialog

    public abstract class CmsWorkplace
    extends java.lang.Object
    Master class for the JSP based workplace which provides default methods and session handling for all JSP workplace classes.

    Since:
    6.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsWorkplace​(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      Public constructor with JSP variables.
      CmsWorkplace​(CmsObject cms, javax.servlet.http.HttpSession session)
      Constructor in case no page context is available.
      CmsWorkplace​(CmsJspActionElement jsp)
      Public constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addMessages​(java.lang.String bundleName)
      Auxiliary method for initialization of messages.
      protected void addMessages​(CmsMessages messages)
      Auxiliary method for initialization of messages.
      java.lang.String allParamsAsHidden()
      Returns all parameters of the current workplace class as hidden field tags that can be inserted in a form.
      java.lang.String allParamsAsRequest()
      Returns all present request parameters as String.
      protected java.util.Map<java.lang.String,​java.lang.Object> allParamValues()
      Returns the values of all parameter methods of this workplace class instance.
      java.lang.String bodyEnd()
      Builds the end html of the body.
      java.lang.String bodyStart​(java.lang.String className)
      Builds the start html of the body.
      java.lang.String bodyStart​(java.lang.String className, java.lang.String parameters)
      Builds the start html of the body.
      java.lang.String buildSelect​(java.lang.String parameters, java.util.List<java.lang.String> options, java.util.List<java.lang.String> values, int selected)
      Generates a html select box out of the provided values.
      static java.lang.String buildSelect​(java.lang.String parameters, java.util.List<java.lang.String> options, java.util.List<java.lang.String> values, int selected, boolean useLineFeed)
      Generates a html select box out of the provided values.
      java.lang.String button​(java.lang.String href, java.lang.String target, java.lang.String image, java.lang.String label, int type)
      Generates a button for the OpenCms workplace.
      java.lang.String button​(java.lang.String href, java.lang.String target, java.lang.String image, java.lang.String label, int type, java.lang.String imagePath)
      Generates a button for the OpenCms workplace.
      java.lang.String buttonBar​(int segment)
      Returns the html for a button bar.
      java.lang.String buttonBar​(int segment, java.lang.String attributes)
      Returns the html for a button bar.
      java.lang.String buttonBarHorizontalLine()
      Generates a horizontal button bar separator line with maximum width.
      java.lang.String buttonBarLabel​(java.lang.String label)
      Generates a button bar label.
      java.lang.String buttonBarLabel​(java.lang.String label, java.lang.String className)
      Generates a button bar label.
      java.lang.String buttonBarLine​(int leftPixel, int rightPixel, java.lang.String className)
      Generates a variable button bar separator line.
      java.lang.String buttonBarLineSpacer​(int pixel)
      Generates a variable button bar separator line spacer.
      java.lang.String buttonBarSeparator​(int leftPixel, int rightPixel)
      Generates a button bar separator.
      java.lang.String buttonBarSpacer​(int width)
      Returns the html for an invisible spacer between button bar contents like buttons, labels, etc.
      java.lang.String buttonBarStartTab​(int leftPixel, int rightPixel)
      Generates a button bar starter tab.
      static boolean canEditPermissionsForRoles​(CmsObject cms, java.lang.String path)
      Checks if permissions for roles should be editable for the current user on the resource with the given path.
      void checkLock​(java.lang.String resource)
      Checks the lock state of the resource and locks it if the autolock feature is enabled.
      void checkLock​(java.lang.String resource, CmsLockType type)
      Checks the lock state of the resource and locks it if the autolock feature is enabled.
      protected void checkRole()
      Checks that the current user is a workplace user.
      protected java.lang.String decodeParamValue​(java.lang.String paramName, java.lang.String paramValue)
      Decodes an individual parameter value.
      void fillParamValues​(javax.servlet.http.HttpServletRequest request)
      Fills all class parameter values from the data provided in the current request.
      void fillParamValues​(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      First sets site and project in the workplace settings, then fills all class parameter values from the data provided in the current request.
      static java.lang.String generateCssStyle​(CmsObject cms)
      Returns the style sheets for the report.
      static java.lang.String generatePageEndExtended()
      Generates the footer for the extended report view.
      static java.lang.String generatePageEndSimple()
      Generates the footer for the simple report view.
      static java.lang.String generatePageStartExtended​(CmsObject cms, java.lang.String encoding)
      Generates the header for the extended report view.
      static java.lang.String generatePageStartSimple​(CmsWorkplace wp)
      Generates the header for the simple report view.
      java.lang.String getBroadcastMessageString()
      Returns the message String for the broadcast message alert of the workplace.
      CmsObject getCms()
      Returns the initialized cms object for the current user.
      java.lang.String getEncoding()
      Returns the current workplace encoding.
      java.lang.String getExplorerFileListFullUri()
      Returns the uri (including context path) to the explorer file list.
      java.lang.String getFrameSource​(java.lang.String frameName, java.lang.String uri)
      Returns the html for the frame name and source and stores this information in the workplace settings.
      CmsJspActionElement getJsp()
      Returns the JSP action element.
      java.util.Locale getLocale()
      Returns the current users workplace locale settings.
      CmsMacroResolver getMacroResolver()
      Returns the current used macro resolver instance.
      CmsMessages getMessages()
      Returns the current used message object.
      java.util.List<org.apache.commons.fileupload.FileItem> getMultiPartFileItems()
      Returns a list of FileItem instances parsed from the request, in the order that they were transmitted.
      protected java.util.Map<java.lang.String,​java.lang.String[]> getParameterMap()
      Returns the map of parameters read from the current request.
      java.lang.String getResourceUri()
      Returns the path to the workplace static resources.
      static java.lang.String getResourceUri​(java.lang.String resourceName)
      Returns the full Workplace resource path to the selected resource.
      javax.servlet.http.HttpSession getSession()
      Returns the current user http session.
      CmsWorkplaceSettings getSettings()
      Returns the current users workplace settings.
      static java.lang.String getSkinUri()
      Returns the path to the skin resources.
      static java.lang.String getStartSiteRoot​(CmsObject cms, CmsUserSettings userSettings)
      Returns the start site from the given user settings.
      static java.lang.String getStartSiteRoot​(CmsObject cms, CmsWorkplaceSettings settings)
      Returns the start site from the given workplace settings.
      static java.lang.String getStaticResourceUri​(java.lang.String resourceName)
      Returns the URI to static resources served from the class path.
      static java.lang.String getStaticResourceUri​(java.lang.String resourceName, java.lang.String versionInfo)
      Returns the URI to static resources served from the class path.
      java.lang.String getStyleUri​(java.lang.String filename)
      Returns the path to the cascading stylesheets.
      static java.lang.String getStyleUri​(CmsJspActionElement jsp)
      Returns the path to the cascading stylesheets.
      static java.lang.String getStyleUri​(CmsJspActionElement jsp, java.lang.String filename)
      Returns the path to the cascading stylesheets.
      static java.lang.String getTemporaryFileName​(java.lang.String resourceName)
      Returns the temporary file name for the given resource name.
      static java.lang.String getWorkplaceExplorerLink​(CmsObject cms, java.lang.String explorerRootPath)
      Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.
      static java.lang.String getWorkplaceExplorerLink​(CmsJspActionElement jsp, java.lang.String explorerRootPath)
      Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.
      static CmsWorkplaceSettings getWorkplaceSettings​(CmsObject cms, javax.servlet.http.HttpServletRequest req)
      Returns the workplace settings of the current user.
      java.lang.String htmlEnd()
      Builds the end html of the page.
      java.lang.String htmlStart​(java.lang.String title)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.
      protected void initMessages()
      Initializes the message object.
      boolean initSettings​(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      Sets site and project in the workplace settings with the request values of parameters PARAM_WP_SITE and PARAM_WP_PROJECT.
      protected void initTimeWarp​(CmsUserSettings settings, javax.servlet.http.HttpSession session)
      Sets the users time warp if configured and if the current timewarp setting is different or clears the current time warp setting if the user has no configured timewarp.
      static CmsWorkplaceSettings initUserSettings​(CmsObject cms, CmsWorkplaceSettings settings, boolean update)
      Updates the user settings in the given workplace settings for the current user, reading the user settings from the database if required.
      protected void initWorkplaceMembers​(CmsObject cms, javax.servlet.http.HttpSession session)
      Initializes this workplace class instance.
      protected void initWorkplaceMembers​(CmsJspActionElement jsp)
      Initializes this workplace class instance.
      protected abstract void initWorkplaceRequestValues​(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.
      static CmsWorkplaceSettings initWorkplaceSettings​(CmsObject cms, CmsWorkplaceSettings settings, boolean update)
      Updates the given workplace settings, also re-initializing the state of the Workplace to the users preferences (for example setting the startup site and project).
      boolean isForwarded()
      Returns the forwarded flag.
      boolean isHelpEnabled()
      Returns true if the online help for the users current workplace language is installed.
      boolean isSubElement()
      Returns true if the currently processed element is an included sub element.
      static boolean isTemporaryFile​(CmsResource resource)
      Returns true if the given resource is a temporary file.
      java.lang.String key​(java.lang.String keyName)
      Returns the localized resource string for a given message key, checking the workplace default resources and all module bundles.
      java.lang.String key​(java.lang.String keyName, java.lang.Object[] params)
      Returns the localized resource string for a given message key, with the provided replacement parameters.
      java.lang.String keyDefault​(java.lang.String keyName, java.lang.String defaultValue)
      Returns the localized resource string for the given message key, checking the workplace default resources and all module bundles.
      java.lang.String nullToEmpty​(java.lang.String value)
      Returns the empty String "" if the provided value is null, otherwise just returns the provided value.
      java.lang.String pageBody​(int segment, java.lang.String className, java.lang.String parameters)
      Builds the html of the body.
      java.lang.String pageHtml​(int segment, java.lang.String title)
      Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type.
      java.lang.String pageHtmlStyle​(int segment, java.lang.String title, java.lang.String stylesheet)
      Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type, allowing the selection of an individual style sheet.
      java.lang.String paramsAsHidden()
      Returns all initialized parameters of the current workplace class as hidden field tags that can be inserted in a form.
      java.lang.String paramsAsHidden​(java.util.Collection<java.lang.String> excludes)
      Returns all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form.
      java.util.Map<java.lang.String,​java.lang.String[]> paramsAsParameterMap()
      Returns all initialized parameters of the current workplace class in the form of a parameter map, i.e.
      java.lang.String paramsAsRequest()
      Returns all initialized parameters of the current workplace class as request parameters, i.e.
      protected java.util.Map<java.lang.String,​java.lang.Object> paramValues()
      Returns the values of all parameter methods of this workplace class instance.
      java.lang.String resolveMacros​(java.lang.String input)
      Resolves the macros in the given String and replaces them by their localized keys.
      void sendCmsRedirect​(java.lang.String location)
      Sends a http redirect to the specified URI in the OpenCms VFS.
      void sendForward​(java.lang.String location, java.util.Map<java.lang.String,​java.lang.String[]> params)
      Forwards to the specified location in the OpenCms VFS.
      void setForwarded​(boolean forwarded)
      Sets the forwarded flag.
      java.lang.String shortKey​(java.lang.String keyName)
      Get a localized short key value for the workplace.
      protected java.lang.String substituteSiteTitle​(java.lang.String title)
      Replaces the site title, if necessary.
      static java.lang.String substituteSiteTitleStatic​(java.lang.String title, java.util.Locale locale)
      Substitutes the site title.
      protected void switchToCurrentProject()
      Helper method to change back from the temporary project to the current project.
      protected CmsUUID switchToTempProject()
      Helper method to change the current project to the temporary file project.
      static void updateUserPreferences​(CmsObject cms, javax.servlet.http.HttpServletRequest req)
      Updates the user preferences after changes have been made.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CmsWorkplace

        public CmsWorkplace​(CmsObject cms,
                            javax.servlet.http.HttpSession session)
        Constructor in case no page context is available.

        Parameters:
        cms - the current user context
        session - the session
      • CmsWorkplace

        public CmsWorkplace​(javax.servlet.jsp.PageContext context,
                            javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse res)
        Public constructor with JSP variables.

        Parameters:
        context - the JSP page context
        req - the JSP request
        res - the JSP response
    • Method Detail

      • buildSelect

        public static java.lang.String buildSelect​(java.lang.String parameters,
                                                   java.util.List<java.lang.String> options,
                                                   java.util.List<java.lang.String> values,
                                                   int selected,
                                                   boolean useLineFeed)
        Generates a html select box out of the provided values.

        Parameters:
        parameters - a string that will be inserted into the initial select tag, if null no parameters will be inserted
        options - the options
        values - the option values, if null the select will have no value attributes
        selected - the index of the pre-selected option, if -1 no option is pre-selected
        useLineFeed - if true, adds some formatting "\n" to the output String
        Returns:
        a String representing a html select box
      • canEditPermissionsForRoles

        public static boolean canEditPermissionsForRoles​(CmsObject cms,
                                                         java.lang.String path)
        Checks if permissions for roles should be editable for the current user on the resource with the given path.

        Parameters:
        cms - the CMS context
        path - the path of a resource
        Returns:
        true if permissions for roles should be editable for the current user on the resource with the given path
      • generateCssStyle

        public static java.lang.String generateCssStyle​(CmsObject cms)
        Returns the style sheets for the report.

        Parameters:
        cms - the current users context
        Returns:
        the style sheets for the report
      • generatePageEndExtended

        public static java.lang.String generatePageEndExtended()
        Generates the footer for the extended report view.

        Returns:
        html code
      • generatePageEndSimple

        public static java.lang.String generatePageEndSimple()
        Generates the footer for the simple report view.

        Returns:
        html code
      • generatePageStartExtended

        public static java.lang.String generatePageStartExtended​(CmsObject cms,
                                                                 java.lang.String encoding)
        Generates the header for the extended report view.

        Parameters:
        cms - the current users context
        encoding - the encoding string
        Returns:
        html code
      • generatePageStartSimple

        public static java.lang.String generatePageStartSimple​(CmsWorkplace wp)
        Generates the header for the simple report view.

        Parameters:
        wp - the workplace instance
        Returns:
        html code
      • getResourceUri

        public static java.lang.String getResourceUri​(java.lang.String resourceName)
        Returns the full Workplace resource path to the selected resource.

        Parameters:
        resourceName - the name of the resource to get the resource path for
        Returns:
        the full Workplace resource path to the selected resource
      • getSkinUri

        public static java.lang.String getSkinUri()
        Returns the path to the skin resources.

        Returns:
        the path to the skin resources
      • getStartSiteRoot

        public static java.lang.String getStartSiteRoot​(CmsObject cms,
                                                        CmsUserSettings userSettings)
        Returns the start site from the given user settings.

        Parameters:
        cms - the cms context
        userSettings - the user settings
        Returns:
        the start site root
      • getStartSiteRoot

        public static java.lang.String getStartSiteRoot​(CmsObject cms,
                                                        CmsWorkplaceSettings settings)
        Returns the start site from the given workplace settings.

        Parameters:
        cms - the cms context
        settings - the workplace settings
        Returns:
        the start site root
      • getStaticResourceUri

        public static java.lang.String getStaticResourceUri​(java.lang.String resourceName)
        Returns the URI to static resources served from the class path.

        Parameters:
        resourceName - the resource name
        Returns:
        the URI
      • getStaticResourceUri

        public static java.lang.String getStaticResourceUri​(java.lang.String resourceName,
                                                            java.lang.String versionInfo)
        Returns the URI to static resources served from the class path.

        Parameters:
        resourceName - the resource name
        versionInfo - add an additional version info parameter to avoid browser caching issues
        Returns:
        the URI
      • getStyleUri

        public static java.lang.String getStyleUri​(CmsJspActionElement jsp)
        Returns the path to the cascading stylesheets.

        Parameters:
        jsp - the JSP context
        Returns:
        the path to the cascading stylesheets
      • getStyleUri

        public static java.lang.String getStyleUri​(CmsJspActionElement jsp,
                                                   java.lang.String filename)
        Returns the path to the cascading stylesheets.

        Parameters:
        jsp - the JSP context
        filename - the name of the stylesheet
        Returns:
        the path to the cascading stylesheets
      • getTemporaryFileName

        public static java.lang.String getTemporaryFileName​(java.lang.String resourceName)
        Returns the temporary file name for the given resource name.

        To create a temporary file name of a resource name, the prefix char '~' (tilde) is added to the file name after all parent folder names have been removed.

        Parameters:
        resourceName - the resource name to return the temporary file name for
        Returns:
        the temporary file name for the given resource name
        See Also:
        CmsResource.isTemporaryFileName(String), isTemporaryFile(CmsResource)
      • getWorkplaceExplorerLink

        public static java.lang.String getWorkplaceExplorerLink​(CmsJspActionElement jsp,
                                                                java.lang.String explorerRootPath)
        Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.

        Parameters:
        jsp - needed for link functionality.
        explorerRootPath - a root relative folder link (has to end with '/').
        Returns:
        a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.
      • getWorkplaceExplorerLink

        public static java.lang.String getWorkplaceExplorerLink​(CmsObject cms,
                                                                java.lang.String explorerRootPath)
        Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.

        Parameters:
        cms - the cms object
        explorerRootPath - a root relative folder link (has to end with '/').
        Returns:
        a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the site of the given explorerRootPath and show the folder given in the explorerRootPath.
      • getWorkplaceSettings

        public static CmsWorkplaceSettings getWorkplaceSettings​(CmsObject cms,
                                                                javax.servlet.http.HttpServletRequest req)
        Returns the workplace settings of the current user.

        Parameters:
        cms - the cms context
        req - the request
        Returns:
        the workplace settings or null if the user is not logged in
      • substituteSiteTitleStatic

        public static java.lang.String substituteSiteTitleStatic​(java.lang.String title,
                                                                 java.util.Locale locale)
        Substitutes the site title.

        Parameters:
        title - the raw site title
        locale - the localel
        Returns:
        the locale specific site title
      • updateUserPreferences

        public static void updateUserPreferences​(CmsObject cms,
                                                 javax.servlet.http.HttpServletRequest req)
        Updates the user preferences after changes have been made.

        Parameters:
        cms - the current cms context
        req - the current http request
      • allParamsAsHidden

        public java.lang.String allParamsAsHidden()
        Returns all parameters of the current workplace class as hidden field tags that can be inserted in a form.

        Returns:
        all parameters of the current workplace class as hidden field tags that can be inserted in a html form
      • allParamsAsRequest

        public java.lang.String allParamsAsRequest()
        Returns all present request parameters as String.

        The String is formatted as a parameter String (param1=val1&param2=val2) with UTF-8 encoded values.

        Returns:
        all present request parameters as String
      • bodyEnd

        public java.lang.String bodyEnd()
        Builds the end html of the body.

        Returns:
        the end html of the body
      • bodyStart

        public java.lang.String bodyStart​(java.lang.String className)
        Builds the start html of the body.

        Parameters:
        className - optional class attribute to add to the body tag
        Returns:
        the start html of the body
      • bodyStart

        public java.lang.String bodyStart​(java.lang.String className,
                                          java.lang.String parameters)
        Builds the start html of the body.

        Parameters:
        className - optional class attribute to add to the body tag
        parameters - optional parameters to add to the body tag
        Returns:
        the start html of the body
      • buildSelect

        public java.lang.String buildSelect​(java.lang.String parameters,
                                            java.util.List<java.lang.String> options,
                                            java.util.List<java.lang.String> values,
                                            int selected)
        Generates a html select box out of the provided values.

        Parameters:
        parameters - a string that will be inserted into the initial select tag, if null no parameters will be inserted
        options - the options
        values - the option values, if null the select will have no value attributes
        selected - the index of the pre-selected option, if -1 no option is pre-selected
        Returns:
        a formatted html String representing a html select box
      • button

        public java.lang.String button​(java.lang.String href,
                                       java.lang.String target,
                                       java.lang.String image,
                                       java.lang.String label,
                                       int type)
        Generates a button for the OpenCms workplace.

        Parameters:
        href - the href link for the button, if none is given the button will be disabled
        target - the href link target for the button, if none is given the target will be same window
        image - the image name for the button, skin path will be automattically added as prefix
        label - the label for the text of the button
        type - 0: image only (default), 1: image and text, 2: text only
        Returns:
        a button for the OpenCms workplace
      • button

        public java.lang.String button​(java.lang.String href,
                                       java.lang.String target,
                                       java.lang.String image,
                                       java.lang.String label,
                                       int type,
                                       java.lang.String imagePath)
        Generates a button for the OpenCms workplace.

        Parameters:
        href - the href link for the button, if none is given the button will be disabled
        target - the href link target for the button, if none is given the target will be same window
        image - the image name for the button, skin path will be automattically added as prefix
        label - the label for the text of the button
        type - 0: image only (default), 1: image and text, 2: text only
        imagePath - the path to the image
        Returns:
        a button for the OpenCms workplace
      • buttonBar

        public java.lang.String buttonBar​(int segment)
        Returns the html for a button bar.

        Parameters:
        segment - the HTML segment (START / END)
        Returns:
        a button bar html start / end segment
      • buttonBar

        public java.lang.String buttonBar​(int segment,
                                          java.lang.String attributes)
        Returns the html for a button bar.

        Parameters:
        segment - the HTML segment (START / END)
        attributes - optional attributes for the table tag
        Returns:
        a button bar html start / end segment
      • buttonBarHorizontalLine

        public java.lang.String buttonBarHorizontalLine()
        Generates a horizontal button bar separator line with maximum width.

        Returns:
        a horizontal button bar separator line
      • buttonBarLabel

        public java.lang.String buttonBarLabel​(java.lang.String label)
        Generates a button bar label.

        Parameters:
        label - the label to show
        Returns:
        a button bar label
      • buttonBarLabel

        public java.lang.String buttonBarLabel​(java.lang.String label,
                                               java.lang.String className)
        Generates a button bar label.

        Parameters:
        label - the label to show
        className - the css class name for the formatting
        Returns:
        a button bar label
      • buttonBarLine

        public java.lang.String buttonBarLine​(int leftPixel,
                                              int rightPixel,
                                              java.lang.String className)
        Generates a variable button bar separator line.

        Parameters:
        leftPixel - the amount of pixel left to the line
        rightPixel - the amount of pixel right to the line
        className - the css class name for the formatting
        Returns:
        a variable button bar separator line
      • buttonBarLineSpacer

        public java.lang.String buttonBarLineSpacer​(int pixel)
        Generates a variable button bar separator line spacer.

        Parameters:
        pixel - the amount of pixel space
        Returns:
        a variable button bar separator line spacer
      • buttonBarSeparator

        public java.lang.String buttonBarSeparator​(int leftPixel,
                                                   int rightPixel)
        Generates a button bar separator.

        Parameters:
        leftPixel - the amount of pixel left to the separator
        rightPixel - the amount of pixel right to the separator
        Returns:
        a button bar separator
      • buttonBarSpacer

        public java.lang.String buttonBarSpacer​(int width)
        Returns the html for an invisible spacer between button bar contents like buttons, labels, etc.

        Parameters:
        width - the width of the invisible spacer
        Returns:
        the html for the invisible spacer
      • buttonBarStartTab

        public java.lang.String buttonBarStartTab​(int leftPixel,
                                                  int rightPixel)
        Generates a button bar starter tab.

        Parameters:
        leftPixel - the amount of pixel left to the starter
        rightPixel - the amount of pixel right to the starter
        Returns:
        a button bar starter tab
      • checkLock

        public void checkLock​(java.lang.String resource)
                       throws CmsException
        Checks the lock state of the resource and locks it if the autolock feature is enabled.

        Parameters:
        resource - the resource name which is checked
        Throws:
        CmsException - if reading or locking the resource fails
      • fillParamValues

        public void fillParamValues​(CmsWorkplaceSettings settings,
                                    javax.servlet.http.HttpServletRequest request)
        First sets site and project in the workplace settings, then fills all class parameter values from the data provided in the current request.

        Parameters:
        settings - the workplace settings
        request - the current request
      • fillParamValues

        public void fillParamValues​(javax.servlet.http.HttpServletRequest request)
        Fills all class parameter values from the data provided in the current request.

        All methods that start with "setParam" are possible candidates to be automatically filled. The remaining part of the method name is converted to lower case. Then a parameter of this name is searched in the request parameters. If the parameter is found, the "setParam" method is automatically invoked by reflection with the value of the parameter.

        Parameters:
        request - the current JSP request
      • getBroadcastMessageString

        public java.lang.String getBroadcastMessageString()
        Returns the message String for the broadcast message alert of the workplace.

        Caution: returns the pure message String (not escaped) or null, if no message is pending.

        Returns:
        the message String for the broadcast message alert of the workplace
      • getCms

        public CmsObject getCms()
        Returns the initialized cms object for the current user.

        Returns:
        the initialized cms object for the current user
      • getEncoding

        public java.lang.String getEncoding()
        Returns the current workplace encoding.

        Returns:
        the current workplace encoding
      • getExplorerFileListFullUri

        public java.lang.String getExplorerFileListFullUri()
        Returns the uri (including context path) to the explorer file list.

        Returns:
        the uri (including context path) to the explorer file list
      • getFrameSource

        public java.lang.String getFrameSource​(java.lang.String frameName,
                                               java.lang.String uri)
        Returns the html for the frame name and source and stores this information in the workplace settings.

        Parameters:
        frameName - the name of the frame
        uri - the absolute path of the frame
        Returns:
        the html for the frame name and source
      • getLocale

        public java.util.Locale getLocale()
        Returns the current users workplace locale settings.

        Returns:
        the current users workplace locale setting
      • getMessages

        public CmsMessages getMessages()
        Returns the current used message object.

        Returns:
        the current used message object
      • getMultiPartFileItems

        public java.util.List<org.apache.commons.fileupload.FileItem> getMultiPartFileItems()
        Returns a list of FileItem instances parsed from the request, in the order that they were transmitted.

        This list is automatically initialized from the createParameterMapFromMultiPart(HttpServletRequest) method.

        Returns:
        list of FileItem instances parsed from the request, in the order that they were transmitted
      • getResourceUri

        public java.lang.String getResourceUri()
        Returns the path to the workplace static resources.

        Workplaces static resources are images, css files etc. These are exported during the installation of OpenCms, and are usually only read from this exported location to avoid the overhaead of accessing the database later.

        Returns:
        the path to the workplace static resources
      • getSession

        public javax.servlet.http.HttpSession getSession()
        Returns the current user http session.

        Returns:
        the current user http session
      • getStyleUri

        public java.lang.String getStyleUri​(java.lang.String filename)
        Returns the path to the cascading stylesheets.

        Parameters:
        filename - the name of the stylesheet
        Returns:
        the path to the cascading stylesheets
      • htmlEnd

        public java.lang.String htmlEnd()
        Builds the end html of the page.

        Returns:
        the end html of the page
      • htmlStart

        public java.lang.String htmlStart​(java.lang.String title)
        Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

        Parameters:
        title - the content for the title tag
        Returns:
        the start html of the page
      • initSettings

        public boolean initSettings​(CmsWorkplaceSettings settings,
                                    javax.servlet.http.HttpServletRequest request)
        Sets site and project in the workplace settings with the request values of parameters PARAM_WP_SITE and PARAM_WP_PROJECT.

        Parameters:
        settings - the workplace settings
        request - the current request
        Returns:
        true, if a reload of the main body frame is required
      • isForwarded

        public boolean isForwarded()
        Returns the forwarded flag.

        Returns:
        the forwarded flag
      • isHelpEnabled

        public boolean isHelpEnabled()
        Returns true if the online help for the users current workplace language is installed.

        Returns:
        true if the online help for the users current workplace language is installed
      • isSubElement

        public boolean isSubElement()
        Returns true if the currently processed element is an included sub element.

        Returns:
        true if the currently processed element is an included sub element
      • key

        public java.lang.String key​(java.lang.String keyName)
        Returns the localized resource string for a given message key, checking the workplace default resources and all module bundles.

        If the key was not found, the return value is "??? " + keyName + " ???".

        If the key starts with "help." and is not found, the value "index.html" is returned.

        Parameters:
        keyName - the key for the desired string
        Returns:
        the resource string for the given key
        See Also:
        CmsMessages.key(String)
      • key

        public java.lang.String key​(java.lang.String keyName,
                                    java.lang.Object[] params)
        Returns the localized resource string for a given message key, with the provided replacement parameters.

        If the key was found in the bundle, it will be formatted using a MessageFormat using the provided parameters.

        If the key was not found in the bundle, the return value is "??? " + keyName + " ???". This will also be returned if the bundle was not properly initialized first.

        Parameters:
        keyName - the key for the desired string
        params - the parameters to use for formatting
        Returns:
        the resource string for the given key
        See Also:
        CmsMessages.key(String)
      • keyDefault

        public java.lang.String keyDefault​(java.lang.String keyName,
                                           java.lang.String defaultValue)
        Returns the localized resource string for the given message key, checking the workplace default resources and all module bundles.

        If the key was not found, the provided default value is returned.

        Parameters:
        keyName - the key for the desired string
        defaultValue - the default value in case the key does not exist in the bundle
        Returns:
        the resource string for the given key it it exists, or the given default if not
        See Also:
        CmsMessages.keyDefault(String, String)
      • nullToEmpty

        public java.lang.String nullToEmpty​(java.lang.String value)
        Returns the empty String "" if the provided value is null, otherwise just returns the provided value.

        Use this method in forms if a getParamXXX method is used, but a String (not null) is required.

        Parameters:
        value - the String to check
        Returns:
        the empty String "" if the provided value is null, otherwise just returns the provided value
      • pageBody

        public java.lang.String pageBody​(int segment,
                                         java.lang.String className,
                                         java.lang.String parameters)
        Builds the html of the body.

        Parameters:
        segment - the HTML segment (START / END)
        className - optional class attribute to add to the body tag
        parameters - optional parameters to add to the body tag
        Returns:
        the html of the body
      • pageHtml

        public java.lang.String pageHtml​(int segment,
                                         java.lang.String title)
        Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type.

        Parameters:
        segment - the HTML segment (START / END)
        title - the title of the page, if null no title tag is inserted
        Returns:
        the default html for a workplace page
      • pageHtmlStyle

        public java.lang.String pageHtmlStyle​(int segment,
                                              java.lang.String title,
                                              java.lang.String stylesheet)
        Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type, allowing the selection of an individual style sheet.

        Parameters:
        segment - the HTML segment (START / END)
        title - the title of the page, if null no title tag is inserted
        stylesheet - the used style sheet, if null the default stylesheet 'workplace.css' is inserted
        Returns:
        the default html for a workplace page
      • paramsAsHidden

        public java.lang.String paramsAsHidden()
        Returns all initialized parameters of the current workplace class as hidden field tags that can be inserted in a form.

        Returns:
        all initialized parameters of the current workplace class as hidden field tags that can be inserted in a html form
      • paramsAsHidden

        public java.lang.String paramsAsHidden​(java.util.Collection<java.lang.String> excludes)
        Returns all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form.

        Parameters:
        excludes - the parameters to exclude
        Returns:
        all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form
      • paramsAsParameterMap

        public java.util.Map<java.lang.String,​java.lang.String[]> paramsAsParameterMap()
        Returns all initialized parameters of the current workplace class in the form of a parameter map, i.e. the values are arrays.

        Returns:
        all initialized parameters of the current workplace class in the form of a parameter map
      • paramsAsRequest

        public java.lang.String paramsAsRequest()
        Returns all initialized parameters of the current workplace class as request parameters, i.e. in the form key1=value1&key2=value2 etc.
        Returns:
        all initialized parameters of the current workplace class as request parameters
      • resolveMacros

        public java.lang.String resolveMacros​(java.lang.String input)
        Resolves the macros in the given String and replaces them by their localized keys.

        The following macro contexts are available in the Workplace:

        • Macros based on the current users OpenCms context (obtained from the current CmsObject).
        • Localized key macros (obtained from the current CmsMessages).
        • Macros from the current JSP page context (obtained by getJsp()).
        Parameters:
        input - the input String containing the macros
        Returns:
        the resolved String
        See Also:
        CmsMacroResolver.resolveMacros(String)
      • sendCmsRedirect

        public void sendCmsRedirect​(java.lang.String location)
                             throws java.io.IOException
        Sends a http redirect to the specified URI in the OpenCms VFS.

        Parameters:
        location - the location the response is redirected to
        Throws:
        java.io.IOException - in case redirection fails
      • sendForward

        public void sendForward​(java.lang.String location,
                                java.util.Map<java.lang.String,​java.lang.String[]> params)
                         throws java.io.IOException,
                                javax.servlet.ServletException
        Forwards to the specified location in the OpenCms VFS.

        Parameters:
        location - the location the response is redirected to
        params - the map of parameters to use for the forwarded request
        Throws:
        java.io.IOException - in case the forward fails
        javax.servlet.ServletException - in case the forward fails
      • setForwarded

        public void setForwarded​(boolean forwarded)
        Sets the forwarded flag.

        Parameters:
        forwarded - the forwarded flag to set
      • shortKey

        public java.lang.String shortKey​(java.lang.String keyName)
        Get a localized short key value for the workplace.

        Parameters:
        keyName - name of the key
        Returns:
        a localized short key value
      • addMessages

        protected void addMessages​(java.lang.String bundleName)
        Auxiliary method for initialization of messages.

        Parameters:
        bundleName - the resource bundle name to add
      • allParamValues

        protected java.util.Map<java.lang.String,​java.lang.Object> allParamValues()
        Returns the values of all parameter methods of this workplace class instance.

        Returns:
        the values of all parameter methods of this workplace class instance
      • decodeParamValue

        protected java.lang.String decodeParamValue​(java.lang.String paramName,
                                                    java.lang.String paramValue)
        Decodes an individual parameter value.

        In special cases some parameters might require a different-from-default encoding. This is the case if the content of the parameter was encoded using the JavaScript encodeURIComponent() method on the client, which always encodes in UTF-8.

        Parameters:
        paramName - the name of the parameter
        paramValue - the unencoded value of the parameter
        Returns:
        the encoded value of the parameter
      • getParameterMap

        protected java.util.Map<java.lang.String,​java.lang.String[]> getParameterMap()
        Returns the map of parameters read from the current request.

        This method will also handle parameters from forms of type multipart/form-data.

        Returns:
        the map of parameters read from the current request
      • initTimeWarp

        protected void initTimeWarp​(CmsUserSettings settings,
                                    javax.servlet.http.HttpSession session)
        Sets the users time warp if configured and if the current timewarp setting is different or clears the current time warp setting if the user has no configured timewarp.

        Timwarping is controlled by the session attribute CmsContextInfo.ATTRIBUTE_REQUEST_TIME with a value of type Long.

        Parameters:
        settings - the user settings which are configured via the preferences dialog
        session - the session of the user
      • initWorkplaceMembers

        protected void initWorkplaceMembers​(CmsJspActionElement jsp)
        Initializes this workplace class instance.

        This method can be used in case there a workplace class was generated using Class.forName(java.lang.String) to initialize the class members.

        Parameters:
        jsp - the initialized JSP context
      • initWorkplaceMembers

        protected void initWorkplaceMembers​(CmsObject cms,
                                            javax.servlet.http.HttpSession session)
        Initializes this workplace class instance.

        Parameters:
        cms - the user context
        session - the session
      • initWorkplaceRequestValues

        protected abstract void initWorkplaceRequestValues​(CmsWorkplaceSettings settings,
                                                           javax.servlet.http.HttpServletRequest request)
        Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.

        Parameters:
        settings - the workplace settings
        request - the current request
      • paramValues

        protected java.util.Map<java.lang.String,​java.lang.Object> paramValues()
        Returns the values of all parameter methods of this workplace class instance.

        Returns:
        the values of all parameter methods of this workplace class instance
      • substituteSiteTitle

        protected java.lang.String substituteSiteTitle​(java.lang.String title)
        Replaces the site title, if necessary.

        Parameters:
        title - the site title
        Returns:
        the new site title
      • switchToTempProject

        protected CmsUUID switchToTempProject()
                                       throws CmsException
        Helper method to change the current project to the temporary file project.

        The id of the old project is stored in a member variable to switch back.

        Returns:
        the id of the tempfileproject
        Throws:
        CmsException - if getting the tempfileproject id fails