📄 cmslock.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsLock.java,v $
* Date : $Date: 2006/03/27 14:52:18 $
* Version: $Revision: 1.16 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace.commons;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.security.CmsPermissionSet;
import org.opencms.workplace.CmsDialogSelector;
import org.opencms.workplace.CmsMultiDialog;
import org.opencms.workplace.CmsWorkplaceSettings;
import org.opencms.workplace.I_CmsDialogHandler;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
/**
* Creates the dialogs for locking, unlocking or steal lock operations on a resource.<p>
*
* The following files use this class:
* <ul>
* <li>/commons/lock_standard.jsp
* <li>/commons/lockchange_standard.jsp
* <li>/commons/unlock_standard.jsp
* </ul>
* <p>
*
* @author Andreas Zahner
*
* @version $Revision: 1.16 $
*
* @since 6.0.0
*/
public class CmsLock extends CmsMultiDialog implements I_CmsDialogHandler {
/** Value for the action: confirmed. */
public static final int ACTION_SUBMIT_NOCONFIRMATION = 200;
/** Request parameter value for the action: submit form without user interaction. */
public static final String DIALOG_SUBMIT_NOCONFIRMATION = "submitnoconfirmation";
/** The dialog type: lock a resource. */
public static final String DIALOG_TYPE_LOCK = "lock";
/** The dialog type: Steal a lock. */
public static final String DIALOG_TYPE_LOCKCHANGE = "lockchange";
/** The dialog type: unlock a resource. */
public static final String DIALOG_TYPE_UNLOCK = "unlock";
/** Type of the operation which is performed: lock resource. */
public static final int TYPE_LOCK = 1;
/** Type of the operation which is performed: steal a lock. */
public static final int TYPE_LOCKCHANGE = 2;
/** Type of the operation which is performed: unlock resource. */
public static final int TYPE_UNLOCK = 3;
/** The lock dialog URI. */
public static final String URI_LOCK_DIALOG = PATH_DIALOGS + "lock_standard.jsp";
/** The steal lock dialog URI. */
public static final String URI_LOCKCHANGE_DIALOG = PATH_DIALOGS + "lockchange_standard.jsp";
/** The unlock dialog URI. */
public static final String URI_UNLOCK_DIALOG = PATH_DIALOGS + "unlock_standard.jsp";
/** Flag indicating if the selected resources to lockes contain locked subresources.*/
private boolean m_hasLockedSubResources;
/**
* Default constructor needed for dialog handler implementation.<p>
*/
public CmsLock() {
super(null);
}
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsLock(CmsJspActionElement jsp) {
super(jsp);
}
/**
* Public constructor with JSP variables.<p>
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsLock(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Determines if the resource should be locked, unlocked or if the lock should be stolen.<p>
*
* @param cms the CmsObject
* @return the dialog action: lock, change lock (steal) or unlock
*/
public static int getDialogAction(CmsObject cms) {
String fileName = CmsResource.getName(cms.getRequestContext().getUri());
if (fileName == null) {
// file name could not be determined, return "unlock" action
return TYPE_UNLOCK;
} else if (fileName.equalsIgnoreCase("lock.jsp")) {
// a "lock" action is requested
return TYPE_LOCK;
} else if (fileName.indexOf("change") != -1) {
// a "steal lock" action is requested
return TYPE_LOCKCHANGE;
} else {
// an "unlock" action is requested
return TYPE_UNLOCK;
}
}
/**
* Performs the lock/unlock operation, will be called by the JSP page.<p>
*
* @throws JspException if problems including sub-elements occur
*/
public void actionToggleLock() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
if (performDialogOperation()) {
// if no exception is caused and "true" is returned the lock/unlock operation was successful
actionCloseDialog();
} else {
// "false" returned, display "please wait" screen
getJsp().include(FILE_DIALOG_SCREEN_WAIT);
}
} catch (Throwable e) {
// exception occured, show error dialog
includeErrorpage(this, e);
}
}
/**
* Builds the HTML for the text that is shown on the confirmation dialog depending on the selected resource(s).<p>
*
* @return the HTML for the text that is shown on the confirmation dialog depending on the selected resource(s)
*/
public String buildDialogText() {
switch (getDialogAction(getCms())) {
case TYPE_LOCK:
if (hasLockedSubResources()) {
if (isMultiOperation()) {
return key(Messages.GUI_LOCK_MULTI_INFO_LOCKEDSUBRESOURCES_0);
} else {
return key(Messages.GUI_LOCK_INFO_LOCKEDSUBRESOURCES_0);
}
} else {
if (isMultiOperation()) {
return key(Messages.GUI_LOCK_MULTI_LOCK_CONFIRMATION_0);
} else {
return key(Messages.GUI_LOCK_CONFIRMATION_0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -