Commit 5a72c447 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Initial check in for plugins. Documentation and bug fixing to come now.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4130 b35dd754-fafc-0310-a699-88a17e54d16e
parent 965f6b1d
...@@ -190,4 +190,12 @@ public class AvailablePlugin { ...@@ -190,4 +190,12 @@ public class AvailablePlugin {
} }
return Long.parseLong(fileSize); return Long.parseLong(fileSize);
} }
/**
* Returns the hash code for this object.
* @return the hash code.
*/
public int getHashCode(){
return hashCode();
}
} }
/**
* $Revision$
* $Date$
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.wildfire.update;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.update.Update;
import org.jivesoftware.wildfire.update.UpdateManager;
/**
*
*/
public class PluginDownloadManager {
public Update downloadPlugin(String url) {
UpdateManager updateManager = XMPPServer.getInstance().getUpdateManager();
updateManager.downloadPlugin(url);
Update returnUpdate = null;
for (Update update : updateManager.getPluginUpdates()) {
if (update.getURL().equals(url)) {
returnUpdate = update;
break;
}
}
try {
updateManager.checkForPluginsUpdates(true);
}
catch (Exception e) {
Log.error(e);
}
return returnUpdate;
}
public int installPlugin(String url, int hashCode) {
UpdateManager updateManager = XMPPServer.getInstance().getUpdateManager();
updateManager.downloadPlugin(url);
return hashCode;
}
}
...@@ -109,4 +109,12 @@ public class Update { ...@@ -109,4 +109,12 @@ public class Update {
public void setDownloaded(boolean downloaded) { public void setDownloaded(boolean downloaded) {
this.downloaded = downloaded; this.downloaded = downloaded;
} }
/**
* Returns the hashCode for this update object.
* @return hashCode
*/
public int getHashCode(){
return hashCode();
}
} }
...@@ -32,14 +32,27 @@ import org.jivesoftware.wildfire.container.Plugin; ...@@ -32,14 +32,27 @@ import org.jivesoftware.wildfire.container.Plugin;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import java.io.*; import java.io.BufferedWriter;
import java.util.*; import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/** /**
* Service that frequently checks for new server or plugins releases. By default the service * Service that frequently checks for new server or plugins releases. By default the service
* will check every 48 hours for updates. Use the system property <tt>update.frequency</tt> * will check every 48 hours for updates. Use the system property <tt>update.frequency</tt>
* to set new values.<p> * to set new values.<p>
* * <p/>
* New versions of plugins can be downloaded and installed. However, new server releases * New versions of plugins can be downloaded and installed. However, new server releases
* should be manually installed. * should be manually installed.
* *
...@@ -265,7 +278,7 @@ public class UpdateManager extends BasicModule { ...@@ -265,7 +278,7 @@ public class UpdateManager extends BasicModule {
// Remove installed plugins from the list of available plugins // Remove installed plugins from the list of available plugins
for (Plugin plugin : server.getPluginManager().getPlugins()) { for (Plugin plugin : server.getPluginManager().getPlugins()) {
String pluginName = server.getPluginManager().getName(plugin); String pluginName = server.getPluginManager().getName(plugin);
for (Iterator<AvailablePlugin> it=plugins.iterator(); it.hasNext();) { for (Iterator<AvailablePlugin> it = plugins.iterator(); it.hasNext();) {
AvailablePlugin availablePlugin = it.next(); AvailablePlugin availablePlugin = it.next();
if (availablePlugin.getName().equals(pluginName)) { if (availablePlugin.getName().equals(pluginName)) {
it.remove(); it.remove();
...@@ -429,7 +442,7 @@ public class UpdateManager extends BasicModule { ...@@ -429,7 +442,7 @@ public class UpdateManager extends BasicModule {
Element xmlResponse = new SAXReader().read(new StringReader(response)).getRootElement(); Element xmlResponse = new SAXReader().read(new StringReader(response)).getRootElement();
Iterator plugins = xmlResponse.elementIterator("plugin"); Iterator plugins = xmlResponse.elementIterator("plugin");
while (plugins.hasNext()) { while (plugins.hasNext()) {
Element plugin = (Element) plugins.next(); Element plugin = (Element)plugins.next();
String pluginName = plugin.attributeValue("name"); String pluginName = plugin.attributeValue("name");
String latestVersion = plugin.attributeValue("latest"); String latestVersion = plugin.attributeValue("latest");
String icon = plugin.attributeValue("icon"); String icon = plugin.attributeValue("icon");
...@@ -689,7 +702,7 @@ public class UpdateManager extends BasicModule { ...@@ -689,7 +702,7 @@ public class UpdateManager extends BasicModule {
// Parse info and recreate available plugins // Parse info and recreate available plugins
Iterator it = xmlResponse.getRootElement().elementIterator("plugin"); Iterator it = xmlResponse.getRootElement().elementIterator("plugin");
while (it.hasNext()) { while (it.hasNext()) {
Element plugin = (Element) it.next(); Element plugin = (Element)it.next();
String pluginName = plugin.attributeValue("name"); String pluginName = plugin.attributeValue("name");
String latestVersion = plugin.attributeValue("latest"); String latestVersion = plugin.attributeValue("latest");
String icon = plugin.attributeValue("icon"); String icon = plugin.attributeValue("icon");
...@@ -707,4 +720,13 @@ public class UpdateManager extends BasicModule { ...@@ -707,4 +720,13 @@ public class UpdateManager extends BasicModule {
availablePlugins.put(pluginName, available); availablePlugins.put(pluginName, available);
} }
} }
/**
* Returns a previously fetched list of updates.
*
* @return a previously fetched list of updates.
*/
public Collection<Update> getPluginUpdates() {
return pluginUpdates;
}
} }
...@@ -8,4 +8,11 @@ ...@@ -8,4 +8,11 @@
<param name="class" value="java.util.Date"/> <param name="class" value="java.util.Date"/>
</create> </create>
</allow> </allow>
<allow>
<create creator="new" javascript="downloader">
<param name="class" value="org.jivesoftware.wildfire.update.PluginDownloadManager"/>
</create>
<convert converter="bean" match="org.jivesoftware.wildfire.update.Update"/>
<convert converter="bean" match="org.jivesoftware.wildfire.update.AvailablePlugin"/>
</allow>
</dwr> </dwr>
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
org.jivesoftware.wildfire.update.AvailablePlugin, org.jivesoftware.wildfire.update.AvailablePlugin,
org.jivesoftware.wildfire.update.UpdateManager, org.jivesoftware.wildfire.update.UpdateManager,
java.util.Collections" java.util.Collections"
%> %>
<%@ page import="java.util.Comparator"%> <%@ page import="java.util.Comparator" %>
<%@ page import="java.util.List"%> <%@ page import="java.util.List" %><%@ page import="org.jivesoftware.util.ByteFormat"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" /> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<% <%
boolean downloadRequested = request.getParameter("download") != null; boolean downloadRequested = request.getParameter("download") != null;
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// Sort plugins alphabetically // Sort plugins alphabetically
Collections.sort(plugins, new Comparator() { Collections.sort(plugins, new Comparator() {
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
return ((AvailablePlugin) o1).getName().compareTo(((AvailablePlugin) o2).getName()); return ((AvailablePlugin)o1).getName().compareTo(((AvailablePlugin)o2).getName());
} }
}); });
...@@ -44,24 +44,220 @@ ...@@ -44,24 +44,220 @@
<head> <head>
<title><fmt:message key="plugin.available.title"/></title> <title><fmt:message key="plugin.available.title"/></title>
<meta name="pageID" content="available-plugins"/> <meta name="pageID" content="available-plugins"/>
<style type="text/css">
.content {
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
}
.textfield {
font-size: 11px;
font-family: verdana;
padding: 3px 2px;
background: #efefef;
}
.text {
font-size: 11px;
font-family: verdana;
}
.small-label {
font-size: 11px;
font-weight: bold;
font-family: verdana;
}
.small-label-link {
font-size: 11px;
font-weight: bold;
font-family: verdana;
text-decoration: underline;
}
.light-gray-border {
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 1px;
padding: 5px;
}
.light-gray-border-bottom {
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
}
.table-header {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 0px 1px 0px;
padding: 5px;
}
.row-header {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 0px;
padding: 5px;
}
.table-header-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 0px 1px 1px;
padding: 5px;
}
.table-header-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 0px;
padding: 5px;
}
.update-top {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 9pt;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 0px 0px 0px;
padding: 5px;
}
.update-bottom {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 0px 1px 0px;
padding: 5px;
}
.update-top-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 0px 0px 1px;
padding: 5px;
}
.update-bottom-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 0px 1px 1px;
padding: 5px;
}
.update-bottom-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 1px 1px 0px;
padding: 5px;
}
.update-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 1px 0px 0px;
padding: 5px;
}
.line-bottom-border {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 9pt;
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
padding: 5px;
}
</style>
<script src="dwr/engine.js" type="text/javascript"></script>
<script src="dwr/util.js" type="text/javascript"></script>
<script src="dwr/interface/downloader.js" type="text/javascript"></script>
<script type="text/javascript">
function downloadPlugin(url, id) {
document.getElementById(id+"-image").innerHTML = '<img src="images/working-16x16.gif" border="0"/>';
document.getElementById(id).style.background = "#FFFFF7";
downloader.installPlugin(downloadComplete, url, id);
}
function downloadComplete(id) {
document.getElementById(id).style.display = 'none';
document.getElementById(id + "-row").style.display = '';
setTimeout("fadeIt('"+id+"')", 3000);
}
function fadeIt(id){
Effect.Fade(id+"-row");
}
</script>
</head> </head>
<body> <body>
<p> <p>
<fmt:message key="plugin.available.info" /> <fmt:message key="plugin.available.info"/>
</p> </p>
<p> <p>
<div class="jive-table"> <div class="light-gray-border" style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"> <table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead> <thead>
<tr> <tr style="background:#F7F7FF;">
<th>&nbsp;</th> <td class="table-header-left">&nbsp;</td>
<th nowrap colspan="2"><fmt:message key="plugin.available.name" /></th> <td nowrap colspan="2" class="table-header">Open Source Plugins</td>
<th nowrap><fmt:message key="plugin.available.description" /></th> <td nowrap class="table-header"><fmt:message key="plugin.available.description"/></td>
<th nowrap><fmt:message key="plugin.available.version" /></th> <td nowrap class="table-header"><fmt:message key="plugin.available.version"/></td>
<th nowrap><fmt:message key="plugin.available.author" /></th> <td nowrap class="table-header"><fmt:message key="plugin.available.author"/></td>
<th nowrap><fmt:message key="plugin.available.install" /></th> <td nowrap class="table-header">File Size</td>
<td nowrap class="table-header-right"><fmt:message key="plugin.available.install"/></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -71,7 +267,7 @@ ...@@ -71,7 +267,7 @@
if (plugins.isEmpty()) { if (plugins.isEmpty()) {
%> %>
<tr> <tr>
<td align="center" colspan="8"><fmt:message key="plugin.available.no_plugin" /></td> <td align="center" colspan="8"><fmt:message key="plugin.available.no_plugin"/></td>
</tr> </tr>
<% <%
} }
...@@ -81,55 +277,155 @@ ...@@ -81,55 +277,155 @@
String pluginDescription = plugin.getDescription(); String pluginDescription = plugin.getDescription();
String pluginAuthor = plugin.getAuthor(); String pluginAuthor = plugin.getAuthor();
String pluginVersion = plugin.getLatestVersion(); String pluginVersion = plugin.getLatestVersion();
ByteFormat byteFormat = new ByteFormat();
String fileSize = byteFormat.format(plugin.getFileSize());
if (plugin.isCommercial()) {
continue;
}
%> %>
<tr> <tr id="<%= plugin.hashCode()%>">
<td width="1%"> <td width="1%" class="line-bottom-border">
<% if (plugin.getIcon() != null) { %> <% if (plugin.getIcon() != null) { %>
<img src="<%= plugin.getIcon() %>" width="16" height="16" alt="Plugin"> <img src="<%= plugin.getIcon() %>" width="16" height="16" alt="Plugin">
<% } else { %> <% }
else { %>
<img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin"> <img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
<% } %> <% } %>
</td> </td>
<td width="20%" nowrap> <td width="20%" nowrap class="line-bottom-border">
<%= (pluginName != null ? pluginName : "") %> &nbsp; <%= (pluginName != null ? pluginName : "") %> &nbsp;
</td> </td>
<td nowrap valign="top"> <td nowrap valign="top" class="line-bottom-border">
<% if (plugin.getReadme() != null) { %> <% if (plugin.getReadme() != null) { %>
<a href="<%= plugin.getReadme() %>" <a href="<%= plugin.getReadme() %>"
><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a> ><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
<% } else { %> &nbsp; <% } %> <% }
else { %> &nbsp; <% } %>
<% if (plugin.getChangelog() != null) { %> <% if (plugin.getChangelog() != null) { %>
<a href="<%= plugin.getChangelog() %>" <a href="<%= plugin.getChangelog() %>"
><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a> ><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
<% } else { %> &nbsp; <% } %> <% }
else { %> &nbsp; <% } %>
</td> </td>
<td width="60%"> <td width="60%" class="line-bottom-border">
<%= pluginDescription != null ? pluginDescription : "" %> <%= pluginDescription != null ? pluginDescription : "" %>
</td> </td>
<td width="5%" align="center" valign="top"> <td width="5%" align="center" valign="top" class="line-bottom-border">
<%= pluginVersion != null ? pluginVersion : "" %> <%= pluginVersion != null ? pluginVersion : "" %>
</td> </td>
<td width="15%" nowrap valign="top"> <td width="15%" nowrap valign="top" class="line-bottom-border">
<%= pluginAuthor != null ? pluginAuthor : "" %> &nbsp; <%= pluginAuthor != null ? pluginAuthor : "" %> &nbsp;
</td> </td>
<td width="1%" align="center" valign="top"> <td width="15%" nowrap valign="top" class="line-bottom-border">
<%= fileSize %>
</td>
<td width="1%" align="center" valign="top" class="line-bottom-border">
<% <%
String updateURL = plugin.getURL(); String updateURL = plugin.getURL();
if (updateManager.isPluginDownloaded(updateURL)) { if (updateManager.isPluginDownloaded(updateURL)) {
%> %>
&nbsp; &nbsp;
<% } else { %> <% }
else { %>
<% <%
if (updateURL.endsWith(".jar") || updateURL.endsWith(".zip") || updateURL.endsWith(".war")) {
// Change it so that the server downloads and installs the new version of the plugin %>
updateURL = "available-plugins.jsp?download=true&url="+ updateURL; <span id="<%= plugin.hashCode() %>-image"><a href="javascript:downloadPlugin('<%=updateURL%>', '<%= plugin.hashCode()%>')"><img src="images/add-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="plugin.available.download" />"></a></span>
<% } %>
</td>
</tr>
<tr id="<%= plugin.hashCode()%>-row" style="display:none;">
<td width="1%" class="line-bottom-border">
<img src="<%= plugin.getIcon()%>" width="16" height="16" />
</td>
<td nowrap class="line-bottom-border"><%= plugin.getName()%> plugin installed successfully!</td>
<td colspan="5" class="line-bottom-border">&nbsp;</td>
<td class="line-bottom-border" align="center">
<img src="images/success-16x16.gif" height="16" width="16" />
</td>
</tr>
<%
} }
%>
<tr><td><br/></td></tr>
<tr style="background:#F7F7FF;">
<td class="table-header-left">&nbsp;</td>
<td nowrap colspan="7" class="row-header">Commercial Plugins</td>
</tr>
<%
for (AvailablePlugin plugin : plugins) {
String pluginName = plugin.getName();
String pluginDescription = plugin.getDescription();
String pluginAuthor = plugin.getAuthor();
String pluginVersion = plugin.getLatestVersion();
ByteFormat byteFormat = new ByteFormat();
String fileSize = byteFormat.format(plugin.getFileSize());
if (plugin.isCommercial()) {
continue;
}
%>
<tr id="<%= plugin.hashCode()%>">
<td width="1%" class="line-bottom-border">
<% if (plugin.getIcon() != null) { %>
<img src="<%= plugin.getIcon() %>" width="16" height="16" alt="Plugin">
<% }
else { %>
<img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
<% } %>
</td>
<td width="20%" nowrap class="line-bottom-border">
<%= (pluginName != null ? pluginName : "") %> &nbsp;
</td>
<td nowrap valign="top" class="line-bottom-border">
<% if (plugin.getReadme() != null) { %>
<a href="<%= plugin.getReadme() %>"
><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
<% }
else { %> &nbsp; <% } %>
<% if (plugin.getChangelog() != null) { %>
<a href="<%= plugin.getChangelog() %>"
><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
<% }
else { %> &nbsp; <% } %>
</td>
<td width="60%" class="line-bottom-border">
<%= pluginDescription != null ? pluginDescription : "" %>
</td>
<td width="5%" align="center" valign="top" class="line-bottom-border">
<%= pluginVersion != null ? pluginVersion : "" %>
</td>
<td width="15%" nowrap valign="top" class="line-bottom-border">
<%= pluginAuthor != null ? pluginAuthor : "" %> &nbsp;
</td>
<td width="15%" nowrap valign="top" class="line-bottom-border">
<%= fileSize %>
</td>
<td width="1%" align="center" valign="top" class="line-bottom-border">
<%
String updateURL = plugin.getURL();
if (updateManager.isPluginDownloaded(updateURL)) {
%> %>
<a href="<%= updateURL %>" &nbsp;
><img src="images/doc-down-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="plugin.available.download" />"></a> <% }
else { %>
<span id="<%= plugin.hashCode() %>-image"><a href="javascript:downloadPlugin('<%=updateURL%>', '<%= plugin.hashCode()%>')"><img src="images/add-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="plugin.available.download" />"></a></span>
<% } %> <% } %>
</td> </td>
</tr> </tr>
<tr id="<%= plugin.hashCode()%>-row" style="display:none;">
<td width="1%" class="line-bottom-border">
<img src="<%= plugin.getIcon()%>" width="16" height="16" />
</td>
<td class="line-bottom-border"><%= plugin.getName()%> plugin installed successfully!</td>
<td colspan="5" class="line-bottom-border">&nbsp;</td>
<td class="line-bottom-border">
<img src="images/success-16x16.gif" height="16" width="16" />
</td>
</tr>
<% <%
} }
%> %>
......
...@@ -6,27 +6,29 @@ ...@@ -6,27 +6,29 @@
--%> --%>
<%@ page import="org.jivesoftware.util.ParamUtils, <%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.WebManager,
org.jivesoftware.wildfire.XMPPServer, org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.container.Plugin, org.jivesoftware.wildfire.container.Plugin,
org.jivesoftware.wildfire.container.PluginManager, org.jivesoftware.wildfire.container.PluginManager,
org.jivesoftware.wildfire.update.Update, org.jivesoftware.wildfire.update.Update"
org.jivesoftware.wildfire.update.UpdateManager" %>
%> <%@ page import="org.jivesoftware.wildfire.update.UpdateManager" %>
<%@ page import="java.io.BufferedReader"%> <%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.File"%> <%@ page import="java.io.File" %>
<%@ page import="java.io.FileReader"%> <%@ page import="java.io.FileReader" %>
<%@ page import="java.io.IOException"%> <%@ page import="java.io.IOException" %>
<%@ page import="java.net.URLEncoder"%> <%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.ArrayList"%> <%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collections"%> <%@ page import="java.util.Collections" %>
<%@ page import="java.util.Comparator"%> <%@ page import="java.util.Comparator" %>
<%@ page import="java.util.List"%> <%@ page import="java.util.List" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" /> <%
WebManager webManager = new WebManager();
%>
<% <%
String deletePlugin = ParamUtils.getParameter(request, "deleteplugin"); String deletePlugin = ParamUtils.getParameter(request, "deleteplugin");
String reloadPlugin = ParamUtils.getParameter(request, "reloadplugin"); String reloadPlugin = ParamUtils.getParameter(request, "reloadplugin");
...@@ -92,7 +94,7 @@ ...@@ -92,7 +94,7 @@
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
%> %>
<%= line %> <%= line %>
<% <%
} }
} }
...@@ -101,7 +103,11 @@ ...@@ -101,7 +103,11 @@
} }
finally { finally {
if (in != null) { if (in != null) {
try { in.close(); } catch (Exception e) { } try {
in.close();
}
catch (Exception e) {
}
} }
} }
} }
...@@ -121,7 +127,7 @@ ...@@ -121,7 +127,7 @@
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
%> %>
<%= line %> <%= line %>
<% <%
} }
} }
...@@ -130,7 +136,11 @@ ...@@ -130,7 +136,11 @@
} }
finally { finally {
if (in != null) { if (in != null) {
try { in.close(); } catch (Exception e) { } try {
in.close();
}
catch (Exception e) {
}
} }
} }
} }
...@@ -140,84 +150,284 @@ ...@@ -140,84 +150,284 @@
%> %>
<html> <html>
<head> <head>
<title><fmt:message key="plugin.admin.title"/></title> <title><fmt:message key="plugin.admin.title"/></title>
<meta name="pageID" content="plugin-settings"/> <meta name="pageID" content="plugin-settings"/>
<meta name="helpPage" content="manage_system_plugins.html"/> <meta name="helpPage" content="manage_system_plugins.html"/>
</head> <script src="dwr/engine.js" type="text/javascript"></script>
<body> <script src="dwr/util.js" type="text/javascript"></script>
<script src="dwr/interface/downloader.js" type="text/javascript"></script>
<style type="text/css">
.content {
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
}
.textfield {
font-size: 11px;
font-family: verdana;
padding: 3px 2px;
background: #efefef;
}
.text {
font-size: 11px;
font-family: verdana;
}
.small-label {
font-size: 11px;
font-weight: bold;
font-family: verdana;
}
.small-label-link {
font-size: 11px;
font-weight: bold;
font-family: verdana;
text-decoration: underline;
}
.light-gray-border {
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 1px;
padding: 5px;
}
.light-gray-border-bottom {
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
}
.table-header {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 0px 1px 0px;
padding: 5px;
}
.table-header-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 0px 1px 1px;
padding: 5px;
}
.table-header-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
border-color: #bbb;
border-style: solid;
border-width: 1px 1px 1px 0px;
padding: 5px;
}
.table-font {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
}
.update-top {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 9pt;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 0px 0px 0px;
padding: 5px;
}
.update {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 1px 1px 1px;
padding: 5px;
}
.update-bottom {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 0px 1px 0px;
padding: 5px;
}
.update-top-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 0px 0px 1px;
padding: 5px;
}
.update-bottom-left {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 0px 1px 1px;
padding: 5px;
}
.update-bottom-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 0px 1px 1px 0px;
padding: 5px;
}
.update-right {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
background: #E7FBDE;
border-color: #73CB73;
border-style: solid;
border-width: 1px 1px 0px 0px;
padding: 5px;
}
.line-bottom-border {
text-align: left;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 9pt;
border-color: #bbb;
border-style: solid;
border-width: 0px 0px 1px 0px;
padding: 5px;
}
</style>
<script type="text/javascript">
function download(url, hashCode) {
document.getElementById(hashCode + "-row").style.display = 'none';
document.getElementById(hashCode + "-update").style.display = '';
downloader.downloadPlugin(downloadComplete, url);
}
function downloadComplete(update) {
document.getElementById(update.hashCode + "-row").style.display = 'none';
document.getElementById(update.hashCode + "-update").style.display = '';
document.getElementById(update.hashCode + "-image").innerHTML = '<img src="images/success-16x16.gif" border="0"/>';
document.getElementById(update.hashCode + "-text").innerHTML = 'Update Completed';
}
</script>
</head>
<body>
<% if ("true".equals(request.getParameter("deletesuccess"))) { %> <% if ("true".equals(request.getParameter("deletesuccess"))) { %>
<div class="jive-success"> <div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0"> <table cellpadding="0" cellspacing="0" border="0">
<tbody> <tbody>
<tr> <tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td> <td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
<td class="jive-icon-label"><fmt:message key="plugin.admin.deleted_success" /></td> <td class="jive-icon-label"><fmt:message key="plugin.admin.deleted_success"/></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<br> <br>
<% } else if ("false".equals(request.getParameter("deletesuccess"))) { %> <% }
else if ("false".equals(request.getParameter("deletesuccess"))) { %>
<div class="jive-error"> <div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0"> <table cellpadding="0" cellspacing="0" border="0">
<tbody> <tbody>
<tr> <tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt="" />></td> <td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""/>></td>
<td class="jive-icon-label"><fmt:message key="plugin.admin.deleted_failure" /></td> <td class="jive-icon-label"><fmt:message key="plugin.admin.deleted_failure"/></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<br> <br>
<% } %> <% } %>
<% if ("true".equals(request.getParameter("reloadsuccess"))) { %> <% if ("true".equals(request.getParameter("reloadsuccess"))) { %>
<div class="jive-success"> <div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0"> <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" alt=""></td> <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
<td class="jive-icon-label"><fmt:message key="plugin.admin.reload_success" /></td></tr> <td class="jive-icon-label"><fmt:message key="plugin.admin.reload_success"/></td></tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<br> <br>
<% } %> <% } %>
<p> <p>
<fmt:message key="plugin.admin.info" /> <fmt:message key="plugin.admin.info"/>
</p> </p>
<p> <p>
<div class="jive-table"> <div class="light-gray-border" style="padding:10px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%"> <table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead> <tr>
<tr>
<th>&nbsp;</th> <td nowrap colspan="3" class="table-header-left"><fmt:message key="plugin.admin.name"/></td>
<th nowrap colspan="2"><fmt:message key="plugin.admin.name" /></th> <td nowrap class="table-header"><fmt:message key="plugin.admin.description"/></td>
<th nowrap><fmt:message key="plugin.admin.description" /></th> <td nowrap class="table-header"><fmt:message key="plugin.admin.version"/></td>
<th nowrap><fmt:message key="plugin.admin.version" /></th> <td nowrap class="table-header"><fmt:message key="plugin.admin.author"/></td>
<th nowrap><fmt:message key="plugin.admin.author" /></th> <td nowrap class="table-header"><fmt:message key="plugin.admin.restart"/></td>
<th nowrap><fmt:message key="plugin.admin.restart" /></th> <td nowrap class="table-header-right"><fmt:message key="global.delete"/></td>
<th nowrap><fmt:message key="global.delete" /></th> </tr>
</tr>
</thead>
<tbody> <tbody>
<tr><td colspan="8"><br/></td></tr>
<% <%
// If only the admin plugin is installed, show "none". // If only the admin plugin is installed, show "none".
if (plugins.size() == 1) { if (plugins.size() == 1) {
%> %>
<tr> <tr>
<td align="center" colspan="8"><fmt:message key="plugin.admin.no_plugin" /></td> <td align="center" colspan="8"><fmt:message key="plugin.admin.no_plugin"/></td>
</tr> </tr>
<% <%
} }
...@@ -240,75 +450,110 @@ ...@@ -240,75 +450,110 @@
Update update = updateManager.getPluginUpdate(pluginName, pluginVersion); Update update = updateManager.getPluginUpdate(pluginName, pluginVersion);
%> %>
<tr> <tr valign="top">
<td width="1%"> <td width="1%" class="<%= update != null ? "update-top-left" : "line-bottom-border"%>">
<% if (icon.exists()) { %> <% if (icon.exists()) { %>
<img src="plugin-icon.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showIcon=true&decorator=none" width="16" height="16" alt="Plugin"> <img src="plugin-icon.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showIcon=true&decorator=none" width="16" height="16" alt="Plugin">
<% } else { %> <% }
else { %>
<img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin"> <img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
<% } %> <% } %>
</td> </td>
<td width="20%" nowrap> <td width="20%" nowrap valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<%= (pluginName != null ? pluginName : dirName) %> &nbsp; <%= (pluginName != null ? pluginName : dirName) %> &nbsp;
<% <%
boolean readmeExists = new File(pluginDir, "readme.html").exists(); boolean readmeExists = new File(pluginDir, "readme.html").exists();
boolean changelogExists = new File(pluginDir, "changelog.html").exists(); boolean changelogExists = new File(pluginDir, "changelog.html").exists();
%> %>
</td> </td>
<td nowrap valign="top"> <td nowrap valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<p><% if (readmeExists) { %> <p><% if (readmeExists) { %>
<a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showReadme=true&decorator=none" <a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showReadme=true&decorator=none"
><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a> ><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
<% } else { %> &nbsp; <% } %> <% }
else { %> &nbsp; <% } %>
<% if (changelogExists) { %> <% if (changelogExists) { %>
<a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showChangelog=true&decorator=none" <a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showChangelog=true&decorator=none"
><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a> ><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
<% } else { %> &nbsp; <% } %></p> <% }
<% if (update != null) { %> else { %> &nbsp; <% } %></p>
<p>
<%
String updateURL = update.getURL();
if (updateURL.endsWith(".jar") || updateURL.endsWith(".zip") || updateURL.endsWith(".war")) {
// Change it so that the server downloads and installs the new version of the plugin
updateURL = "plugin-admin.jsp?download=true&url="+ updateURL;
}
%>
<a href="<%= updateURL %>"
><img src="images/doc-down-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="plugin.admin.download" />"></a>
<% if (update.getChangelog() != null) { %>
<a href="<%= update.getChangelog()%>"
><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
<% } else { %> &nbsp; <% } %>
</p>
<% } %>
</td> </td>
<td width="60%"> <td width="60%" valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<p><%= pluginDescription != null ? pluginDescription : "" %></p> <%= pluginDescription != null ? pluginDescription : "" %>
<% if (update != null) { %>
<p><fmt:message key="plugin.admin.update-desc" /></p>
<% } %>
</td> </td>
<td width="5%" align="center" valign="top"> <td width="5%" align="center" valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<p><%= pluginVersion != null ? pluginVersion : "" %></p> <p><%= pluginVersion != null ? pluginVersion : "" %></p>
<% if (update != null) { %>
<p><%= update.getLatestVersion() %></p>
<% } %>
</td> </td>
<td width="15%" nowrap valign="top"> <td width="15%" nowrap valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<%= pluginAuthor != null ? pluginAuthor : "" %> &nbsp; <%= pluginAuthor != null ? pluginAuthor : "" %> &nbsp;
</td> </td>
<td width="1%" align="center" valign="top"> <td width="1%" align="center" valign="top" class="<%= update != null ? "update-top" : "line-bottom-border"%>">
<a href="plugin-admin.jsp?reloadplugin=<%= dirName %>" <a href="plugin-admin.jsp?reloadplugin=<%= dirName %>"
title="<fmt:message key="plugin.admin.click_reload" />" title="<fmt:message key="plugin.admin.click_reload" />"
><img src="images/refresh-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.refresh" />"></a> ><img src="images/refresh-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.refresh" />"></a>
</td> </td>
<td width="1%" align="center" valign="top" style="border-right:1px #ccc solid;"> <td width="1%" align="center" valign="top" class="<%= update != null ? "update-right" : "line-bottom-border"%>">
<a href="#" onclick="if (confirm('<fmt:message key="plugin.admin.confirm" />')) { location.replace('plugin-admin.jsp?deleteplugin=<%= dirName %>'); } " <a href="#" onclick="if (confirm('<fmt:message key="plugin.admin.confirm" />')) { location.replace('plugin-admin.jsp?deleteplugin=<%= dirName %>'); } "
title="<fmt:message key="global.click_delete" />" title="<fmt:message key="global.click_delete" />"
><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.delete" />"></a> ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.delete" />"></a>
</td> </td>
</tr>
<% if (update != null) { %>
<!-- Has Updates, show show -->
<%
String updateURL = update.getURL();
if (updateURL.endsWith(".jar") || updateURL.endsWith(".zip") || updateURL.endsWith(".war")) {
// Change it so that the server downloads and installs the new version of the plugin
updateURL = "plugin-admin.jsp?download=true&url=" + updateURL;
}
%>
<tr id="<%= update.hashCode() %>-row">
<td class="update-bottom-left">&nbsp;</td>
<td class="update-bottom" nowrap>
<span class="small-label">Version <%= update.getLatestVersion()%> Available</span>
</td>
<td nowrap class="update-bottom">
<% if (update.getChangelog() != null) { %>
<span class="text">(<a href="<%= update.getChangelog()%>">Change Log</a>)</span>
<% }
else { %>
&nbsp;
<% } %>
</td>
<td class="update-bottom">
<table>
<tr>
<td><a href="javascript:download('<%= update.getURL()%>', '<%=update.hashCode()%>')"><img src="images/icon_update-16x16.gif" width="16" height="16" border="0" alt="changelog"></a></td>
<td><a href="javascript:download('<%= update.getURL()%>', '<%=update.hashCode()%>')"><span class="small-label">Update</span></a></td>
</tr>
</table>
</td>
<td class="update-bottom" colspan="3">&nbsp;</td>
<td class="update-bottom-right" colspan="3">&nbsp;</td>
</tr>
<tr id="<%= update.hashCode()%>-update" style="display:none;">
<td colspan="8" align="center" class="update">
<table>
<tr>
<td id="<%= update.hashCode()%>-image"><img src="images/working-16x16.gif" border="0"/></td>
<td id="<%= update.hashCode()%>-text" class="table-font">Updating</td>
</tr> </tr>
</table>
</td>
</tr>
<% } %>
<tr><td></td></tr>
<!-- End of update section -->
<% <%
} }
} }
...@@ -317,5 +562,5 @@ ...@@ -317,5 +562,5 @@
</table> </table>
</div> </div>
</body> </body>
</html> </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