diff --git a/openfire-export/OpenfireExporter/changelog.html b/openfire-export/OpenfireExporter/changelog.html deleted file mode 100755 index 973e684..0000000 --- a/openfire-export/OpenfireExporter/changelog.html +++ /dev/null @@ -1,192 +0,0 @@ - - - -
-Note: Openfire plugin improved to export to XEP-227 -format. There is also old code to import users, but using a custom Openfire -format. If you are interested you can improve it to also support XEP-227 -import.
- -The user import/export plugin provides a way to import and export Openfire user data via -the Admin Console. This plugin use for its migration the XEP-0227 standard to be able to migrate its -list of users from other Jabber/XMPP compliant based systems.
- -This plugin is based in the original plugin developed by Ryan Graham. -It was modified by Vidal Santiago Martinez (from ProcessOne) -to export to a XML file in the XEP-0227 format. -If you are migrating to ejabberd, check additional details in: -ejabberd migration kit. -The existing feature to import XML file was not modified, so it is not capable of importing XEP-0227 files.
- -Copy the OpenfireExporter.jar into the plugins directory of your Openfire installation. -The plugin will then be automatically deployed. To upgrade to a new version, copy the new -OpenfireExporter.jar file over the existing file.
- -Nothing to do
- -The plugin is accessed via the "User Import & Export XEP-0227 compliant" sidebar item located under the -"Users/Groups" tab in the Admin Console. Note: if you are using a read-only user store such as LDAP -or POP3 this plugin will still work with two caveats: -
-
-<?xml version="1.0" encoding="UTF-8"?> -<server-data xmlns="http://www.xmpp.org/extensions/xep-0227.html#ns"> -<host jid="example.org"> - <user name="testuser1" password="testuser1"> - <query xmlns="jabber:iq:roster"> - <item jid="testuser1@example.org" name="testuser1" subscription="both"> - <group/> - </item> - </query> - </user> - <user name="santiago" password="santiago"> - <query xmlns="jabber:iq:roster"> - <item jid="smartinez@example.org" name="santiago" subscription="both"> - <group/> - </item> - </query> - <vCard xmlns="vcard-temp"> - <FN>Vidal Santiago Martinez</FN> - <NICKNAME>Santiago</NICKNAME> - <EMAIL>smartinez@example.org</EMAIL> - <URL>www.process-one.net</URL> - </vCard> - </user> -</host> -</server-data> - |
-
- * The user import/export plugin provides a way to import and export Openfire - * user data via the Admin Console. This plugin is XEP-0227 compliant - *
- * This plugin can export:- * See also: {@link List http://xmpp.org/extensions/xep-0227.html} - *
- * - * @author Vidal Santiago - * Martinez - */ -public class ExporterXEP227 implements Plugin { - - private static final String LOAD_ALL_PRIVATE = "SELECT privateData FROM ofPrivate WHERE username=?"; - - private UserManager userManager; - private UserProvider provider; - private String serverName; - private OfflineMessageStore offlineMessagesStore; - private VCardManager vCardManager; - private PrivateStorage privateStorage; - - - public ExporterXEP227() { - userManager = XMPPServer.getInstance().getUserManager(); - offlineMessagesStore = XMPPServer.getInstance() - .getOfflineMessageStore(); - provider = UserManager.getUserProvider(); - serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain(); - privateStorage = XMPPServer.getInstance().getPrivateStorage(); - vCardManager = VCardManager.getInstance(); - } - - public void initializePlugin(PluginManager manager, File pluginDirectory) { - } - - public void destroyPlugin() { - userManager = null; - provider = null; - serverName = null; - offlineMessagesStore = null; - } - - /** - * Convenience method that returns true if this UserProvider is read-only. - * - * @return true if the user provider is read-only. - */ - public boolean isUserProviderReadOnly() { - return provider.isReadOnly(); - } - - /** - * Converts the user data that is to be exported to a byte[]. If a read-only - * user store is being used a user's password will be the same as their - * username. - * - * @return a byte[] of the user data. - * @throws IOException - * if there's a problem writing to the XMLWriter. - */ - public byte[] exportUsersToByteArray() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint()); - writer.write(exportUsers()); - - return out.toByteArray(); - } - - /** - * Converts the exported user data to a String. If a read-only user store is - * being used a user's password will be the same as their username. - * - * @return a formatted String representation of the user data. - * @throws IOException - * if there's a problem writing to the XMLWriter. - */ - public String exportUsersToString() throws IOException { - StringWriter stringWriter = new StringWriter(); - XMLWriter writer = null; - try { - writer = new XMLWriter(stringWriter, OutputFormat - .createPrettyPrint()); - writer.write(exportUsers()); - } catch (IOException ioe) { - Log.error(ioe); - throw ioe; - } finally { - if (writer != null) { - writer.close(); - } - } - - return stringWriter.toString(); - } - - /** - * Returns a list of usernames that were unable to be imported or whose - * rosters could not imported. Users are not able to be imported for the - * following reasons:
- *
- * <name xmlns='namespace'/>
- *
- *
- * If no data is currently stored under the given key, an empty element will
- * be returned.
- *
- * @param data
- * an XML document who's element name and namespace is used to
- * match previously stored private data.
- * @param username
- * the username of the account where private data is being
- * stored.
- * @return the data stored under the given key or the data element.
- */
- public Element get(String username, Element data) {
- if (enabled) {
- Connection con = null;
- PreparedStatement pstmt = null;
- SAXReader xmlReader = null;
- try {
- // Get a sax reader from the pool
- xmlReader = xmlReaders.take();
- con = DbConnectionManager.getConnection();
- pstmt = con.prepareStatement(LOAD_PRIVATE);
- pstmt.setString(1, username);
- pstmt.setString(2, data.getNamespaceURI());
- ResultSet rs = pstmt.executeQuery();
- if (rs.next()) {
- data.clearContent();
- String result = rs.getString(1).trim();
- Document doc = xmlReader.read(new StringReader(result));
- data = doc.getRootElement();
- }
- rs.close();
- } catch (Exception e) {
- Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
- } finally {
- // Return the sax reader to the pool
- if (xmlReader != null) {
- xmlReaders.add(xmlReader);
- }
- try {
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- try {
- if (con != null) {
- con.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- }
- }
- return data;
- }
-
- public Element getAll(String username) {
- QName qName = new QName("", new Namespace("","jabber:iq:private"), "query");
- Element data = DocumentHelper.createElement(qName);
-
- if (enabled) {
- Connection con = null;
- PreparedStatement pstmt = null;
- SAXReader xmlReader = null;
- try {
- // Get a sax reader from the pool
- xmlReader = xmlReaders.take();
- con = DbConnectionManager.getConnection();
- pstmt = con.prepareStatement(LOAD_ALL_PRIVATE);
- pstmt.setString(1, username);
-
- ResultSet rs = pstmt.executeQuery();
- while (rs.next()) {
- String result = rs.getString(1).trim();
- Document doc = xmlReader.read(new StringReader(result));
- data.add(doc.getRootElement());
- }
- rs.close();
- } catch (Exception e) {
- Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
- } finally {
- // Return the sax reader to the pool
- if (xmlReader != null) {
- xmlReaders.add(xmlReader);
- }
- try {
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- try {
- if (con != null) {
- con.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- }
- }
- return data;
- }
-
- public void userCreated(User user, Map params) {
- // Do nothing
- }
-
- public void userDeleting(User user, Map params) {
- // Delete all private properties of the user
- java.sql.Connection con = null;
- PreparedStatement pstmt = null;
- try {
- con = DbConnectionManager.getConnection();
- pstmt = con.prepareStatement(DELETE_PRIVATES);
- pstmt.setString(1, user.getUsername());
- pstmt.executeUpdate();
- } catch (Exception e) {
- Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
- } finally {
- try {
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- try {
- if (con != null) {
- con.close();
- }
- } catch (Exception e) {
- Log.error(e);
- }
- }
- }
-
- public void userModified(User user, Map params) {
- // Do nothing
- }
-
- public void start() throws IllegalStateException {
- super.start();
- // Initialize the pool of sax readers
- for (int i = 0; i < 10; i++) {
- SAXReader xmlReader = new SAXReader();
- xmlReader.setEncoding("UTF-8");
- xmlReaders.add(xmlReader);
- }
- // Add this module as a user event listener so we can delete
- // all user properties when a user is deleted
- UserEventDispatcher.addListener(this);
- }
-
- public void stop() {
- super.stop();
- // Clean up the pool of sax readers
- xmlReaders.clear();
- // Remove this module as a user event listener
- UserEventDispatcher.removeListener(this);
- }
-}
\ No newline at end of file
diff --git a/openfire-export/OpenfireExporter/src/web/export-file.jsp b/openfire-export/OpenfireExporter/src/web/export-file.jsp
deleted file mode 100755
index 1d63228..0000000
--- a/openfire-export/OpenfireExporter/src/web/export-file.jsp
+++ /dev/null
@@ -1,17 +0,0 @@
-<%@ page import="java.io.OutputStream,
- org.jivesoftware.openfire.XMPPServer,
- net.processone.plugin.openfire.ExporterXEP227"
- contentType="application/x-download" %>
-
-
-
-<%String fileName = request.getParameter("fileName");
- response.setContentType("application/x-download");
- response.setHeader("Content-Disposition","attachment;filename="+fileName+".xml");
- ExporterXEP227 plugin = (ExporterXEP227) XMPPServer.getInstance().getPluginManager().getPlugin("openfireexporter");
- byte[] content = plugin.exportUsersToByteArray();
- OutputStream os = response.getOutputStream();
- os.write(content);
- os.flush();
- os.close();%>
\ No newline at end of file
diff --git a/openfire-export/OpenfireExporter/src/web/export-user-data.jsp b/openfire-export/OpenfireExporter/src/web/export-user-data.jsp
deleted file mode 100755
index 70320e3..0000000
--- a/openfire-export/OpenfireExporter/src/web/export-user-data.jsp
+++ /dev/null
@@ -1,137 +0,0 @@
-<%@ page
- import="java.io.IOException,java.util.*,
- net.processone.plugin.openfire.ExporterXEP227,
- org.jivesoftware.openfire.XMPPServer,
- org.jivesoftware.util.ParamUtils"%>
-<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
-<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
-
-
-
-<%
- boolean exportUsers = request.getParameter("exportUsers") != null;
- boolean success = request.getParameter("success") != null;
- boolean exportToFile = ParamUtils.getBooleanParameter(request,
- "exporttofile", true);
-
- ExporterXEP227 plugin = (ExporterXEP227) XMPPServer.getInstance()
- .getPluginManager().getPlugin("openfireexporter");
-
- String exportText = "";
-
- Map
-Openfire plugin improved to export to XEP-227 format.
-There is also old code to import, but using a custom Openfire format.
-If you are interested you can improve it to also support XEP-227 import.
-
-
-
-
-
-
-
-
-
- <%
- if (errors.containsKey("missingFile")) {
- %> Missing or bad file
- name. <%
- } else if (errors.containsKey("IOException")
- || errors.containsKey("fileNotCreated")) {
- %>
- Couldn't create export file. <%
- }
- %>
-
-
-
-<%
- } else if (ParamUtils.getBooleanParameter(request, "success")) {
-%>
-
-
-
-
-
-
-
-
- User data successfully exported.
-
-
-<%
- }
-%>
-
-
-
-
-
\ No newline at end of file
diff --git a/openfire-export/OpenfireExporter/src/web/images/error-16x16.gif b/openfire-export/OpenfireExporter/src/web/images/error-16x16.gif
deleted file mode 100644
index 379f501..0000000
Binary files a/openfire-export/OpenfireExporter/src/web/images/error-16x16.gif and /dev/null differ
diff --git a/openfire-export/OpenfireExporter/src/web/images/info-16x16.gif b/openfire-export/OpenfireExporter/src/web/images/info-16x16.gif
deleted file mode 100644
index 3843dca..0000000
Binary files a/openfire-export/OpenfireExporter/src/web/images/info-16x16.gif and /dev/null differ
diff --git a/openfire-export/OpenfireExporter/src/web/images/success-16x16.gif b/openfire-export/OpenfireExporter/src/web/images/success-16x16.gif
deleted file mode 100644
index 93e8153..0000000
Binary files a/openfire-export/OpenfireExporter/src/web/images/success-16x16.gif and /dev/null differ
diff --git a/openfire-export/OpenfireExporter/src/web/import-export-selection.jsp b/openfire-export/OpenfireExporter/src/web/import-export-selection.jsp
deleted file mode 100755
index 7ad1c57..0000000
--- a/openfire-export/OpenfireExporter/src/web/import-export-selection.jsp
+++ /dev/null
@@ -1,42 +0,0 @@
-<%@ page import="net.processone.plugin.openfire.ExporterXEP227,
- org.jivesoftware.openfire.XMPPServer"
-%>
-
-
-
-
-
-
- |
- <% 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("invalidUser")) { %>
-
- <% if (plugin.isUserProviderReadOnly()) { %>
- The following users did not exist in the system or have invalid username so their roster was not loaded: - <% } else { %> - The following users already exist in the system or have invalid username and were not loaded: - <% } %> - <% - Iterator iter = duplicateUsers.iterator(); - while (iter.hasNext()) { - String username = (String) iter.next(); - %><%= username %><% - if (iter.hasNext()) { - %>, <% - } else { - %>.<% - } - } - } %> - |
-
- <% if (plugin.isUserProviderReadOnly()) { %> - | User roster data added successfully. | - <% } else { %> -All users added successfully. | - <% } %> -