org.opencms.workplace
Class CmsMultiDialog

java.lang.Object
  extended by org.opencms.workplace.CmsWorkplace
      extended by org.opencms.workplace.tools.CmsToolDialog
          extended by org.opencms.workplace.CmsDialog
              extended by org.opencms.workplace.CmsMultiDialog
Direct Known Subclasses:
CmsAvailability, CmsCopy, CmsDelete, CmsLock, CmsMove, CmsPublishProject, CmsReport, CmsTouch, CmsUndelete, CmsUndoChanges

public abstract class CmsMultiDialog
extends CmsDialog

The base class to build a dialog capable of multiple file operations.

Extend this class for workplace dialogs that can perform operations on more than one VFS resource like copy, move, touch etc.

Provides methods to determine if a multi-resource operation has to be done and helper methods, e.g. to get the list of resources to work with.

Since:
6.2.0
Version:
$Revision: 1.9 $
Author:
Andreas Zahner

Field Summary
static java.lang.String DELIMITER_RESOURCES
          The delimiter that is used in the resource list request parameter.
static java.lang.String PARAM_RESOURCELIST
          Request parameter name for the resource list.
 
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_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_BASE, PARAM_FORCE, 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
CmsMultiDialog(CmsJspActionElement jsp)
          Public constructor.
CmsMultiDialog(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Public constructor with JSP variables.
 
Method Summary
 void addMultiOperationException(CmsException exc)
          Adds an exception thrown during a multi resource operation to the multi exception.
 java.lang.String buildLockHeaderBox()
          Returns the html code to build the header box.
 java.lang.String buildResourceList()
          Builds the HTML for the resource list that is affected by the multi operation.
 void checkMultiOperationException(I_CmsMessageBundle messages, java.lang.String key)
          Checks if an exception occurred during a multi resource operation, and throws a new exception if necessary.
protected  boolean checkResourcePermissions(CmsPermissionSet required, boolean neededForFolder)
          Checks if the permissions of the current user on the single resource to use in the dialog are sufficient.
 java.lang.String getParamResourcelist()
          Returns the value of the resource list parameter, or null if the parameter is not provided.
 java.util.List getResourceList()
          Returns the resources that are defined for the dialog operation.
 java.lang.String getResourceListAsParam()
          Returns the value of the resourcelist parameter in form of a String separated with DELIMITER_RESOURCES, or the value of the resource parameter if the first parameter is not provided (no multiple choice has been done.
 boolean isMultiOperation()
          Returns true if the dialog operation has to be performed on multiple resources.
protected  boolean isOperationOnFolder()
          Checks if the resource operation is an operation on at least one folder.
protected abstract  boolean performDialogOperation()
          Performs the dialog operation for the selected resources.
 void setDialogTitle(java.lang.String singleKey, java.lang.String multiKey)
          Sets the title of the dialog depending on the operation type, multiple or single operation.
 void setParamResource(java.lang.String value)
          Sets the value of the file parameter.
 void setParamResourcelist(java.lang.String paramResourcelist)
          Sets the value of the resourcelist parameter.
 
Methods inherited from class org.opencms.workplace.CmsDialog
actionCloseDialog, appendDelimiter, buildAjaxResultContainer, buildAjaxWaitMessage, buildLockAdditionalOptions, buildLockConfirmationMessageJS, buildLockDialog, buildLockDialog, 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, initWorkplaceRequestValues, isPopup, isPreEditor, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamOriginalParams, setParamPreActionDone, setParamRedirect, setParamTitle
 
Methods inherited from class org.opencms.workplace.tools.CmsToolDialog
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, checkLock, checkLock, checkRole, decodeParamValue, fillParamValues, fillParamValues, getBroadcastMessageString, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStyleUri, getStyleUri, getStyleUri, getTemporaryFileName, htmlEnd, initMessages, initSettings, initTimeWarp, initUserSettings, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, isTemporaryFile, isTemporaryFileName, 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

DELIMITER_RESOURCES

public static final java.lang.String DELIMITER_RESOURCES
The delimiter that is used in the resource list request parameter.

See Also:
Constant Field Values

PARAM_RESOURCELIST

public static final java.lang.String PARAM_RESOURCELIST
Request parameter name for the resource list.

See Also:
Constant Field Values
Constructor Detail

CmsMultiDialog

public CmsMultiDialog(CmsJspActionElement jsp)
Public constructor.

Parameters:
jsp - an initialized JSP action element

CmsMultiDialog

public CmsMultiDialog(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

addMultiOperationException

public void addMultiOperationException(CmsException exc)
Adds an exception thrown during a multi resource operation to the multi exception.

After iterating the dialog resources, use checkMultiOperationException(I_CmsMessageBundle, String) to display the multi exception depending on collected exceptions.

Parameters:
exc - the exception that was thrown

buildResourceList

public java.lang.String buildResourceList()
Builds the HTML for the resource list that is affected by the multi operation.

Returns:
the HTML for the resource list that is affected by the multi operation

buildLockHeaderBox

public java.lang.String buildLockHeaderBox()
                                    throws CmsException
Description copied from class: CmsDialog
Returns the html code to build the header box.

Overrides:
buildLockHeaderBox in class CmsDialog
Returns:
html code
Throws:
CmsException - if something goes wrong
See Also:
CmsDialog.buildLockHeaderBox()

checkMultiOperationException

public void checkMultiOperationException(I_CmsMessageBundle messages,
                                         java.lang.String key)
                                  throws CmsException
Checks if an exception occurred during a multi resource operation, and throws a new exception if necessary.

Parameters:
messages - the message bundle to use for the exception message generation
key - the key for the exception to throw with one parameter
Throws:
CmsException - the exception that is thrown when the multi operation was not successful

getParamResourcelist

public java.lang.String getParamResourcelist()
Returns the value of the resource list parameter, or null if the parameter is not provided.

This parameter selects the resources to perform operations on.

Returns:
the value of the resource list parameter or null, if the parameter is not provided

getResourceList

public java.util.List getResourceList()
Returns the resources that are defined for the dialog operation.

For single resource operations, the list contains one item: the resource name found in the request parameter value of the "resource" parameter.

Returns:
the resources that are defined for the dialog operation

getResourceListAsParam

public java.lang.String getResourceListAsParam()
Returns the value of the resourcelist parameter in form of a String separated with DELIMITER_RESOURCES, or the value of the resource parameter if the first parameter is not provided (no multiple choice has been done.

This may be used for jsps as value for the parameter for resources PARAM_RESOURCELIST.

Returns:
the value of the resourcelist parameter or null, if the parameter is not provided

isMultiOperation

public boolean isMultiOperation()
Returns true if the dialog operation has to be performed on multiple resources.

Returns:
true if the dialog operation has to be performed on multiple resources, otherwise false

setDialogTitle

public void setDialogTitle(java.lang.String singleKey,
                           java.lang.String multiKey)
Sets the title of the dialog depending on the operation type, multiple or single operation.

Parameters:
singleKey - the key for the single operation
multiKey - the key for the multiple operation

setParamResourcelist

public void setParamResourcelist(java.lang.String paramResourcelist)
Sets the value of the resourcelist parameter.

Parameters:
paramResourcelist - the value of the resourcelist parameter

setParamResource

public void setParamResource(java.lang.String value)
Description copied from class: CmsDialog
Sets the value of the file parameter.

Overrides:
setParamResource in class CmsDialog
Parameters:
value - the value to set
See Also:
CmsDialog.setParamResource(java.lang.String)

checkResourcePermissions

protected boolean checkResourcePermissions(CmsPermissionSet required,
                                           boolean neededForFolder)
Checks if the permissions of the current user on the single resource to use in the dialog are sufficient.

For a multi resource operation, this returns always true, checks only for single resource operations.

Overrides:
checkResourcePermissions in class CmsDialog
Parameters:
required - the required permissions for the dialog
neededForFolder - if true, the permissions are required for the parent folder of the resource (e.g. for editors)
Returns:
true if the permissions are sufficient, otherwise false
See Also:
CmsDialog.checkResourcePermissions(CmsPermissionSet, boolean)

isOperationOnFolder

protected boolean isOperationOnFolder()
Checks if the resource operation is an operation on at least one folder.

Returns:
true if the operation an operation on at least one folder, otherwise false

performDialogOperation

protected abstract boolean performDialogOperation()
                                           throws CmsException
Performs the dialog operation for the selected resources.

Returns:
true, if the operation was successful, otherwise false
Throws:
CmsException - if operation was not successful