Commit f79a77ec authored by Guus der Kinderen's avatar Guus der Kinderen Committed by daryl herzmann

User Import/Export plugin fixes. (#829)

* OF-546: UserImportExport plugin should have admin console when built with Maven.

* OF-1355: UserImportExport should not fail on missing optional config.
parent 2f199750
......@@ -148,6 +148,11 @@ hr {
</div>
<div id="pageBody">
<p><b>2.6.1</b> -- June 22, 2017</p>
<ul>
<li>[<a href='http://www.igniterealtime.org/issues/browse/OF-1355'>OF-1355</a>] - UserImportExport plugin: import should not fail when optional config is missing.</li>
</ul>
<p><b>2.6.0</b> -- September 27, 2016</p>
<ul>
<li>Added option to use XEP-0227 Compliant export and import.</li>
......
......@@ -6,8 +6,8 @@
<name>User Import Export</name>
<description>Enables import and export of user data</description>
<author>Ryan Graham</author>
<version>2.6.0</version>
<date>09/26/2016</date>
<version>2.6.1</version>
<date>06/22/2017</date>
<minServerVersion>4.0.0</minServerVersion>
<adminconsole>
......
......@@ -8,7 +8,7 @@
</parent>
<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>userImportExport</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
<name>UserImportExport Plugin</name>
<description>Enables import and export of user data</description>
......@@ -24,6 +24,11 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<!-- Compiles the Openfire Admin Console JSP pages. -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
......@@ -18,22 +18,40 @@
Map<String, String> errors = new HashMap<String, String>();
if (importUsers) {
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();
FileItem xsup = (FileItem) i.next();
xep227Support = new Boolean( xsup.getString() );
String previousDomain = null;
xep227Support = false;
FileItem file = null; // the file.
List<FileItem> fileItems = dfu.parseRequest(request);
for ( FileItem fileItem : fileItems )
{
if ( fileItem.isFormField() )
{
switch ( fileItem.getFieldName() )
{
case "xep227support":
xep227Support = Boolean.parseBoolean( fileItem.getString() );
break;
case "previousDomain":
previousDomain = fileItem.getString();
break;
}
}
else
{
// the fileItem is an actual file.
file = fileItem;
}
}
if (plugin.validateImportFile(fi, xep227Support)) {
if (plugin.validateImportFile(file, xep227Support)) {
try {
if (isEmpty(previousDomain)) {
duplicateUsers.addAll(plugin.importUserData(fi, null, xep227Support));
duplicateUsers.addAll(plugin.importUserData(file, null, xep227Support));
}
else if (!isEmpty(previousDomain)) {
duplicateUsers.addAll(plugin.importUserData(fi, previousDomain, xep227Support));
duplicateUsers.addAll(plugin.importUserData(file, previousDomain, xep227Support));
}
else {
errors.put("missingDomain", "missingDomain");
......
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