📄 cmsadminmoduleadmin.java
字号:
if("edit".equals(from)) {
stepTo = "props";
}
if("propsready".equals(from)) {
// ready; save changes in registry
updateTheModule(cms, sessionData, packetName);
session.removeValue(CmsWorkplaceDefault.C_SESSION_MODULE_ADMIN_DATA);
templateSelector = "done";
}
}
if("firstpage".equals(stepTo)) {
// show the first page
templateDocument.setData(CmsWorkplaceDefault.C_MODULE_PACKETNAME, (String)sessionData.get(CmsWorkplaceDefault.C_MODULE_PACKETNAME));
templateDocument.setData(C_VERSION, (String)sessionData.get(C_VERSION));
templateDocument.setData(C_MODULENAME, (String)sessionData.get(C_MODULENAME));
templateDocument.setData(C_DESCRIPTION, (String)sessionData.get(C_DESCRIPTION));
templateDocument.setData(C_MAINTENANCE, (String)sessionData.get(C_MAINTENANCE));
templateDocument.setData(C_PUBLISHCLASS, (String)sessionData.get(C_PUBLISHCLASS));
templateDocument.setData(C_AUTHOR, (String)sessionData.get(C_AUTHOR));
templateDocument.setData(C_EMAIL, (String)sessionData.get(C_EMAIL));
templateDocument.setData(C_DATE, (String)sessionData.get(C_DATE));
templateDocument.setData("moduletype", "checked");
templateSelector = "";
}
if("deps".equals(stepTo)) {
// show the dependencies
templateDocument.setData(CmsWorkplaceDefault.C_MODULE_PACKETNAME, (String)sessionData.get(CmsWorkplaceDefault.C_MODULE_PACKETNAME));
Vector deps = (Vector)sessionData.get(C_DEPENDENCY);
String entrys = "";
for(int i = 0;i < deps.size();i++) {
templateDocument.setData(C_ONEDEP, (String)deps.elementAt(i));
entrys += templateDocument.getProcessedDataValue(C_OPTIONENTRY);
}
templateDocument.setData(C_ALLDEPS, entrys);
templateSelector = "dependencies";
}
if("props".equals(stepTo)) {
// prepare the properties page
templateSelector = "properties";
}
// Now load the template file and start the processing
return startProcessing(cms, templateDocument, elementName, parameters, templateSelector);
}
/**
* returns the String or "" if it is null.
* Creation date: (29.10.00 16:05:38)
* @return java.lang.String
* @param param java.lang.String
*/
private String getStringValue(String param) {
if(param == null) {
return "";
}
return param;
}
/**
* Indicates if the results of this class are cacheable.
*
* @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.
* @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
*/
public boolean isCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
return false;
}
/** Parse the string which holds all dependencies
*
* @param resources containts the full pathnames of all the resources, separated by semicolons
* @return A vector with the same resources
*/
private Vector parseAllDeps(String resources) {
Vector ret = new Vector();
if(resources != null) {
StringTokenizer resTokenizer = new StringTokenizer(resources, ";");
while(resTokenizer.hasMoreElements()) {
String path = (String)resTokenizer.nextElement();
ret.addElement(path);
}
}
return ret;
}
/**
* Insert the method's description here.
* Creation date: (03.11.00 08:23:13)
* @param param org.opencms.file.CmsObject
* @param folder java.lang.String
* @param newFolder java.lang.String
*/
private void tryToCreateFolder(CmsObject cms, String folder, String newFolder) {
try {
cms.createResource(folder + newFolder, CmsResourceTypeFolder.RESOURCE_TYPE_ID);
}catch(Exception e) {
}
}
/**
* fills the data from the hashtable in the module.
* Creation date: (30.10.00 14:22:22)
* @param param java.lang.String
* @return java.util.Hashtable
*/
private void updateTheModule(CmsObject cms, Hashtable table, String module) {
SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy");
String name = (String)table.get(CmsWorkplaceDefault.C_MODULE_PACKETNAME);
try {
// set the module version
CmsModuleVersion version = new CmsModuleVersion((String)table.get(C_VERSION));
// the easy values
String niceName = (String)table.get(C_MODULENAME);
String group = (String)table.get(C_GROUP);
String description = (String)table.get(C_DESCRIPTION);
String moduleClass = (String)table.get(C_PUBLISHCLASS);
String moduleAuthor = (String)table.get(C_AUTHOR);
String moduleEmail = (String)table.get(C_EMAIL);
// set the date, if the value is not correct set the current date
String date = (String)table.get(C_DATE);
long moduleDateCreated = 0;
try {
moduleDateCreated = dateFormat.parse(date).getTime();
}catch(Exception exc) {
moduleDateCreated = (new Date()).getTime();
}
// now the dependnecies
Vector stringDeps = (Vector)table.get(C_DEPENDENCY);
List dependencies = new ArrayList();
for(int i = 0;i < stringDeps.size();i++) {
String complString = (String)stringDeps.elementAt(i);
complString = complString.substring(0, complString.lastIndexOf("-") - 1);
String min = complString.substring(complString.lastIndexOf(":") + 1);
String depName = (complString.substring(0, complString.lastIndexOf("Version:") - 1)).trim();
dependencies.add(new CmsModuleDependency(depName, new CmsModuleVersion(String.valueOf(min))));
}
// last not least: the properties
Vector paraNames = (Vector)table.get(CmsWorkplaceDefault.C_SESSION_MODULE_ADMIN_PROP_NAMES);
Vector paraVal = (Vector)table.get(CmsWorkplaceDefault.C_SESSION_MODULE_ADMIN_PROP_VAL);
Map parameters = new HashMap();
for (int i=0; i<paraNames.size(); i++) {
String key = (String)paraNames.get(i);
parameters.put(key, paraVal.get(i));
}
CmsModule currentModule = OpenCms.getModuleManager().getModule(name);
CmsModule updatedModule =
new CmsModule(
name,
niceName,
group,
moduleClass,
description,
version,
moduleAuthor,
moduleEmail,
moduleDateCreated,
currentModule.getUserInstalled(),
currentModule.getDateInstalled(),
dependencies,
currentModule.getExportPoints(),
currentModule.getResources(),
parameters);
updatedModule.setResourceTypes(currentModule.getResourceTypes());
updatedModule.setExplorerTypes(currentModule.getExplorerTypes());
OpenCms.getModuleManager().updateModule(cms, updatedModule);
} catch (CmsException e) {
if(CmsLog.getLog(this).isErrorEnabled()) {
CmsLog.getLog(this).error("Error in module administration", e);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -