一个jive论坛管理的源码
学习Jive源程序
源代码在线查看: data.jsp
/**
* $RCSfile: data.jsp,v $
* $Revision: 1.1.1.1 $
* $Date: 2002/09/09 13:50:10 $
*/
%>
java.util.*,
java.text.*,
com.jivesoftware.util.*,
com.jivesoftware.forum.*,
com.jivesoftware.forum.database.*,
com.jivesoftware.forum.util.*"
errorPage="error.jsp"
%>
// Date formatter for filenames
final static SimpleDateFormat fileDateFormatter =
new SimpleDateFormat("yyyy-MM-dd");
final static DecimalFormat megFormatter = new DecimalFormat("0.00");
final static DecimalFormat kFormatter = new DecimalFormat("0.00");
%>
boolean export = ParamUtils.getBooleanParameter(request,"export");
boolean doImport = ParamUtils.getBooleanParameter(request,"import");
String filename = ParamUtils.getParameter(request,"filename");
// Do an export
if (export) {
DbForumFactory dbForumFactory = (DbForumFactory)(((ForumFactoryProxy)forumFactory).getProxiedForumFactory());
DbDataExport exporter = new DbDataExport(dbForumFactory);
exporter.export(false);
response.sendRedirect("data.jsp");
return;
}
// Do an import
if (doImport) {
DbForumFactory dbForumFactory = (DbForumFactory)(((ForumFactoryProxy)forumFactory).getProxiedForumFactory());
DbDataImport importer = new DbDataImport(dbForumFactory);
Reader in = new BufferedReader(new InputStreamReader(new FileInputStream(
new File(JiveGlobals.getJiveHome() + System.getProperty("file.separator")
+ "data" + System.getProperty("file.separator") + filename)),"UTF8"));
importer.doImport(in);
System.out.println("**DEBUG**:import data !");
response.sendRedirect("data.jsp");
return;
}
%>
String title = "数据导入 & 导出";
String[][] breadcrumbs = {
{"主页面", "main.jsp"},
{title, "data.jsp"}
};
%>
数据导入和导出功能允许你向Jive论坛中写入数据或者从中读取数据。所有的数据都使用Jive XML 格式。
导入数据
请从以下文件中选择一个导入。
文件名
大小
try {
File dataDir = new File(JiveGlobals.getJiveHome() + System.getProperty("file.separator") + "data");
String[] filenames = dataDir.list();
for (int i=0; i if (filenames[i].endsWith(".xml")) {
foundXMLFiles = true;
File xmlFile = new File(dataDir, filenames[i]);
double size = xmlFile.length();
String displaySize = "";
if ((size/(1024.0*1024.0)) < 1.0) {
displaySize = kFormatter.format(size/(1024.0)) + " K";
}
else {
displaySize = megFormatter.format(size/(1024.0*1024.0)) + " MB";
}
%>
}
}
}
catch (Exception e) {}
if (!foundXMLFiles) {
%>
没有可导入的文件。
}
%>
导出数据
%>
将当前数据导出到: