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; ...@@ -19,6 +19,7 @@ import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jivesoftware.messenger.XMPPServer; import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.container.Plugin; import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager; import org.jivesoftware.messenger.container.PluginManager;
...@@ -31,7 +32,6 @@ import org.jivesoftware.messenger.user.UserNotFoundException; ...@@ -31,7 +32,6 @@ import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.user.UserProvider; import org.jivesoftware.messenger.user.UserProvider;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLWriter;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
/** /**
...@@ -46,10 +46,10 @@ import org.xmpp.packet.JID; ...@@ -46,10 +46,10 @@ import org.xmpp.packet.JID;
public class ImportExportPlugin implements Plugin { public class ImportExportPlugin implements Plugin {
private UserManager userManager; private UserManager userManager;
private PluginManager pluginManager; private PluginManager pluginManager;
private static UserProvider provider; private UserProvider provider;
private static String serverName; private String serverName;
private static String exportDirectory; private String exportDirectory;
public ImportExportPlugin() { public ImportExportPlugin() {
userManager = XMPPServer.getInstance().getUserManager(); userManager = XMPPServer.getInstance().getUserManager();
...@@ -94,7 +94,7 @@ public class ImportExportPlugin implements Plugin { ...@@ -94,7 +94,7 @@ public class ImportExportPlugin implements Plugin {
return provider.isReadOnly(); return provider.isReadOnly();
} }
public static String exportDirectory() { public String exportDirectory() {
return exportDirectory; return exportDirectory;
} }
...@@ -134,7 +134,7 @@ public class ImportExportPlugin implements Plugin { ...@@ -134,7 +134,7 @@ public class ImportExportPlugin implements Plugin {
writer.close(); writer.close();
} }
} }
return stringWriter.toString(); return stringWriter.toString();
} }
...@@ -340,3 +340,4 @@ public class ImportExportPlugin implements Plugin { ...@@ -340,3 +340,4 @@ public class ImportExportPlugin implements Plugin {
return null; return null;
} }
} }
...@@ -25,7 +25,7 @@ public class UserSchemaValidator { ...@@ -25,7 +25,7 @@ public class UserSchemaValidator {
private Document doc; private Document doc;
private String schema; 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 usersURL = new File(usersFile).toURL();
URL schemaURL = this.getClass().getClassLoader().getResource(schemaFile); URL schemaURL = this.getClass().getClassLoader().getResource(schemaFile);
...@@ -34,7 +34,7 @@ public class UserSchemaValidator { ...@@ -34,7 +34,7 @@ public class UserSchemaValidator {
schema = schemaURL.toExternalForm(); schema = schemaURL.toExternalForm();
} }
public boolean validate() { boolean validate() {
try { try {
SAXParserFactory saxFactory = SAXParserFactory.newInstance(); SAXParserFactory saxFactory = SAXParserFactory.newInstance();
saxFactory.setNamespaceAware(true); saxFactory.setNamespaceAware(true);
......
...@@ -6,28 +6,27 @@ ...@@ -6,28 +6,27 @@
org.jivesoftware.util.ParamUtils" org.jivesoftware.util.ParamUtils"
%> %>
<%-- Define Administration Bean --%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" /> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<c:set var="admin" value="${admin.manager}" />
<% admin.init(request, response, session, application, out ); %>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% <%
admin.init(request, response, session, application, out);
boolean exportUsers = request.getParameter("exportUsers") != null; boolean exportUsers = request.getParameter("exportUsers") != null;
boolean success = request.getParameter("success") != null; boolean success = request.getParameter("success") != null;
boolean exportToFile = ParamUtils.getBooleanParameter(request, "exporttofile", true);
boolean exportToFile = ParamUtils.getBooleanParameter(request, "exporttofile", false);
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(); Map errors = new HashMap();
if (exportUsers) { if (exportUsers) {
if (exportToFile) { if (exportToFile) {
String file = ParamUtils.getParameter(request, "exportFile"); String file = ParamUtils.getParameter(request, "exportFile");
if ((file == null) || (file.length() <= 0)) { if ((file == null) || (file.length() <= 0)) {
errors.put("missingFile","missingFile"); errors.put("missingFile","missingFile");
} }
else { else {
try { try {
...@@ -46,7 +45,12 @@ ...@@ -46,7 +45,12 @@
} }
} }
else { else {
exportText = plugin.exportUsersToString(); try {
exportText = plugin.exportUsersToString();
}
catch (IOException e) {
errors.put("IOException","IOException");
}
} }
} }
%> %>
...@@ -83,7 +87,7 @@ ...@@ -83,7 +87,7 @@
</div> </div>
<br> <br>
<% } else if ("true".equals(request.getParameter("success"))) { %> <% } else if (ParamUtils.getBooleanParameter(request, "success")) { %>
<div class="jive-success"> <div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0"> <table cellpadding="0" cellspacing="0" border="0">
...@@ -109,7 +113,7 @@ ...@@ -109,7 +113,7 @@
<tbody> <tbody>
<tr> <tr>
<td width="1%"> <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>
<td width="99%"> <td width="99%">
<label for="rb01"><b>To File</b></label> - Save user data to the specified file location. <label for="rb01"><b>To File</b></label> - Save user data to the specified file location.
...@@ -127,16 +131,16 @@ ...@@ -127,16 +131,16 @@
</tr> </tr>
<tr> <tr>
<td width="1%"> <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>
<td width="99%"> <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> </td>
</tr> </tr>
<tr> <tr>
<td width="1%">&nbsp;</td> <td width="1%">&nbsp;</td>
<td width="99%"> <td width="99%">
<textarea cols="80" rows="20" wrap=off><%=(exportText == null) ? "" : exportText %></textarea> <textarea cols="80" rows="20" wrap=off><%=exportText %></textarea>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
</div> </div>
<br> <br>
<% } else if ("true".equals(request.getParameter("success"))) { %> <% } else if (ParamUtils.getBooleanParameter(request, "success")) { %>
<div class="jive-success"> <div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0"> <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