⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsavailability.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsAvailability.java,v $
 * Date   : $Date: 2006/03/27 14:52:18 $
 * Version: $Revision: 1.2 $
 *
 * 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.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProperty;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsIllegalArgumentException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsAccessControlEntry;
import org.opencms.security.CmsPermissionSet;
import org.opencms.security.I_CmsPrincipal;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsMultiDialog;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.CmsWorkplaceSettings;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;

/**
 * Provides methods for the resource availability/notification dialog.<p> 
 * 
 * The following files use this class:
 * <ul>
 * <li>/commons/availability.jsp
 * </ul>
 * <p>
 *
 * @author Jan Baudisch
 * @author Andreas Zahner
 * 
 * @version $Revision: 1.2 $ 
 * 
 * @since 6.0.0 
 */
public class CmsAvailability extends CmsMultiDialog {

    /** The dialog type. */
    public static final String DIALOG_TYPE = "availability";

    /** Request parameter name for the activation of the notifciation. */
    public static final String PARAM_ENABLE_NOTIFICATION = "enablenotification";

    /** Request parameter name for the expiredate. */
    public static final String PARAM_EXPIREDATE = "expiredate";

    /** Request parameter name for the leaveexpire. */
    public static final String PARAM_LEAVEEXPIRE = "leaveexpire";

    /** Request parameter name for the leaverelease. */
    public static final String PARAM_LEAVERELEASE = "leaverelease";

    /** Request parameter name for the recursive flag. */
    public static final String PARAM_MODIFY_SIBLINGS = "modifysiblings";

    /** Request parameter name for the activation of the notifciation. */
    public static final String PARAM_NOTIFICATION_INTERVAL = "notificationinterval";

    /** Request parameter name for the recursive flag. */
    public static final String PARAM_RECURSIVE = "recursive";

    /** Request parameter name for the releasedate. */
    public static final String PARAM_RELEASEDATE = "releasedate";
    
    /** Request parameter name for the resetexpire. */
    public static final String PARAM_RESETEXPIRE = "resetexpire";
    
    /** Request parameter name for the resetrelease. */
    public static final String PARAM_RESETRELEASE = "resetrelease";
    
    /** The log object for this class. */
    private static final Log LOG = CmsLog.getLog(CmsAvailability.class);
    
    private String m_paramEnablenotification;
    private String m_paramExpiredate;
    private String m_paramLeaveexpire;
    private String m_paramModifysiblings;
    private String m_paramNotificationinterval;
    private String m_paramRecursive;
    private String m_paramReleasedate;
    private String m_paramResetexpire;
    private String m_paramResetrelease;

    /**
     * Public constructor.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsAvailability(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 CmsAvailability(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        this(new CmsJspActionElement(context, req, res));
    }

    /**
     * Returns a localized String for "Group", if the flag of a group ACE, and the localization for "User" otherwise.<p>
     * 
     * @param flags the flags of the ACE
     * 
     * @return localization for "Group", if the flag belongs to a group ACE
     */
    protected String getLocalizedType(int flags) {

        if ((flags & CmsAccessControlEntry.ACCESS_FLAGS_USER) > 0) {
            return key(Messages.GUI_LABEL_USER_0);
        } else {
            return key(Messages.GUI_LABEL_GROUP_0);
        }
    }

    /**
     * 
     * @see org.opencms.workplace.CmsDialog#actionCloseDialog()
     */
    public void actionCloseDialog() throws JspException {

        // so that the explorer will be shown, if dialog is opened from e-mail
        getSettings().getFrameUris().put("body", CmsWorkplace.VFS_PATH_VIEWS + "explorer/explorer_fs.jsp");
        super.actionCloseDialog();
    }

    /**
     * Performs the resource operation, will be called by the JSP page.<p>
     * 
     * @throws JspException if problems including sub-elements occur
     */
    public void actionUpdate() 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 dialog operation was successful          
                actionCloseDialog();
            } else {
                // "false" returned, display "please wait" screen
                getJsp().include(FILE_DIALOG_SCREEN_WAIT);
            }
        } catch (Throwable e) {
            includeErrorpage(this, e);
        }
    }

    /**
     * Creates the checkbox to enable content notification for a resource.<p>
     *  
     * @return HTML code for the enable_notification checkbox.
     */
    public String buildCheckboxEnableNotification() {

        String propVal = null;
        if (!isMultiOperation()) {
            // get current settings for single resource dialog
            try {
                propVal = getCms().readPropertyObject(
                    getParamResource(),
                    CmsPropertyDefinition.PROPERTY_ENABLE_NOTIFICATION,
                    false).getValue();
            } catch (CmsException e) {
                if (LOG.isInfoEnabled()) {
                    LOG.info(e.getLocalizedMessage());
                }
            }

        }
        if (CmsStringUtil.isEmpty(propVal)) {
            propVal = CmsStringUtil.FALSE;
        }
        StringBuffer result = new StringBuffer(512);
        result.append("<input type=\"checkbox\" style=\"text-align:left\" name=\"");
        result.append(PARAM_ENABLE_NOTIFICATION);
        if (Boolean.valueOf(propVal).booleanValue()) {
            result.append("\" checked=\"checked");
        }
        result.append("\" value=\"true\">");
        return result.toString();
    }

    /**
     * Creates an the checkbox to modify all siblings.<p>
     *  
     * If no siblings exist for this resource, an empty string will be returned.
     * 
     * @return HTML code for the modify siblings checkbox.
     */
    public String buildCheckboxModifySiblings() {

        StringBuffer result = new StringBuffer(254);
        try {
            if (isMultiOperation() || getCms().readSiblings(getParamResource(), CmsResourceFilter.ALL).size() > 1) {
                result.append("<tr>\n<td style=\"white-space:nowrap;\">");
                result.append(key(Messages.GUI_AVAILABILITY_MODIFY_SIBLINGS_0));
                result.append("</td>\n<td class=\"maxwidth\" style=\"padding-left: 5px;\">\n");
                result.append("<input type=\"checkbox\" name=\"");
                result.append(PARAM_MODIFY_SIBLINGS);
                result.append("\" value=\"true\" style=\"text-align:left\">\n</td>\n<td>&nbsp</td></tr>");
            }
        } catch (CmsException e) {
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
        }
        return result.toString();
    }

    /**
     * Creates the "recursive" checkbox for touching subresources of folders.<p>
     *  
     * @return the String with the checkbox input field or an empty String for folders.
     */
    public String buildCheckRecursive() {

        StringBuffer result = new StringBuffer(256);

        // show the checkbox only for operation(s) on folder(s)
        if (isOperationOnFolder()) {
            result.append(dialogBlockStart(key(Messages.GUI_AVAILABILITY_NOTIFICATION_SUBRES_0)));
            result.append("<table border=\"0\">");
            result.append("<tr>\n\t<td style=\"white-space:nowrap;\">");
            result.append(key(Messages.GUI_TOUCH_MODIFY_SUBRESOURCES_0));
            result.append("</td><td class=\"maxwidth\" style=\"padding-left: 5px;\"><input type=\"checkbox\" style=\"text-align:left\" name=\"");
            result.append(PARAM_RECURSIVE);
            result.append("\" value=\"true\">&nbsp;</td>\n<td>&nbsp</td></tr>\n");
            result.append("</table>");
            result.append(dialogBlockEnd());
            result.append(dialogSpacer());
        }
        return result.toString();
    }

    /**
     * Creates an input field for the notification interval.<p>
     *  
     * @return HTML code for the notification interval input field.
     */
    public String buildInputNotificationInterval() {

        String propVal = null;
        if (!isMultiOperation()) {
            try {
                propVal = getCms().readPropertyObject(
                    getParamResource(),
                    CmsPropertyDefinition.PROPERTY_NOTIFICATION_INTERVAL,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -