Commit 1776b9e4 authored by Ryan Graham's avatar Ryan Graham Committed by ryang

* Added the ability to allow users to specify the import and export file locations

* JM-369
* Added additional information to the migration section of the readme file

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2755 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7e45a0a4
......@@ -2,41 +2,46 @@
<html>
<head>
<title>User Import/Export Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
<title>User Import/Export Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
TT {
font-family : courier new;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new;
font-size : 100%;
}
</style>
</head>
<body>
......@@ -44,11 +49,18 @@
User Import/Export Plugin Changelog
</h1>
<p><b>2.0</b> -- September 1, 2005</p>
<ul>
<li>Added the ability to allow users to specify the import and export file locations.
<li>[<a href="http://www.jivesoftware.org/issues/browse/JM-369">JM-369</a>] - Add option to replace old domain with new domain while doing an import.
<li>Added additional information to the migration section of the readme file.
</ul>
<p><b>1.0.1</b> -- June 30, 2005</p>
<ul>
<li>Added the ability to send export data directly to the screen.</li>
<li>Fixed compatibility issue with Messenger version 2.1.4 and 2.1.5.</li>
<li>Refactored the code that creates the output directory to try and alleviate permission issues on Unix installations.</li>
<li>Added the ability to send export data directly to the screen.</li>
<li>Fixed compatibility issue with Messenger version 2.1.4 and 2.1.5.</li>
<li>Refactored the code that creates the output directory to try and alleviate permission issues on Unix installations.</li>
</ul>
<p><b>1.0</b> -- June 1, 2005</p>
......
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>org.jivesoftware.messenger.plugin.ImportExportPlugin</class>
<class>org.jivesoftware.messenger.plugin.ImportExportPlugin</class>
<name>User Import Export</name>
<description>Enables import and export of user data.</description>
<author>Ryan Graham</author>
<version>1.0.1</version>
<date>06/30/2005</date>
<minServerVersion>2.1.4</minServerVersion>
<description>Enables import and export of user data.</description>
<author>Ryan Graham</author>
<version>2.0</version>
<date>09/01/2005</date>
<minServerVersion>2.1.5</minServerVersion>
<adminconsole>
<tab id="tab-users">
<adminconsole>
<tab id="tab-users">
<sidebar id="user-import-export" name="Import &amp; Export">
<item id="import-export-selection" name="User Import &amp; Export"
url="import-export-selection.jsp"
description="Allows the importing and exporting of Messenger user data." />
</sidebar>
</tab>
</adminconsole>
</plugin>
\ No newline at end of file
url="import-export-selection.jsp"
description="Allows the importing and exporting of Messenger user data." />
</sidebar>
</tab>
</adminconsole>
</plugin>
This diff is collapsed.
package org.jivesoftware.messenger.plugin;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.parsers.SAXParserFactory;
import com.sun.msv.reader.util.GrammarLoader;
import com.sun.msv.reader.util.IgnoreController;
import com.sun.msv.verifier.DocumentDeclaration;
import com.sun.msv.verifier.Verifier;
import org.dom4j.Document;
import org.dom4j.DocumentException;
......@@ -16,10 +15,11 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
import com.sun.msv.reader.util.GrammarLoader;
import com.sun.msv.reader.util.IgnoreController;
import com.sun.msv.verifier.DocumentDeclaration;
import com.sun.msv.verifier.Verifier;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.parsers.SAXParserFactory;
public class UserSchemaValidator {
private Document doc;
......
<%@ page import="java.io.IOException,
java.util.*,
org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.messenger.XMPPServer,
org.jivesoftware.util.ParamUtils"
java.util.*,
org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.messenger.XMPPServer,
org.jivesoftware.util.ParamUtils"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
......@@ -11,7 +11,7 @@
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<%
admin.init(request, response, session, application, out);
admin.init(request, response, session, application, out);
boolean exportUsers = request.getParameter("exportUsers") != null;
boolean success = request.getParameter("success") != null;
......@@ -21,41 +21,28 @@
String exportText = "";
Map errors = new HashMap();
Map<String, String> errors = new HashMap<String, String>();
if (exportUsers) {
if (exportToFile) {
String file = ParamUtils.getParameter(request, "exportFile");
if ((file == null) || (file.length() <= 0)) {
errors.put("missingFile","missingFile");
}
else {
try {
//todo this could take some, redirect to a progress page?
if (plugin.exportUsersToFile(file)) {
response.sendRedirect("export-user-data.jsp?success=true");
return;
}
else {
errors.put("fileNotCreated","fileNotCreated");
}
}
catch (IOException e) {
errors.put("IOException","IOException");
}
}
String file = ParamUtils.getParameter(request, "exportFile");
if ((file == null) || (file.length() <= 0)) {
errors.put("missingFile","missingFile");
}
else {
response.sendRedirect("export-file.jsp?fileName="+file);
}
}
else {
try {
exportText = plugin.exportUsersToString();
exportText = plugin.exportUsersToString();
}
catch (IOException e) {
errors.put("IOException","IOException");
}
catch (IOException e) {
errors.put("IOException","IOException");
}
}
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Export User Data";
......@@ -73,14 +60,14 @@
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("missingFile")) { %>
Missing or bad file name.
<% } else if (errors.containsKey("IOException") || errors.containsKey("fileNotCreated")) { %>
Couldn't create export file.
<% } %>
</td>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("missingFile")) { %>
Missing or bad file name.
<% } else if (errors.containsKey("IOException") || errors.containsKey("fileNotCreated")) { %>
Couldn't create export file.
<% } %>
</td>
</tr>
</tbody>
</table>
......@@ -93,8 +80,8 @@
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">User data successfully exported.</td>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">User data successfully exported.</td>
</tr>
</tbody>
</table>
......@@ -107,49 +94,37 @@
<fieldset>
<legend>Export Options</legend>
<div>
<div>
<p>
Select the radio button next to the desired export option and then click on the Export button.
</p>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="1%">
<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.
</td>
<tr>
<td width="1%">&nbsp;</td>
<td width="99%">
<%= plugin.exportDirectory() %>
</td>
</tr>
<tr>
<td width="1%">&nbsp;</td>
<td width="99%">Export File Name:&nbsp;<input type="text" size="30" maxlength="150" name="exportFile"></td>
</tr>
<td width="1%"><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.</td>
</tr>
<tr>
<td width="1%">
<input type="radio" name="exporttofile" value="false" <%= !exportToFile ? "checked" : "" %> id="rb02">
</td>
<td width="99%">
<label for="rb02"><b>To Screen</b></label> - Display user data in the text area below.
</td>
<td width="1%">&nbsp;</td>
<td width="99%">Export File Name:&nbsp;<input type="text" size="30" maxlength="150" name="exportFile"></td>
</tr>
<tr>
<td width="1%"><input type="radio" name="exporttofile" value="false" <%= !exportToFile ? "checked" : "" %> id="rb02"></td>
<td width="99%"><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 %></textarea>
</td>
<td width="1%">&nbsp;</td>
<td width="99%"><textarea cols="80" rows="20" wrap=off><%=exportText %></textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
</fieldset>
<br><br>
<input type="submit" value="Export">
</form>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<jsp:include page="bottom.jsp" flush="true" />
<%@ page import="org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.messenger.XMPPServer"
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.messenger.XMPPServer"
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
......@@ -20,7 +20,7 @@
<% if (plugin.isUserProviderReadOnly()) { %>
Sorry, because you are using LDAP as your user store this plugin will not work with your Messenger installation.
Sorry, because you are using LDAP as your user store, this plugin will not work with your Messenger installation.
<% } else { %>
......@@ -28,10 +28,10 @@ The import and export functions allow you to read data into and write user
data from your Jive Messenger installation.
<ul>
<li><a href="import-user-data.jsp">Import User Data</a></li>
<li><a href="import-user-data.jsp">Import User Data</a></li>
<li><a href="export-user-data.jsp">Export User Data</a></li>
</ul>
<% } %>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<jsp:include page="bottom.jsp" flush="true" />
<%@ page import="java.io.IOException,
java.net.MalformedURLException,
java.util.*,
org.dom4j.DocumentException,
org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.messenger.XMPPServer,
org.jivesoftware.util.ParamUtils"
<%@ page import="java.net.MalformedURLException,
java.util.*,
org.dom4j.DocumentException,
org.apache.commons.fileupload.DiskFileUpload,
org.apache.commons.fileupload.FileItem,
org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.plugin.ImportExportPlugin,
org.jivesoftware.util.ParamUtils"
%>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<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 importUsers = request.getParameter("importUsers") != null;
boolean success = request.getParameter("success") != null;
ImportExportPlugin plugin = (ImportExportPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("userimportexport");
List duplicateUsers = new ArrayList();
Map errors = new HashMap();
ImportExportPlugin plugin = (ImportExportPlugin) admin.getXMPPServer().getPluginManager().getPlugin("userimportexport");
List<String> duplicateUsers = new ArrayList<String>();
Map<String, String> errors = new HashMap<String, String>();
if (importUsers) {
String file = ParamUtils.getParameter(request, "importFile");
if ((file == null) || (file.length() <= 0)) {
errors.put("badFile", "badFile");
DiskFileUpload dfu = new DiskFileUpload();
List fileItems = dfu.parseRequest(request);
Iterator i = fileItems.iterator();
FileItem fi = (FileItem) i.next();
FileItem pd = (FileItem) i.next();
String previousDomain = pd.getString();
try {
if (isEmpty(previousDomain)) {
duplicateUsers.addAll(plugin.importUserData(fi, null));
}
else if (!isEmpty(previousDomain)) {
duplicateUsers.addAll(plugin.importUserData(fi, previousDomain));
}
else {
errors.put("missingDomain", "missingDomain");
}
if (duplicateUsers.size() == 0) {
response.sendRedirect("import-user-data.jsp?success=true");
return;
}
errors.put("userAlreadyExists", "userAlreadyExists");
}
catch (MalformedURLException e) {
errors.put("IOException", "IOException");
}
else {
try {
//todo this could take some, redirect to a progress page?
if (plugin.validateImportFile(file)) {
duplicateUsers.addAll(plugin.importUserData(file));
if (duplicateUsers.size() == 0) {
response.sendRedirect("import-user-data.jsp?success=true");
return;
}
errors.put("userAlreadyExists", "userAlreadyExists");
}
else {
errors.put("invalidUserFile", "invalidUserFile");
}
}
catch (MalformedURLException e) {
errors.put("MalformedURLException", "MalformedURLException");
}
catch (DocumentException e) {
errors.put("DocumentException", "DocumentException");
}
}
}
catch (DocumentException e) {
errors.put("DocumentException", "DocumentException");
}
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
......@@ -64,35 +68,37 @@
<% if (errors.size() > 0) { %>
<div class="jive-error">
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("MalformedURLException") || errors.containsKey("badFile")) { %>
Missing or bad file name.
<% } else if (errors.containsKey("DocumentException")) { %>
Import failed.
<% } else if (errors.containsKey("invalidUserFile")) { %>
The import file does not match the user schema.
<% } else if (errors.containsKey("userAlreadyExists")) { %>
The following users are already exist in the system and were not loaded:<br>
<%
Iterator iter = duplicateUsers.iterator();
while (iter.hasNext()) {
String username = (String) iter.next();
%><%= username %><%
if (iter.hasNext()) {
%>,&nbsp;<%
} else {
%>.<%
}
}
} %>
</td>
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("missingDomain")) { %>
You must supply both a existing and new domain name.
<% } else if (errors.containsKey("IOException")) { %>
Missing or bad file name.
<% } else if (errors.containsKey("DocumentException")) { %>
Import failed.
<% } else if (errors.containsKey("invalidUserFile")) { %>
The import file does not match the user schema.
<% } else if (errors.containsKey("userAlreadyExists")) { %>
The following users are already exist in the system and were not loaded:<br>
<%
Iterator iter = duplicateUsers.iterator();
while (iter.hasNext()) {
String username = (String) iter.next();
%><%= username %><%
if (iter.hasNext()) {
%>,&nbsp;<%
} else {
%>.<%
}
}
} %>
</td>
</tr>
</tbody>
</tbody>
</table>
</div>
<br>
......@@ -101,46 +107,53 @@
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">All users added successfully.</td>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">All users added successfully.</td>
</tr>
</tbody>
</tbody>
</table>
</div>
<br>
<% } %>
<form action="import-user-data.jsp?importUsers" method="post" enctype="multipart/form-data">
<form action="import-user-data.jsp?importUsers" method="post">
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th>Import Properties</th>
</tr>
</thead>
<tr class="jive-even">
<td style="border-right:1px #ccc solid;">Import Location:</td>
</tr>
<tr class="jive-odd">
<td style="border-right:1px #ccc solid;"><%= plugin.exportDirectory() %></td>
</tr>
<tr class="jive-even">
<td style="border-right:1px #ccc solid;">Import File Name:</td>
</tr>
<tr class="jive-odd">
<td style="border-right:1px #ccc solid;"><input type="text" size="30" maxlength="150" name="importFile"></td>
</tr>
</table>
</div>
<br><br>
<fieldset>
<legend>Import</legend>
<div>
<p>
Use the Browse button to select the file that conatians the Jive Messenger user data to be imported, then click on the Import button.
</p>
<input type="file" name="thefile"><input type="submit" value="Import">
<br><br><br>
<p>
<b>Optional</b> - Use the field below to replace the domain name of user roster entries with the current hostname.
See the migration section of the <a href="../../plugin-admin.jsp?plugin=userimportexport&showReadme=true">readme</a> for details.
</p>
Existing Domain:<input type="text" size="20" maxlength="150" name="previousDomain" value=""/>
</div>
</fieldset>
<input type="submit" value="Import">
</form>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<jsp:include page="bottom.jsp" flush="true" />
<%!
public boolean isEmpty(String s) {
if (s == null) {
return true;
}
if (s.trim().length() == 0) {
return true;
}
return false;
}
%>
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