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

📄 cmsadministration.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdministration.java,v $
* Date   : $Date: 2005/06/27 23:22:07 $
* Version: $Revision: 1.7 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001  The OpenCms Group
*
* 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 OpenCms, please see the
* OpenCms 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 com.opencms.workplace;

import org.opencms.file.CmsFile;
import org.opencms.file.CmsFolder;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsVfsResourceNotFoundException;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.security.CmsPermissionSet;
import org.opencms.security.CmsSecurityException;
import org.opencms.workplace.CmsWorkplace;

import com.opencms.core.I_CmsSession;
import com.opencms.legacy.CmsLegacyException;
import com.opencms.legacy.CmsXmlTemplateLoader;
import com.opencms.template.CmsTemplateClassManager;
import com.opencms.template.CmsXmlTemplateFile;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

/**
 * This class is used to display the administration view.
 *
 * Creation date: (09.08.00 14:01:21)
 * @author Hanjo Riege
 * @version $Name:  $ $Revision: 1.7 $ $Date: 2005/06/27 23:22:07 $
 * 
 * @deprecated Will not be supported past the OpenCms 6 release.
 */

public class CmsAdministration extends CmsWorkplaceDefault {

    /**
     * Returns the complete Icon.
     *
     * @param cms CmsObject Object for accessing system resources
     * @param templateDocument contains the icondefinition.
     * @param parameters Hashtable containing all user parameters.
     * @param lang CmsXmlLanguageFile conataining the currently valid language file.
     * @param picName the basic name of the picture.
     * @param sender the name of the icon incl. path.
     * @param languageKey the the key for the languagefile.
     * @param iconActiveMethod the method for decision if icon is active, or null.
     * @param iconVisibleMethod the method for decision if icon is visible,  or null.
     */

    private String generateIcon(CmsObject cms, CmsXmlTemplateFile templateDocument, Hashtable parameters,
            CmsXmlLanguageFile lang, String picName, String sender, String languageKey,
                    String iconActiveMethod, String iconVisibleMethod, String accessVisible) throws CmsException {

        boolean hasAccessVisible = (new Boolean(accessVisible)).booleanValue();
        String iconPicPath = (String)resourcesUri(cms, "", null, null);
        // change the iconPicPath if the point is from a module
        if(sender.startsWith(CmsWorkplace.VFS_PATH_SYSTEM + "modules")) {
            if (picName.startsWith("/")) {
                iconPicPath = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl() + sender.substring(0, sender.indexOf("/administration/"));
            }
            else {
                iconPicPath = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl() + sender.substring(0, sender.indexOf("administration/")) + "pics/";
            }
        }

        // call the method for activation decision
        boolean activate = true;
        if(iconActiveMethod != null && !"".equals(iconActiveMethod)) {
            String className = iconActiveMethod.substring(0, iconActiveMethod.lastIndexOf("."));
            iconActiveMethod = iconActiveMethod.substring(iconActiveMethod.lastIndexOf(".") + 1);
            Method groupsMethod = null;
            try {
                Object o = CmsTemplateClassManager.getClassInstance(className);
                groupsMethod = o.getClass().getMethod(iconActiveMethod, new Class[] {
                    CmsObject.class, CmsXmlLanguageFile.class, Hashtable.class
                });
                activate = ((Boolean)groupsMethod.invoke(o, new Object[] {
                    cms, lang, parameters
                })).booleanValue();

            }
            catch(NoSuchMethodException exc) {

                // The requested method was not found.
                throwException("Could not find icon activation method " + iconActiveMethod
                        + " in calling class " + className + " for generating icon.", CmsLegacyException.C_NOT_FOUND);
            }
            catch(InvocationTargetException targetEx) {

                // the method could be invoked, but throwed a exception
                // itself. Get this exception and throw it again.
                Throwable e = targetEx.getTargetException();
                if(!(e instanceof CmsException)) {

                    throwException("Icon activation method " + iconActiveMethod + " in calling class "
                            + className + " throwed an exception. " + e, CmsLegacyException.C_UNKNOWN_EXCEPTION);
                }
                else {

                    // This is a CmsException
                    // Error printing should be done previously.
                    throw (CmsException)e;
                }
            }
            catch(Exception exc2) {
                throwException("Icon activation method " + iconActiveMethod + " in calling class "
                        + className + " was found but could not be invoked. " + exc2, CmsLegacyException.C_UNKNOWN_EXCEPTION);
            }
        }

        // call the method for the visibility decision
        boolean visible = true;
        if(iconVisibleMethod != null && !"".equals(iconVisibleMethod)) {
            String className = iconVisibleMethod.substring(0, iconVisibleMethod.lastIndexOf("."));
            iconVisibleMethod = iconVisibleMethod.substring(iconVisibleMethod.lastIndexOf(".") + 1);
            Method groupsMethod = null;
            try {
                Object o = CmsTemplateClassManager.getClassInstance(className);
                groupsMethod = o.getClass().getMethod(iconVisibleMethod, new Class[] {
                    CmsObject.class, CmsXmlLanguageFile.class, Hashtable.class
                });
                visible = ((Boolean)groupsMethod.invoke(o, new Object[] {
                    cms, lang, parameters
                })).booleanValue();
            }
            catch(NoSuchMethodException exc) {

                // The requested method was not found.
                throwException("Could not find icon activation method " + iconVisibleMethod
                        + " in calling class " + className + " for generating icon.", CmsLegacyException.C_NOT_FOUND);
            }
            catch(InvocationTargetException targetEx) {

                // the method could be invoked, but throwed a exception

                // itself. Get this exception and throw it again.
                Throwable e = targetEx.getTargetException();
                if(!(e instanceof CmsException)) {

                    throwException("Icon activation method " + iconVisibleMethod + " in calling class "
                            + className + " throwed an exception. " + e);
                }
                else {

                    // This is a CmsException

                    // Error printing should be done previously.
                    throw (CmsException)e;
                }
            }
            catch(Exception exc2) {
                throwException("Icon activation method " + iconVisibleMethod + " in calling class "
                        + className + " was found but could not be invoked. " + exc2);
            }
        }
        templateDocument.setData("linkTo", CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl() + CmsWorkplace.VFS_PATH_WORKPLACE 
                + "action/administration_content_top.html?sender=" + sender);
        StringBuffer iconLabelBuffer = new StringBuffer(lang.getLanguageValue(languageKey));

        // Insert a html-break, if needed
        if(iconLabelBuffer.toString().indexOf("- ") != -1) {
            iconLabelBuffer.insert(iconLabelBuffer.toString().indexOf("- ") + 1, "<BR>");
        }
        templateDocument.setData("linkName", iconLabelBuffer.toString());
        if(visible && hasAccessVisible) {
            if(activate) {
                templateDocument.setData("picture", iconPicPath + picName + ".gif");
                return templateDocument.getProcessedDataValue("defaulticon");
            }
            else {
                templateDocument.setData("picture", iconPicPath + picName + "_in.gif");
                return templateDocument.getProcessedDataValue("deactivatedicon");
            }
        }
        else {
            return templateDocument.getProcessedDataValue("noicon");
        }
    } // of generateIcon

    /**
     * Gets the content of a defined section in a given template file and its subtemplates
     * with the given parameters.
     *
     * @see #getContent(CmsObject, String, String, Hashtable, String)
     * @param cms CmsObject Object for accessing system resources.
     * @param templateFile Filename of the template file.
     * @param elementName Element name of this template in our parent template.
     * @param parameters Hashtable with all template class parameters.

⌨️ 快捷键说明

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