org.opencms.workplace.commons
Class CmsLock

java.lang.Object
  extended byorg.opencms.workplace.CmsWorkplace
      extended byorg.opencms.workplace.tools.CmsToolDialog
          extended byorg.opencms.workplace.CmsDialog
              extended byorg.opencms.workplace.CmsMultiDialog
                  extended byorg.opencms.workplace.commons.CmsLock
All Implemented Interfaces:
I_CmsDialogHandler

public class CmsLock
extends CmsMultiDialog
implements I_CmsDialogHandler

Creates the dialogs for locking, unlocking or steal lock operations on a resource.

The following files use this class:

Since:
6.0.0
Version:
$Revision: 1.16 $
Author:
Andreas Zahner

Field Summary
static int ACTION_SUBMIT_NOCONFIRMATION
          Value for the action: confirmed.
static java.lang.String DIALOG_SUBMIT_NOCONFIRMATION
          Request parameter value for the action: submit form without user interaction.
static java.lang.String DIALOG_TYPE_LOCK
          The dialog type: lock a resource.
static java.lang.String DIALOG_TYPE_LOCKCHANGE
          The dialog type: Steal a lock.
static java.lang.String DIALOG_TYPE_UNLOCK
          The dialog type: unlock a resource.
static int TYPE_LOCK
          Type of the operation which is performed: lock resource.
static int TYPE_LOCKCHANGE
          Type of the operation which is performed: steal a lock.
static int TYPE_UNLOCK
          Type of the operation which is performed: unlock resource.
static java.lang.String URI_LOCK_DIALOG
          The lock dialog URI.
static java.lang.String URI_LOCKCHANGE_DIALOG
          The steal lock dialog URI.
static java.lang.String URI_UNLOCK_DIALOG
          The unlock dialog URI.
 
Fields inherited from class org.opencms.workplace.CmsMultiDialog
DELIMITER_RESOURCES, PARAM_RESOURCELIST
 
Fields inherited from class org.opencms.workplace.CmsDialog
ACTION_CANCEL, ACTION_CLOSEPOPUP, ACTION_CLOSEPOPUP_SAVE, ACTION_CONFIRMED, ACTION_DEFAULT, 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_OK, DIALOG_SET, DIALOG_WAIT, PARAM_ACTION, PARAM_CLOSELINK, PARAM_DIALOGTYPE, PARAM_ERRORSTACK, PARAM_FILE, PARAM_FRAMENAME, PARAM_ISPOPUP, PARAM_LOCK, PARAM_MESSAGE, 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_BASE, PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW
 
Fields inherited from class org.opencms.workplace.CmsWorkplace
DEBUG, 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, PARAM_WP_EXPLORER_RESOURCE, PARAM_WP_PROJECT, PARAM_WP_SITE, PATH_DIALOGS, PATH_WORKPLACE, REQUEST_ATTRIBUTE_MULTIPART, REQUEST_ATTRIBUTE_RELOADTREE, RFS_PATH_RESOURCES, SESSION_WORKPLACE_CLASS, TEMP_FILE_PREFIX, VFS_DIR_DEFAULTBODIES, VFS_DIR_TEMPLATES, VFS_PATH_COMMONS, VFS_PATH_EDITORS, VFS_PATH_GALLERIES, VFS_PATH_LOCALES, VFS_PATH_MODULES, VFS_PATH_RESOURCES, VFS_PATH_SYSTEM, VFS_PATH_VIEWS, VFS_PATH_WORKPLACE
 
Constructor Summary
CmsLock()
          Default constructor needed for dialog handler implementation.
CmsLock(CmsJspActionElement jsp)
          Public constructor.
CmsLock(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Public constructor with JSP variables.
 
Method Summary
 void actionToggleLock()
          Performs the lock/unlock operation, will be called by the JSP page.
 java.lang.String buildDialogText()
          Builds the HTML for the text that is shown on the confirmation dialog depending on the selected resource(s).
static int getDialogAction(CmsObject cms)
          Determines if the resource should be locked, unlocked or if the lock should be stolen.
 java.lang.String getDialogHandler()
          Returns the name of the handler which is used as key for the OpenCms runtime properties.
 java.lang.String getDialogUri(java.lang.String resource, CmsJspActionElement jsp)
          Returns the dialog URI in the OpenCms VFS to the dialog selector class.
 boolean hasLockedSubResources()
          Returns true if the resources to lock have locked subresources.
protected  void initWorkplaceRequestValues(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
          Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.
protected  boolean performDialogOperation()
          Performs the lock/unlock/steal lock operation.
protected  void performSingleResourceOperation(java.lang.String resourceName, int dialogAction)
          Performs the lock state operation on a single resource.
 void setHasLockedSubResources(boolean hasLockedSubResources)
          Sets if the resources to lock have locked subresources.
 boolean showConfirmation()
          Determines whether to show the lock dialog depending on the users settings and the dilaog type.
 
Methods inherited from class org.opencms.workplace.CmsMultiDialog
addMultiOperationException, buildResourceList, checkMultiOperationException, checkResourcePermissions, getParamResourcelist, getResourceList, isMultiOperation, isOperationOnFolder, setDialogTitle, setParamResourcelist
 
Methods inherited from class org.opencms.workplace.CmsDialog
actionCloseDialog, appendDelimiter, checkResourcePermissions, dialog, dialogBlock, dialogBlockEnd, dialogBlockStart, dialogButtonRow, dialogButtonRowEnd, dialogButtonRowStart, dialogButtons, dialogButtonsClose, dialogButtonsClose, dialogButtonsCloseDetails, dialogButtonsHtml, dialogButtonsOk, dialogButtonsOk, dialogButtonsOkCancel, dialogButtonsOkCancel, dialogButtonsOkCancelAdvanced, dialogButtonsSetOkCancel, dialogContent, dialogContentEnd, dialogContentStart, dialogEnd, dialogHead, dialogHorizontalSpacer, 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, getParamRedirect, getParamResource, getParamTitle, getState, htmlStart, htmlStart, htmlStart, htmlStartStyle, includeErrorpage, initCmsDialog, isPopup, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamRedirect, setParamResource, setParamTitle
 
Methods inherited from class org.opencms.workplace.tools.CmsToolDialog
dialogTitle, getAdminTool, getCurrentToolPath, getParamBase, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamBase, 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, calendarIncludes, calendarIncludes, calendarInit, calendarInit, checkLock, checkLock, decodeParamValue, fillParamValues, fillParamValues, getBroadcastMessageString, getCalendarDate, getCalendarJavaDateFormat, getCalendarLocalizedTime, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStyleUri, getStyleUri, getStyleUri, htmlEnd, initMessages, initSettings, initUserSettings, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, key, key, keyDefault, nullToEmpty, paramsAsHidden, paramsAsHidden, paramsAsParameterMap, paramsAsRequest, paramValues, resolveMacros, sendCmsRedirect, sendForward, setForwarded, shortKey, switchToCurrentProject, switchToTempProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_SUBMIT_NOCONFIRMATION

public static final int ACTION_SUBMIT_NOCONFIRMATION
Value for the action: confirmed.

See Also:
Constant Field Values

DIALOG_SUBMIT_NOCONFIRMATION

public static final java.lang.String DIALOG_SUBMIT_NOCONFIRMATION
Request parameter value for the action: submit form without user interaction.

See Also:
Constant Field Values

DIALOG_TYPE_LOCK

public static final java.lang.String DIALOG_TYPE_LOCK
The dialog type: lock a resource.

See Also:
Constant Field Values

DIALOG_TYPE_LOCKCHANGE

public static final java.lang.String DIALOG_TYPE_LOCKCHANGE
The dialog type: Steal a lock.

See Also:
Constant Field Values

DIALOG_TYPE_UNLOCK

public static final java.lang.String DIALOG_TYPE_UNLOCK
The dialog type: unlock a resource.

See Also:
Constant Field Values

TYPE_LOCK

public static final int TYPE_LOCK
Type of the operation which is performed: lock resource.

See Also:
Constant Field Values

TYPE_LOCKCHANGE

public static final int TYPE_LOCKCHANGE
Type of the operation which is performed: steal a lock.

See Also:
Constant Field Values

TYPE_UNLOCK

public static final int TYPE_UNLOCK
Type of the operation which is performed: unlock resource.

See Also:
Constant Field Values

URI_LOCK_DIALOG

public static final java.lang.String URI_LOCK_DIALOG
The lock dialog URI.

See Also:
Constant Field Values

URI_LOCKCHANGE_DIALOG

public static final java.lang.String URI_LOCKCHANGE_DIALOG
The steal lock dialog URI.

See Also:
Constant Field Values

URI_UNLOCK_DIALOG

public static final java.lang.String URI_UNLOCK_DIALOG
The unlock dialog URI.

See Also:
Constant Field Values
Constructor Detail

CmsLock

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


CmsLock

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

getDialogAction

public static int getDialogAction(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

buildDialogText

public java.lang.String buildDialogText()
Builds the HTML for the text that is shown on the confirmation dialog depending on the selected resource(s).

Returns:
the HTML for the text that is shown on the confirmation dialog depending on the selected resource(s)

getDialogHandler

public java.lang.String getDialogHandler()
Description copied from interface: I_CmsDialogHandler
Returns the name of the handler which is used as key for the OpenCms runtime properties.

Store the name of the key as a public String constant in the CmsDialogSelector class.

Specified by:
getDialogHandler in interface I_CmsDialogHandler
Returns:
the name of the dialog handler
See Also:
I_CmsDialogHandler.getDialogHandler()

getDialogUri

public java.lang.String getDialogUri(java.lang.String resource,
                                     CmsJspActionElement jsp)
Description copied from interface: I_CmsDialogHandler
Returns the dialog URI in the OpenCms VFS to the dialog selector class.

Specified by:
getDialogUri in interface I_CmsDialogHandler
Parameters:
resource - the selected resource
jsp - the CmsJspActionElement
Returns:
the absolute path to the property dialog
See Also:
I_CmsDialogHandler.getDialogUri(java.lang.String, CmsJspActionElement)

hasLockedSubResources

public boolean hasLockedSubResources()
Returns true if the resources to lock have locked subresources.

Returns:
true if the resources to lock have locked subresources

setHasLockedSubResources

public void setHasLockedSubResources(boolean hasLockedSubResources)
Sets if the resources to lock have locked subresources.

Parameters:
hasLockedSubResources - if the resources to lock have locked subresources

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(CmsWorkplaceSettings settings,
                                          javax.servlet.http.HttpServletRequest request)
Description copied from class: CmsWorkplace
Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.

Overrides:
initWorkplaceRequestValues in class CmsDialog
See Also:
CmsWorkplace.initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)

performDialogOperation

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

Specified by:
performDialogOperation in class CmsMultiDialog
Returns:
true, if the operation was performed, otherwise false
Throws:
CmsException - if operation is not successful

performSingleResourceOperation

protected void performSingleResourceOperation(java.lang.String resourceName,
                                              int dialogAction)
                                       throws 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:
CmsException - if the operation fails