Commit 91d4b5ec authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-635] Added ability to upload plugins through the web interface. (plugins-admin.jsp)

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8752 b35dd754-fafc-0310-a699-88a17e54d16e
parent a860f128
......@@ -19,6 +19,24 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../src/web/WEB-INF/lib/commons-fileupload.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../src/web/WEB-INF/lib/commons-io.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntryProperties />
</component>
<component name="WebModuleBuildComponent">
......@@ -56,6 +74,11 @@
<attribute name="URI" value="/WEB-INF/lib/ant.jar" />
<url>jar://$MODULE_DIR$/../lib/ant.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/cglib-nodep.jar" />
<url>jar://$MODULE_DIR$/../lib/cglib-nodep.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/commons-el.jar" />
......@@ -101,6 +124,16 @@
<attribute name="URI" value="&lt;N/A&gt;" />
<url>jar://$MODULE_DIR$/../lib/dist/servlet.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/hamcrest-api.jar" />
<url>jar://$MODULE_DIR$/../lib/hamcrest-api.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/hamcrest-library.jar" />
<url>jar://$MODULE_DIR$/../lib/hamcrest-library.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/i4jruntime.jar" />
......@@ -116,6 +149,16 @@
<attribute name="URI" value="/WEB-INF/lib/jasper-runtime.jar" />
<url>jar://$MODULE_DIR$/../lib/jasper-runtime.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/jmock-junit4.jar" />
<url>jar://$MODULE_DIR$/../lib/jmock-junit4.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/jmock.jar" />
<url>jar://$MODULE_DIR$/../lib/jmock.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/junit.jar" />
......@@ -236,6 +279,11 @@
<attribute name="URI" value="/WEB-INF/lib/xpp3.jar" />
<url>jar://$MODULE_DIR$/../lib/merge/xpp3.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/objenesis.jar" />
<url>jar://$MODULE_DIR$/../lib/objenesis.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="0" />
<attribute name="URI" value="/WEB-INF/lib/xmltask.jar" />
......@@ -426,6 +474,16 @@
<attribute name="URI" value="/WEB-INF/classes" />
<url>file://$MODULE_DIR$/../../src/resources/jar</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/lib/commons-fileupload.jar" />
<url>jar://$MODULE_DIR$/../../src/web/WEB-INF/lib/commons-fileupload.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/lib/commons-io.jar" />
<url>jar://$MODULE_DIR$/../../src/web/WEB-INF/lib/commons-io.jar!/</url>
</containerElement>
<containerElement type="library" level="module">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/lib/dwr.jar" />
......
......@@ -222,6 +222,11 @@
## Added key: 'user.roster.shared_groups'
## Added key: 'user.roster.click_view'
## Added key: 'user.roster.cant_delete'
## Added key: 'plugin.admin.uploaded_success'
## Added key: 'plugin.admin.uploaded_failure'
## Added key: 'plugin.admin.upload_plugin'
## Added key: 'plugin.admin.upload_plugin.info'
# Openfire
......@@ -1984,6 +1989,11 @@ plugin.admin.info=Plugins add new functionality to the server. The list of plugi
<a href="available-plugins.jsp">Available Plugins</a> page.
plugin.admin.deleted_success=Plugin deleted successfully.
plugin.admin.deleted_failure=Unable to delete plugin.
plugin.admin.uploaded_success=Plugin uploaded successfully. It may take a short time for the \
plugin to appear in the list of installed plugins.
plugin.admin.uploaded_failure=Unable to upload plugin. See server error logs.
plugin.admin.upload_plugin=Upload Plugin
plugin.admin.upload_plugin.info=Plugin files (.jar) can be uploaded directly by using the form below.
plugin.admin.click_reload=Reload the plugin.
plugin.admin.reload_success=Plugin was successfully reloaded. It may take a short time for the \
plugin to appear in the list of installed plugins again.
......
Name | Version
-------------------------------------------------------------------------
commons-fileupload.jar | 1.2
commons-io.jar | 1.3.2
......@@ -13,15 +13,20 @@
org.jivesoftware.openfire.update.Update"
%>
<%@ page import="org.jivesoftware.openfire.update.UpdateManager" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.File" %>
<%@ page import="java.io.FileReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.Comparator" %>
<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.util.Log" %>
<%@ page import="org.apache.commons.fileupload.FileItemFactory" %>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %>
<%@ page import="org.apache.commons.fileupload.FileItem" %>
<%@ page import="org.apache.commons.fileupload.FileUploadException" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -36,7 +41,9 @@
boolean showChangelog = ParamUtils.getBooleanParameter(request, "showChangelog", false);
boolean showIcon = ParamUtils.getBooleanParameter(request, "showIcon", false);
boolean downloadRequested = request.getParameter("download") != null;
boolean uploadPlugin = request.getParameter("uploadplugin") != null;
String url = request.getParameter("url");
Boolean uploadEnabled = JiveGlobals.getBooleanProperty("plugins.upload.enabled", true);
final PluginManager pluginManager = webManager.getXMPPServer().getPluginManager();
......@@ -80,6 +87,52 @@
}
}
}
if (uploadEnabled && uploadPlugin) {
Boolean installed = false;
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
try {
// Parse the request
List items = upload.parseRequest(request);
for (Object objItem : items) {
FileItem item = (FileItem)objItem;
String fileName = item.getName();
if (fileName != null) {
InputStream is = item.getInputStream();
if (is != null) {
installed = XMPPServer.getInstance().getPluginManager().installPlugin(is, fileName);
if (!installed) {
Log.error("Plugin manager failed to install plugin: " + fileName);
}
is.close();
}
else {
Log.error("Unable to open file stream for uploaded file: " + fileName);
}
}
else {
Log.error("No filename specified for file upload.");
}
}
}
catch (FileUploadException e) {
Log.error("Unable to upload plugin file.", e);
}
if (installed) {
response.sendRedirect("plugin-admin.jsp?uploadsuccess=true");
return;
} else {
response.sendRedirect("plugin-admin.jsp?uploadsuccess=false");
return;
}
}
%>
<% if (showReadme) {
......@@ -385,6 +438,23 @@ else if ("false".equals(request.getParameter("deletesuccess"))) { %>
<% } %>
<% if ("true".equals(request.getParameter("uploadsuccess"))) { %>
<div class="success">
<fmt:message key="plugin.admin.uploaded_success"/>
</div>
<br>
<% }
else if ("false".equals(request.getParameter("uploadsuccess"))) { %>
<div class="error">
<fmt:message key="plugin.admin.uploaded_failure"/>
</div>
<br>
<% } %>
<p>
<fmt:message key="plugin.admin.info"/>
</p>
......@@ -551,5 +621,18 @@ else if ("false".equals(request.getParameter("deletesuccess"))) { %>
</table>
</div>
<% if (uploadEnabled) { %>
<br /><br />
<div>
<h3><fmt:message key="plugin.admin.upload_plugin" /></h3>
<p><fmt:message key="plugin.admin.upload_plugin.info" /></p>
<form action="plugin-admin.jsp?uploadplugin" enctype="multipart/form-data" method="post">
<input type="file" name="uploadfile" />
<input type="submit" value="<fmt:message key="plugin.admin.upload_plugin" />" />
</form>
</div>
<% } %>
</body>
</html>
\ No newline at end of file
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