Commit 3e474ee5 authored by Ryan Graham's avatar Ryan Graham Committed by ryang

fixed compatibility issues with Messenger 2.1.4/5

improved error handling and logging


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1560 b35dd754-fafc-0310-a699-88a17e54d16e
parent 08bc139e
......@@ -19,6 +19,7 @@ import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager;
......@@ -31,7 +32,6 @@ import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.user.UserProvider;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLWriter;
import org.xmpp.packet.JID;
/**
......@@ -46,10 +46,10 @@ import org.xmpp.packet.JID;
public class ImportExportPlugin implements Plugin {
private UserManager userManager;
private PluginManager pluginManager;
private static UserProvider provider;
private UserProvider provider;
private static String serverName;
private static String exportDirectory;
private String serverName;
private String exportDirectory;
public ImportExportPlugin() {
userManager = XMPPServer.getInstance().getUserManager();
......@@ -94,7 +94,7 @@ public class ImportExportPlugin implements Plugin {
return provider.isReadOnly();
}
public static String exportDirectory() {
public String exportDirectory() {
return exportDirectory;
}
......@@ -134,7 +134,7 @@ public class ImportExportPlugin implements Plugin {
writer.close();
}
}
return stringWriter.toString();
}
......@@ -340,3 +340,4 @@ public class ImportExportPlugin implements Plugin {
return null;
}
}
......@@ -25,7 +25,7 @@ public class UserSchemaValidator {
private Document doc;
private String schema;
public UserSchemaValidator(String usersFile, String schemaFile) throws MalformedURLException, DocumentException {
UserSchemaValidator(String usersFile, String schemaFile) throws MalformedURLException, DocumentException {
URL usersURL = new File(usersFile).toURL();
URL schemaURL = this.getClass().getClassLoader().getResource(schemaFile);
......@@ -34,7 +34,7 @@ public class UserSchemaValidator {
schema = schemaURL.toExternalForm();
}
public boolean validate() {
boolean validate() {
try {
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
saxFactory.setNamespaceAware(true);
......
......@@ -6,28 +6,27 @@
org.jivesoftware.util.ParamUtils"
%>
<%-- Define Administration Bean --%>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<c:set var="admin" value="${admin.manager}" />
<% admin.init(request, response, session, application, out ); %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<%
admin.init(request, response, session, application, out);
boolean exportUsers = request.getParameter("exportUsers") != null;
boolean success = request.getParameter("success") != null;
boolean exportToFile = ParamUtils.getBooleanParameter(request, "exporttofile", false);
boolean exportToFile = ParamUtils.getBooleanParameter(request, "exporttofile", true);
ImportExportPlugin plugin = (ImportExportPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("userimportexport");
ImportExportPlugin plugin = (ImportExportPlugin) admin.getXMPPServer().getPluginManager().getPlugin("userimportexport");
String exportText = null;
String exportText = "";
Map errors = new HashMap();
if (exportUsers) {
if (exportToFile) {
String file = ParamUtils.getParameter(request, "exportFile");
if ((file == null) || (file.length() <= 0)) {
errors.put("missingFile","missingFile");
errors.put("missingFile","missingFile");
}
else {
try {
......@@ -46,7 +45,12 @@
}
}
else {
exportText = plugin.exportUsersToString();
try {
exportText = plugin.exportUsersToString();
}
catch (IOException e) {
errors.put("IOException","IOException");
}
}
}
%>
......@@ -83,7 +87,7 @@
</div>
<br>
<% } else if ("true".equals(request.getParameter("success"))) { %>
<% } else if (ParamUtils.getBooleanParameter(request, "success")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
......@@ -109,7 +113,7 @@
<tbody>
<tr>
<td width="1%">
<input type="radio" name="exporttofile" value="true" selected id="rb01">
<input type="radio" name="exporttofile" value="true" <%= exportToFile ? "checked" : "" %> id="rb01">
</td>
<td width="99%">
<label for="rb01"><b>To File</b></label> - Save user data to the specified file location.
......@@ -127,16 +131,16 @@
</tr>
<tr>
<td width="1%">
<input type="radio" name="exporttofile" value="false" id="rb02">
<input type="radio" name="exporttofile" value="false" <%= !exportToFile ? "checked" : "" %> id="rb02">
</td>
<td width="99%">
<label for="rb02"><b>To Screen</b></label> - Dispaly user data in the text area below.
<label for="rb02"><b>To Screen</b></label> - Display user data in the text area below.
</td>
</tr>
<tr>
<td width="1%">&nbsp;</td>
<td width="99%">
<textarea cols="80" rows="20" wrap=off><%=(exportText == null) ? "" : exportText %></textarea>
<textarea cols="80" rows="20" wrap=off><%=exportText %></textarea>
</td>
</tr>
</tbody>
......
......@@ -97,7 +97,7 @@
</div>
<br>
<% } else if ("true".equals(request.getParameter("success"))) { %>
<% } else if (ParamUtils.getBooleanParameter(request, "success")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment