📄 cmsadminmodulenew.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsAdminModuleNew.java,v $
* Date : $Date: 2004/01/07 10:57:09 $
* Version: $Revision: 1.19.2.1 $
*
* 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 com.opencms.boot.I_CmsLogChannels;
import com.opencms.core.A_OpenCms;
import com.opencms.core.CmsException;
import com.opencms.core.I_CmsConstants;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsObject;
import com.opencms.file.I_CmsRegistry;
import com.opencms.report.A_CmsReportThread;
import com.opencms.template.CmsXmlTemplateFile;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;
import java.util.Vector;
/**
* Template class for displaying OpenCms workplace admin module screens.
*
* Creation date: (01.09.00 12:55:58)
* @author Hanjo Riege
*/
public class CmsAdminModuleNew extends CmsWorkplaceDefault implements I_CmsConstants {
/**
* the different templateselectors.
*/
private final String C_DONE = "done";
private final String C_FILES = "files";
private final String C_FROMERRORPAGE = "fromerrorpage";
private final String C_ERRORREPLACE = "errorreplace";
private final String C_ERRORDEP = "errordep";
/**
* const for session entrys.
*/
private final String C_MODULE_NAV = "modulenav";
private final String C_MODULE_FILENAME = "modulefilename";
private final String C_MODULE_NAME = "modulename";
private final String C_MODULE_THREAD = "modulethread";
/**
* 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(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() && C_DEBUG ) {
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "getting content of element " + ((elementName == null) ? "<root>" : elementName));
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "template file is: " + templateFile);
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "selected template section is: " + ((templateSelector == null) ? "<default>" : templateSelector));
}
CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms, templateFile);
// get the registry
I_CmsRegistry reg = cms.getRegistry();
I_CmsSession session = cms.getRequestContext().getSession(true);
String errorNavigation = (String)parameters.get(C_FROMERRORPAGE);
if(errorNavigation != null) {
templateSelector = importModule(cms, reg, xmlTemplateDocument, session, null);
return startProcessing(cms, xmlTemplateDocument, elementName, parameters, templateSelector);
}
String step = (String)parameters.get("step");
// first look if there is already a thread running.
if("showResult".equals(step)){
A_CmsReportThread doTheWork = (A_CmsReportThread)session.getValue(C_MODULE_THREAD);
if(doTheWork.isAlive()){
// thread is still running
xmlTemplateDocument.setData("endMethod", "");
xmlTemplateDocument.setData("text", "");
} else {
// thread is finished, activate the buttons
xmlTemplateDocument.setData("endMethod", xmlTemplateDocument.getDataValue("endMethod"));
xmlTemplateDocument.setData("autoUpdate","");
xmlTemplateDocument.setData("text", xmlTemplateDocument.getLanguageFile().getLanguageValue("module.lable.importend"));
session.removeValue(C_MODULE_THREAD);
}
xmlTemplateDocument.setData("data", doTheWork.getReportUpdate());
return startProcessing(cms, xmlTemplateDocument, elementName, parameters, "updateReport");
} else if ("server".equals(step)) {
File modulefolder =
new File(
com.opencms.boot.CmsBase.getAbsolutePath(cms.readExportPath())
+ "/"
+ I_CmsRegistry.C_MODULE_PATH);
if (!modulefolder.exists()) {
boolean success = modulefolder.mkdir();
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING
&& A_OpenCms.isLogging()
&& (!success)) {
A_OpenCms.log(
I_CmsLogChannels.C_OPENCMS_INFO,
"[CmsAccessFilesystem] Couldn't create folder "
+ com.opencms.boot.CmsBase.getAbsolutePath(cms.readExportPath())
+ "/"
+ I_CmsRegistry.C_MODULE_PATH
+ ".");
}
}
String listentrys = "";
if (modulefolder.exists()) {
String[] modules = modulefolder.list();
for (int i = 0; i < modules.length; i++) {
xmlTemplateDocument.setData("modulname", modules[i]);
listentrys += xmlTemplateDocument.getProcessedDataValue("optionentry");
}
}
xmlTemplateDocument.setData("entries", listentrys);
templateSelector = "server";
} else if ("local".equals(step)) {
templateSelector = "local";
} else if ("localupload".equals(step)) {
// get the filename
String filename = null;
Enumeration files = cms.getRequestContext().getRequest().getFileNames();
while (files.hasMoreElements()) {
filename = (String) files.nextElement();
}
if (filename != null) {
session.putValue(C_PARA_FILE, filename.trim());
}
filename = (String) session.getValue(C_PARA_FILE);
// get the filecontent
byte[] filecontent = new byte[0];
if (filename != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -