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

📄 cmsadminmodulecreate.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminModuleCreate.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.db.CmsExportPoint;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsVfsResourceAlreadyExistsException;
import org.opencms.file.types.CmsResourceTypeFolder;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.module.CmsModule;
import org.opencms.module.CmsModuleVersion;
import org.opencms.util.CmsStringUtil;
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.CmsXmlTemplateFile;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
 * Template class for displaying OpenCms workplace administration module create.
 *
 * Creation date: (27.10.00 10:28:08)
 * @author Hanjo Riege
 * 
 * @deprecated Will not be supported past the OpenCms 6 release.
 */
public class CmsAdminModuleCreate extends CmsWorkplaceDefault {
    private final static String C_PACKETNAME = "packetname";
    private final static String C_STEP = "step";
    private final static String C_VERSION = "version";
    private final static String C_GROUP = "group";
    private final static String C_MODULENAME = "modulename";
    private final static String C_DESCRIPTION = "description";
    private final static String C_VIEW = "view";
    private final static String C_ADMINPOINT = "adminpoint";
    private final static String C_MAINTENANCE = "maintenance";
    private final static String C_PUBLISHCLASS = "publishclass";    
    private final static String C_AUTHOR = "author";
    private final static String C_EMAIL = "email";
    private final static String C_DATE = "date";
    private final static String C_MODULE_SESSION_DATA = "module_create_data";
    private final static String C_MODULE_TYPE = "moduletype";
    private final static String C_EXPORTCLASSES = "exportclasses";
    private final static String C_EXPORTLIB = "exportlib";

    /**
     * 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.
     * @param templateSelector template section that should be processed.
     */
    public byte[] getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
        if(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
            CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
            CmsLog.getLog(this).debug("Template file is: " + templateFile);
            CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
        }
        CmsXmlTemplateFile templateDocument = getOwnTemplateFile(cms, templateFile, elementName, parameters, templateSelector);
        I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
        String step = (String)parameters.get(C_STEP);
        SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy");
        if((step == null) || "".equals(step)) {
            templateDocument.setData(C_PACKETNAME, "");
            templateDocument.setData(C_VERSION, "1");
            templateDocument.setData(C_MODULENAME, "");
            templateDocument.setData(C_DESCRIPTION, "");
            templateDocument.setData(C_VIEW, "");
            templateDocument.setData(C_ADMINPOINT, "");
            templateDocument.setData(C_MAINTENANCE, "");
            templateDocument.setData(C_PUBLISHCLASS, "");            
            templateDocument.setData(C_AUTHOR, "");
            templateDocument.setData(C_EMAIL, "");
            templateDocument.setData(C_MODULE_TYPE, "checked");
            templateDocument.setData(C_EXPORTCLASSES, "checked");
            templateDocument.setData(C_EXPORTLIB, "checked");                        
            //  set the current date:
            templateDocument.setData(C_DATE, dateFormat.format(new Date()));
        }else {
            if("OK".equals(step) || "Ok".equals(step)) {
                String modulename = (String)parameters.get(C_PACKETNAME);
                String nicename = (String)parameters.get(C_MODULENAME);
                String version = (String)parameters.get(C_VERSION);
                String description = (String)parameters.get(C_DESCRIPTION);
                String maintenance = (String)parameters.get(C_MAINTENANCE);
                String publishclass = (String)parameters.get(C_PUBLISHCLASS);
                String author = (String)parameters.get(C_AUTHOR);
                String email = (String)parameters.get(C_EMAIL);
                String createDate = (String)parameters.get(C_DATE);
                String moduleType = (String)parameters.get(C_MODULE_TYPE);
                String exportClasses = (String)parameters.get(C_EXPORTCLASSES);
                String exportLib = (String)parameters.get(C_EXPORTLIB);
                String group = "";

                boolean mustExportClasses = ((exportClasses != null) && exportClasses.equals("checked"));
                boolean mustExportLib = ((exportLib != null) && exportLib.equals("checked"));
                
                boolean moduleExists = OpenCms.getModuleManager().hasModule(modulename); 
                
                CmsModuleVersion moduleVersion;
                try {
                    moduleVersion = new CmsModuleVersion(version);
                } catch (IllegalArgumentException e) {
                    moduleVersion = null;
                }
                
                if((!CmsStringUtil.isValidJavaClassName(modulename)) || moduleExists || (moduleVersion == null)) {
                    Hashtable sessionData = new Hashtable();
                    sessionData.put(C_MODULENAME, getStringValue(nicename));
                    sessionData.put(C_VERSION, getStringValue(version));
                    sessionData.put(C_DESCRIPTION, getStringValue(description));
                    sessionData.put(C_VIEW, "");
                    sessionData.put(C_ADMINPOINT, "");
                    sessionData.put(C_MAINTENANCE, getStringValue(maintenance));
                    sessionData.put(C_PUBLISHCLASS, getStringValue(publishclass));                    
                    sessionData.put(C_AUTHOR, getStringValue(author));
                    sessionData.put(C_EMAIL, getStringValue(email));
                    sessionData.put(C_DATE, getStringValue(createDate));
                    sessionData.put(C_MODULE_TYPE, getStringValue(moduleType));
                    session.putValue(C_MODULE_SESSION_DATA, sessionData);
                    if(moduleExists) {
                        templateSelector = "errorexists";
                    }else {
                        templateSelector = "errornoname";
                    }
                }else {
                    tryToCreateFolder(cms, CmsWorkplace.VFS_PATH_SYSTEM, "modules");
                    // create the module (first test if we are in a project including /system/
                    try {

⌨️ 快捷键说明

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