📄 cmsadmindatabase.java
字号:
boolean exportUserdata = false;
if (parameters.get("userdata") != null) {
exportUserdata = true;
}
// start the thread for: export
A_CmsReportThread doExport = new CmsAdminDatabaseExportThread(cms,
CmsBase.getAbsolutePath(cms.readExportPath()) + File.separator + fileName,
exportPaths, excludeSystem, excludeUnchanged, exportUserdata, contentAge);
doExport.start();
session.putValue(C_DATABASE_THREAD, doExport);
xmlTemplateDocument.setData("time", "10");
xmlTemplateDocument.setData("contentage", "" + contentAge);
xmlTemplateDocument.setData("currenttime", "" + System.currentTimeMillis());
templateSelector = "showresult";
} else if("exportmoduledata".equals(action)) {
// export the COS and the COS data
Vector channelNames = parseResources(allResources);
String[] exportChannels = new String[channelNames.size()];
for (int i = 0;i < channelNames.size();i++) {
// modify the foldername if nescessary (the root folder is always given
// as a nice name)
if(lang.getLanguageValue("title.rootfolder").equals(channelNames.elementAt(i))) {
channelNames.setElementAt("/", i);
}
exportChannels[i] = (String)channelNames.elementAt(i);
}
// get the selected modulenames
Vector moduleNames = parseResources(allModules);
String[] exportModules = new String[moduleNames.size()];
for (int i = 0;i < moduleNames.size();i++) {
exportModules[i] = (String)moduleNames.elementAt(i);
}
// start the thread for: exportmodules
A_CmsReportThread doExport = new CmsAdminDatabaseExportThread(cms,
CmsBase.getAbsolutePath(cms.readExportPath()) + File.separator + fileName,
exportChannels, exportModules);
doExport.start();
session.putValue(C_DATABASE_THREAD, doExport);
xmlTemplateDocument.setData("time", "10");
xmlTemplateDocument.setData("currenttime", "" + System.currentTimeMillis());
templateSelector = "showresult";
} else if("import".equals(action)) {
// look for the step
if ("local".equals(step) || "server".equals(step)){
templateSelector = step;
} else if("localupload".equals(step)){
// get the filename and set step to 'go'
existingFile = copyFileToServer(cms, session);
step = "go";
}
if ("go".equals(step) ){
// start the thread for: import
A_CmsReportThread doImport = new CmsAdminDatabaseImportThread(cms,
CmsBase.getAbsolutePath(cms.readExportPath()) + File.separator + existingFile);
doImport.start();
session.putValue(C_DATABASE_THREAD, doImport);
xmlTemplateDocument.setData("time", "10");
templateSelector = "showresult";
}
}
} catch (CmsException exc) {
xmlTemplateDocument.setData("details", Utils.getStackTrace(exc));
templateSelector = "error";
}
// now load the template file and start the processing
return startProcessing (cms, xmlTemplateDocument, elementName, parameters, templateSelector);
}
/**
* Gets all export-files from the export-path.<p>
*
* The given vectors <code>names</code> and <code>values</code> will
* be filled with the appropriate information to be used for building
* a select box.<p>
*
* <code>names</code> will contain language specific view descriptions
* and <code>values</code> will contain the correspondig URL for each
* of these views after returning from this method.<p>
*
* @param cms CmsObject Object for accessing system resources.
* @param lang reference to the currently valid language file
* @param names Vector to be filled with the appropriate values in this method.
* @param values Vector to be filled with the appropriate values in this method.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return Index representing the user's current filter view in the vectors.
* @throws CmsException
*/
public Integer getExportFiles(
CmsObject cms,
CmsXmlLanguageFile lang,
Vector values,
Vector names,
Hashtable parameters
) throws CmsException {
// get the systems-exportpath
String exportpath = cms.readExportPath();
exportpath = CmsBase.getAbsolutePath(exportpath);
File folder = new File(exportpath);
if (!folder.exists()) {
folder.mkdirs();
}
// get a list of all files
String[] list = folder.list(new FilenameFilter() {
public boolean accept(File dir, String fileName) {
return (fileName.endsWith(".zip"));
}
});
for (int i = 0; i < list.length; i++) {
File diskFile = new File(exportpath, list[i]);
// check if it is a file
if (diskFile.isFile()) {
values.addElement(list[i]);
names.addElement(list[i]);
}
}
return new Integer(0);
}
/**
* Indicates that the results of this class are not cacheable.<p>
*
* @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 <code>false</code>
*/
public boolean isCacheable(
CmsObject cms,
String templateFile,
String elementName,
Hashtable parameters,
String templateSelector
) {
return false;
}
/**
* Gets all exportable modules for a select box.<p>
*
* The given vectors <code>names</code> and <code>values</code> will
* be filled with the appropriate information to be used for building
* a select box.<p>
*
* @param cms CmsObject Object for accessing system resources.
* @param names Vector to be filled with the appropriate values in this method.
* @param values Vector to be filled with the appropriate values in this method.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return Index representing the current value in the vectors.
* @throws CmsException
*/
public int getModules(
CmsObject cms,
CmsXmlLanguageFile lang,
Vector names,
Vector values,
Hashtable parameters
) throws CmsException {
// get all exportable modules
Hashtable modules = new Hashtable();
cms.getRegistry().getModuleExportables(modules);
Enumeration keys = modules.keys();
// fill the names and values
while (keys.hasMoreElements()) {
String name = (String)keys.nextElement();
String value = (String)modules.get(name);
names.addElement(name);
values.addElement(value);
}
return 0;
}
/**
* Gets all exportable modules for a select box.<p>
*
* The method returns a string with option tags that contains the module information
* to be used for building a select box.<p>
*
* @param cms CmsObject Object for accessing system resources.
* @param template The current template
* @return String with the modules optiontags.
* @throws CmsException
*/
public String getModuleSelectbox(
CmsObject cms,
CmsXmlWpTemplateFile template
) throws CmsException {
StringBuffer selectBox = new StringBuffer();
if (template.hasData("selectoption")) {
// get all exportable modules
Hashtable modules = new Hashtable();
cms.getRegistry().getModuleExportables(modules);
Enumeration keys = modules.keys();
// fill the names and values
while (keys.hasMoreElements()) {
String name = (String)keys.nextElement();
String value = (String)modules.get(name);
template.setData("name", name);
template.setData("value", value);
try {
selectBox.append(template.getProcessedDataValue("selectoption", this));
} catch (Exception e) {
// do not throw exception because selectbox might not exist
}
}
}
return selectBox.toString();
}
/**
* Parse the string which holds all resources.<p>
*
* @param resources containts the full pathnames of all the resources, separated by semicolons
* @return A vector with the same resources
*/
private Vector parseResources(
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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -