📄 cmsadmindatabase.java
字号:
if (parameters.get("userdata") != null) {
exportUserdata = true;
}
// start the thread for: export
CmsVfsImportExportHandler vfsExportHandler = new CmsVfsImportExportHandler();
vfsExportHandler.setFileName(OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(OpenCms.getSystemInfo().getPackagesRfsPath() + File.separator + fileName));
vfsExportHandler.setExportPaths(Arrays.asList(exportPaths));
vfsExportHandler.setIncludeSystem(!excludeSystem);
vfsExportHandler.setIncludeUnchanged(!excludeUnchanged);
vfsExportHandler.setExportUserdata(exportUserdata);
vfsExportHandler.setContentAge(contentAge);
vfsExportHandler.setDescription("Database VFS export to " + vfsExportHandler.getFileName());
A_CmsReportThread doExport = new CmsExportThread(cms, vfsExportHandler, true);
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
CmsCosImportExportHandler cosExportHandler = new CmsCosImportExportHandler();
cosExportHandler.setFileName(OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(OpenCms.getSystemInfo().getPackagesRfsPath() + File.separator + fileName));
cosExportHandler.setExportChannels(exportChannels);
cosExportHandler.setExportModules(exportModules);
cosExportHandler.setDescription("Database COS export to " + cosExportHandler.getFileName());
A_CmsReportThread doExport = new CmsExportThread(cms, cosExportHandler, true);
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 CmsDatabaseImportThread(cms,
OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(OpenCms.getSystemInfo().getPackagesRfsPath() + existingFile), true);
doImport.start();
session.putValue(C_DATABASE_THREAD, doImport);
xmlTemplateDocument.setData("time", "10");
templateSelector = "showresult";
}
}
} catch (CmsException exc) {
xmlTemplateDocument.setData("details", CmsException.getStackTraceAsString(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 = OpenCms.getSystemInfo().getPackagesRfsPath();
exportpath = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(exportpath);
File folder = new File(exportpath);
if (!folder.exists()) {
folder.mkdirs();
}
// get a list of all files
String[] list = folder.list();
for (int i = 0; i < list.length; i++) {
try {
File diskFile = new File(exportpath, list[i]);
// check if it is a file
if (diskFile.isFile() && diskFile.getName().endsWith(".zip")) {
values.addElement(list[i]);
names.addElement(list[i]);
} else if (diskFile.isDirectory()
&& !diskFile.getName().equalsIgnoreCase("modules")
&& ((new File(diskFile + File.separator + "manifest.xml")).exists())) {
values.addElement(list[i] + "/");
names.addElement(list[i]);
}
} catch (Throwable t) {
// ignore and continue
}
}
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
Iterator it = CmsLegacyModuleAction.getLegacyModulePublishClasses().iterator();
// fill the names and values
while (it.hasNext()) {
String name = (String)it.next();
String value = 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
Iterator it = CmsLegacyModuleAction.getLegacyModulePublishClasses().iterator();
while (it.hasNext()) {
String name = (String)it.next();
String value = 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 + -