Class CmsLock

java.lang.Object
org.opencms.workplace.CmsWorkplace
org.opencms.workplace.tools.CmsToolDialog
org.opencms.workplace.CmsDialog
org.opencms.workplace.CmsMultiDialog
org.opencms.workplace.commons.CmsLock
All Implemented Interfaces:
org.opencms.configuration.I_CmsConfigurationParameterHandler, org.opencms.workplace.I_CmsDialogHandler

public class CmsLock extends CmsMultiDialog implements org.opencms.workplace.I_CmsDialogHandler
Creates the dialogs for locking, unlocking or steal lock operations on a resource.

The following files use this class:

  • /commons/lock_standard.jsp
  • /commons/lockchange_standard.jsp
  • /commons/unlock_standard.jsp
  • /commons/locks.jsp

Since:
6.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value for the action: confirmed.
    static final String
    Request parameter value for the action: submit form without user interaction.
    static final String
    The dialog type: lock a resource.
    static final String
    The dialog type: Steal a lock.
    static final String
    The dialog type: locked subresources.
    static final String
    The dialog type: unlock a resource.
    static final String
    Request parameter name for the 'include unpublished related resources' flag.
    static final String
    Request parameter name for the project id.
    static final String
    Request parameter name for the publishsiblings parameter.
    static final String
    Request parameter name for the 'show own locked resources' flag.
    static final String
    Request parameter name for the source dialog uri.
    static final String
    Request parameter name for the subresources parameter.
    static final int
    Type of the operation which is performed: lock resource.
    static final int
    Type of the operation which is performed: steal a lock.
    static final int
    Type of the operation which is performed: locked subresources.
    static final int
    Type of the operation which is performed: unlock resource.
    static final String
    The lock dialog URI.
    static final String
    The steal lock dialog URI.
    static final String
    The locks dialog URI.
    static final String
    The unlock dialog URI.

    Fields inherited from class org.opencms.workplace.CmsMultiDialog

    DELIMITER_RESOURCES

    Fields inherited from class org.opencms.workplace.CmsDialog

    ACTION_CANCEL, ACTION_CLOSEPOPUP, ACTION_CLOSEPOPUP_SAVE, ACTION_CONFIRMED, ACTION_CONTINUE, ACTION_DEFAULT, ACTION_LOCKS_CONFIRMED, ACTION_OK, ACTION_REPORT_BEGIN, ACTION_REPORT_END, ACTION_REPORT_UPDATE, ACTION_SET, ACTION_WAIT, ATTRIBUTE_THROWABLE, BUTTON_ADVANCED, BUTTON_BACK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_CONTINUE, BUTTON_DETAILS, BUTTON_DISCARD, BUTTON_EDIT, BUTTON_OK, BUTTON_OK_NO_SUBMIT, BUTTON_SET, DIALOG_BACK, DIALOG_CANCEL, DIALOG_CONFIRMED, DIALOG_CONTINUE, DIALOG_INITIAL, DIALOG_LOCKS_CONFIRMED, DIALOG_OK, DIALOG_SET, DIALOG_WAIT, PARAM_ACTION, PARAM_ACTION_VALUE_FOR_CHANGED_INDEX, PARAM_CLOSELINK, PARAM_DIALOGTYPE, PARAM_ERRORSTACK, PARAM_FILE, PARAM_FRAMENAME, PARAM_ISPOPUP, PARAM_LOCK, PARAM_MESSAGE, PARAM_ORIGINALPARAMS, PARAM_PREACTIONDONE, PARAM_REDIRECT, PARAM_RESOURCE, PARAM_TARGET, PARAM_THREAD, PARAM_THREAD_HASNEXT, PARAM_TITLE, REPORT_BEGIN, REPORT_END, REPORT_UPDATE

    Fields inherited from class org.opencms.workplace.tools.CmsToolDialog

    PARAM_ADMIN_PROJECT, PARAM_BASE, PARAM_FORCE, PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW

    Fields inherited from class org.opencms.workplace.CmsWorkplace

    DEBUG, DEFAULT_DATE_STRING, DEFAULT_LANGUAGE, DEFAULT_LOCALE, DIALOG_PATH_COMMON, FILE_DIALOG_CLOSE, FILE_DIALOG_SCREEN_CONFIRM, FILE_DIALOG_SCREEN_ERROR, FILE_DIALOG_SCREEN_ERRORPAGE, FILE_DIALOG_SCREEN_WAIT, FILE_EXPLORER_FILELIST, FILE_REPORT_OUTPUT, HTML_END, HTML_START, INPUT_DEFAULT, INPUT_NONE, JSP_WORKPLACE_URI, PARAM_DIRECTPUBLISH, PARAM_MODELFILE, PARAM_NEWRESOURCETYPE, PARAM_RELATEDRESOURCES, PARAM_RESOURCELIST, PARAM_WP_EXPLORER_RESOURCE, PARAM_WP_PROJECT, PARAM_WP_SITE, PARAM_WP_START, PARAM_WP_VIEW, PATH_DIALOGS, PATH_WORKPLACE, REQUEST_ATTRIBUTE_MULTIPART, REQUEST_ATTRIBUTE_RELOADTREE, RES_PATH_FILETYPES, RFS_PATH_RESOURCES, SESSION_WORKPLACE_CLASS, VFS_DIR_DEFAULTBODIES, VFS_DIR_TEMPLATES, VFS_PATH_COMMONS, VFS_PATH_EDITORS, VFS_PATH_GALLERIES, VFS_PATH_LOCALES, VFS_PATH_MODELDIALOG, VFS_PATH_MODULES, VFS_PATH_NEWRESOURCEDIALOG, VFS_PATH_RESOURCES, VFS_PATH_SITES, VFS_PATH_SYSTEM, VFS_PATH_VIEWS, VFS_PATH_WORKPLACE, VIEW_ADMIN, VIEW_DIRECT_EDIT, VIEW_EXPLORER, VIEW_GALLERY, VIEW_LIST, VIEW_WORKPLACE

    Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler

    ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor needed for dialog handler implementation.
    CmsLock(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
    Public constructor with JSP variables.
    CmsLock(org.opencms.jsp.CmsJspActionElement jsp)
    Public constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Performs the lock/unlock operation, will be called by the JSP page.
    void
    addConfigurationParameter(String paramName, String paramValue)
     
    Returns the html code to build the dialogs default confirmation message js.
    Returns the html code to include the needed js code.
    static String
    buildLockDialog(org.opencms.workplace.CmsDialog dialog)
    Returns the html code to build the lock dialog.
    static String
    buildLockDialog(org.opencms.workplace.CmsDialog dialog, org.opencms.lock.CmsLockFilter nonBlockingFilter, org.opencms.lock.CmsLockFilter blockingFilter, int hiddenTimeout, boolean includeRelated)
    Returns the html code to build the lock dialog.
    Returns the html code to build the lock request.
    buildLockRequest(int hiddenTimeout, boolean includeRelated)
    Returns the html code to build the lock request.
    Returns the report of all locked subresources.
    Builds the necessary button row.
    org.opencms.lock.CmsLockFilter
    Returns the filter to get all blocking locks.
    Returns locked resources that do not belong to the current user.
    int
    Returns the number of blocking locks.
    org.opencms.configuration.CmsParameterConfiguration
     
    getConfirmationMessage(boolean state)
    Returns the confirmation message.
    static int
    getDialogAction(org.opencms.file.CmsObject cms)
    Determines if the resource should be locked, unlocked or if the lock should be stolen.
     
    getDialogUri(String resource, org.opencms.jsp.CmsJspActionElement jsp)
     
    Returns all the locked Resources.
    org.opencms.lock.CmsLockFilter
    Returns the filter to get all non blocking locks.
    Returns the 'include unpublished related resources' parameter value.
    Returns the project id parameter value.
    Returns the 'show own locked resources' parameter value.
    void
     
    protected void
    initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
     
    protected boolean
    Performs the lock/unlock/steal lock operation.
    protected void
    performSingleResourceOperation(String resourceName, int dialogAction)
    Performs the lock state operation on a single resource.
    void
    setBlockingFilter(org.opencms.lock.CmsLockFilter blockingFilter)
    Sets the filter to get all blocking locks.
    void
    setNonBlockingFilter(org.opencms.lock.CmsLockFilter nonBlockingFilter)
    Sets the filter to get all non blocking locks.
    void
    setParamIncluderelated(String paramIncluderelated)
    Sets the 'include unpublished related resources' parameter value.
    void
    Sets the project id parameter value.
    void
    setParamShowownlocks(String paramShowownlocks)
    Sets the 'show own locked resources' parameter value.
    boolean
    Determines whether to show the lock dialog depending on the users settings and the dilaog type.

    Methods inherited from class org.opencms.workplace.CmsDialog

    actionCloseDialog, appendDelimiter, buildAjaxResultContainer, buildAjaxWaitMessage, buildLockAdditionalOptions, buildLockConfirmationMessageJS, checkResourcePermissions, computeCurrentFolder, dialog, dialogBlock, dialogBlockEnd, dialogBlockStart, dialogButtonRow, dialogButtonRowEnd, dialogButtonRowStart, dialogButtons, dialogButtonsClose, dialogButtonsClose, dialogButtonsCloseDetails, dialogButtonsHtml, dialogButtonsOk, dialogButtonsOk, dialogButtonsOkCancel, dialogButtonsOkCancel, dialogButtonsOkCancelAdvanced, dialogButtonsSetOkCancel, dialogContent, dialogContentEnd, dialogContentStart, dialogEnd, dialogHead, dialogHorizontalSpacer, dialogLockButtons, dialogRow, dialogRowEnd, dialogRowStart, dialogScriptSubmit, dialogSeparator, dialogSpacer, dialogStart, dialogStart, dialogSubheadline, dialogToggleStart, dialogWhiteBox, dialogWhiteBoxEnd, dialogWhiteBoxStart, getAction, getAdministrationBackLink, getCancelAction, getDialogRealUri, getDialogUri, getOnlineHelpUriCustom, getParamAction, getParamCloseLink, getParamDialogtype, getParamFramename, getParamIsPopup, getParamMessage, getParamOriginalParams, getParamPreActionDone, getParamRedirect, getParamResource, getParamTitle, getState, hasCorrectLockstate, hasSiblings, htmlStart, htmlStart, htmlStart, htmlStartStyle, includeErrorpage, initCmsDialog, isPopup, isPreEditor, openLaunchpad, openWorkplaceLink, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamOriginalParams, setParamPreActionDone, setParamRedirect, setParamTitle

    Methods inherited from class org.opencms.workplace.tools.CmsToolDialog

    computeUpLevelLink, dialogTitle, getAdminTool, getCurrentToolPath, getParamBase, getParamForce, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamBase, setParamForce, setParamPath, setParamRoot, setParamStyle, useNewStyle

    Methods inherited from class org.opencms.workplace.CmsWorkplace

    addMessages, addMessages, allParamsAsHidden, allParamsAsRequest, allParamValues, bodyEnd, bodyStart, bodyStart, buildSelect, buildSelect, button, button, buttonBar, buttonBar, buttonBarHorizontalLine, buttonBarLabel, buttonBarLabel, buttonBarLine, buttonBarLineSpacer, buttonBarSeparator, buttonBarSpacer, buttonBarStartTab, canEditPermissionsForRoles, checkLock, checkLock, checkRole, decodeParamValue, fillParamValues, fillParamValues, generateCssStyle, generatePageEndExtended, generatePageEndSimple, generatePageStartExtended, generatePageStartSimple, getBroadcastMessageString, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStartSiteRoot, getStartSiteRoot, getStaticResourceUri, getStaticResourceUri, getStyleUri, getStyleUri, getStyleUri, getTemporaryFileName, getWorkplaceExplorerLink, getWorkplaceExplorerLink, getWorkplaceSettings, htmlEnd, initMessages, initSettings, initTimeWarp, initUserSettings, initWorkplaceMembers, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, isTemporaryFile, key, key, keyDefault, nullToEmpty, paramsAsHidden, paramsAsHidden, paramsAsParameterMap, paramsAsRequest, paramValues, resolveMacros, sendCmsRedirect, sendForward, setForwarded, shortKey, substituteSiteTitle, substituteSiteTitleStatic, switchToCurrentProject, switchToTempProject, updateUserPreferences

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CmsLock

      public CmsLock()
      Default constructor needed for dialog handler implementation.

    • CmsLock

      public CmsLock(org.opencms.jsp.CmsJspActionElement jsp)
      Public constructor.

      Parameters:
      jsp - an initialized JSP action element
    • CmsLock

      public CmsLock(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 Details

    • buildLockDialog

      public static String buildLockDialog(org.opencms.workplace.CmsDialog dialog) throws org.opencms.main.CmsException
      Returns the html code to build the lock dialog.

      Returns:
      html code
      Throws:
      org.opencms.main.CmsException - if something goes wrong
    • buildLockDialog

      public static String buildLockDialog(org.opencms.workplace.CmsDialog dialog, org.opencms.lock.CmsLockFilter nonBlockingFilter, org.opencms.lock.CmsLockFilter blockingFilter, int hiddenTimeout, boolean includeRelated) throws org.opencms.main.CmsException
      Returns the html code to build the lock dialog.

      Parameters:
      nonBlockingFilter - the filter to get all non blocking locks
      blockingFilter - the filter to get all blocking locks
      hiddenTimeout - the maximal number of milliseconds the dialog will be hidden
      includeRelated - indicates if the report should include related resources
      Returns:
      html code
      Throws:
      org.opencms.main.CmsException - if something goes wrong
    • getDialogAction

      public static int getDialogAction(org.opencms.file.CmsObject cms)
      Determines if the resource should be locked, unlocked or if the lock should be stolen.

      Parameters:
      cms - the CmsObject
      Returns:
      the dialog action: lock, change lock (steal) or unlock
    • actionToggleLock

      public void actionToggleLock() throws javax.servlet.jsp.JspException
      Performs the lock/unlock operation, will be called by the JSP page.

      Throws:
      javax.servlet.jsp.JspException - if problems including sub-elements occur
    • addConfigurationParameter

      public void addConfigurationParameter(String paramName, String paramValue)
      Specified by:
      addConfigurationParameter in interface org.opencms.configuration.I_CmsConfigurationParameterHandler
      See Also:
      • I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
    • buildDefaultConfirmationJS

      Returns the html code to build the dialogs default confirmation message js.

      Returns:
      html code
    • buildIncludeJs

      Returns the html code to include the needed js code.

      Returns:
      html code
    • buildLockRequest

      Returns the html code to build the lock request.

      Returns:
      html code
    • buildLockRequest

      public String buildLockRequest(int hiddenTimeout, boolean includeRelated)
      Returns the html code to build the lock request.

      Parameters:
      hiddenTimeout - the maximal number of millis the dialog will be hidden
      includeRelated - indicates if the report should include related resources
      Returns:
      html code
    • buildReport

      public String buildReport() throws javax.servlet.jsp.JspException, javax.servlet.ServletException, IOException
      Returns the report of all locked subresources.

      Returns:
      the report of all locked subresources
      Throws:
      javax.servlet.jsp.JspException - if dialog actions fail
      IOException - in case of errros forwarding to the required result page
      javax.servlet.ServletException - in case of errros forwarding to the required result page
    • dialogButtons

      Builds the necessary button row.

      Returns:
      the button row
    • getBlockingFilter

      public org.opencms.lock.CmsLockFilter getBlockingFilter()
      Returns the filter to get all blocking locks.

      Returns:
      the filter to get all blocking locks
    • getBlockingLockedResources

      Returns locked resources that do not belong to the current user.

      Returns:
      the locked Resources
    • getBlockingLocks

      public int getBlockingLocks()
      Returns the number of blocking locks.

      Returns:
      the number of blocking locks
    • getConfiguration

      public org.opencms.configuration.CmsParameterConfiguration getConfiguration()
      Specified by:
      getConfiguration in interface org.opencms.configuration.I_CmsConfigurationParameterHandler
      See Also:
      • I_CmsConfigurationParameterHandler.getConfiguration()
    • getConfirmationMessage

      public String getConfirmationMessage(boolean state)
      Returns the confirmation message.

      Parameters:
      state - if true everything is ok
      Returns:
      the confirmation message
    • getDialogHandler

      Specified by:
      getDialogHandler in interface org.opencms.workplace.I_CmsDialogHandler
      See Also:
      • I_CmsDialogHandler.getDialogHandler()
    • getDialogUri

      public String getDialogUri(String resource, org.opencms.jsp.CmsJspActionElement jsp)
      Specified by:
      getDialogUri in interface org.opencms.workplace.I_CmsDialogHandler
      See Also:
      • I_CmsDialogHandler.getDialogUri(java.lang.String, CmsJspActionElement)
    • getLockedResources

      Returns all the locked Resources.

      Returns:
      all the locked Resources
    • getNonBlockingFilter

      public org.opencms.lock.CmsLockFilter getNonBlockingFilter()
      Returns the filter to get all non blocking locks.

      Returns:
      the filter to get all non blocking locks
    • getParamIncluderelated

      Returns the 'include unpublished related resources' parameter value.

      Returns:
      the 'include unpublished related resources' parameter value
    • getParamProjectid

      Returns the project id parameter value.

      Returns:
      the project id parameter value
    • getParamShowownlocks

      Returns the 'show own locked resources' parameter value.

      Returns:
      the 'show own locked resources' parameter value
    • initConfiguration

      public void initConfiguration()
      Specified by:
      initConfiguration in interface org.opencms.configuration.I_CmsConfigurationParameterHandler
      See Also:
      • I_CmsConfigurationParameterHandler.initConfiguration()
    • setBlockingFilter

      public void setBlockingFilter(org.opencms.lock.CmsLockFilter blockingFilter)
      Sets the filter to get all blocking locks.

      Parameters:
      blockingFilter - the filter to set
    • setNonBlockingFilter

      public void setNonBlockingFilter(org.opencms.lock.CmsLockFilter nonBlockingFilter)
      Sets the filter to get all non blocking locks.

      Parameters:
      nonBlockingFilter - the filter to set
    • setParamIncluderelated

      public void setParamIncluderelated(String paramIncluderelated)
      Sets the 'include unpublished related resources' parameter value.

      Parameters:
      paramIncluderelated - the 'include unpublished related resources' parameter value to set
    • setParamProjectid

      public void setParamProjectid(String projectid)
      Sets the project id parameter value.

      Parameters:
      projectid - the project id parameter value to set
    • setParamShowownlocks

      public void setParamShowownlocks(String paramShowownlocks)
      Sets the 'show own locked resources' parameter value.

      Parameters:
      paramShowownlocks - the 'show own locked resources' parameter value to set
    • showConfirmation

      public boolean showConfirmation()
      Determines whether to show the lock dialog depending on the users settings and the dilaog type.

      In case of locking a folder, a confirmation dialog is needed if any sub resources are already locked.

      Returns:
      true if dialogs should be shown, otherwise false
    • initWorkplaceRequestValues

      protected void initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      Overrides:
      initWorkplaceRequestValues in class org.opencms.workplace.CmsDialog
      See Also:
      • CmsWorkplace.initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
    • performDialogOperation

      protected boolean performDialogOperation() throws org.opencms.main.CmsException
      Performs the lock/unlock/steal lock operation.

      Specified by:
      performDialogOperation in class CmsMultiDialog
      Returns:
      true, if the operation was performed, otherwise false
      Throws:
      org.opencms.main.CmsException - if operation is not successful
    • performSingleResourceOperation

      protected void performSingleResourceOperation(String resourceName, int dialogAction) throws org.opencms.main.CmsException
      Performs the lock state operation on a single resource.

      Parameters:
      resourceName - the resource name to perform the operation on
      dialogAction - the lock action: lock, unlock or change lock
      Throws:
      org.opencms.main.CmsException - if the operation fails