Commit 7ed97e50 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1. Modified to include license type and plugin size.

2. Modified to handle i18n of plugins.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4094 b35dd754-fafc-0310-a699-88a17e54d16e
parent 077aaa1d
...@@ -43,9 +43,9 @@ public class AvailablePlugin { ...@@ -43,9 +43,9 @@ public class AvailablePlugin {
*/ */
private String changelog; private String changelog;
/** /**
* Flag that indicates whether the plugin is commercial or not. * Type of license of the plugin.
*/ */
private boolean commercial; private String licenseType;
/** /**
* Description of the plugin as specified in plugin.xml. * Description of the plugin as specified in plugin.xml.
*/ */
...@@ -58,20 +58,25 @@ public class AvailablePlugin { ...@@ -58,20 +58,25 @@ public class AvailablePlugin {
* Minimum server version required by this plugin as specified in plugin.xml. * Minimum server version required by this plugin as specified in plugin.xml.
*/ */
private String minServerVersion; private String minServerVersion;
/**
* Size in bytes of the plugin jar file.
*/
private String fileSize;
public AvailablePlugin(String name, String description, String latestVersion, String author, public AvailablePlugin(String name, String description, String latestVersion, String author,
String icon, String changelog, String readme, boolean commercial, String icon, String changelog, String readme, String licenseType,
String minServerVersion, String url) { String minServerVersion, String url, String fileSize) {
this.author = author; this.author = author;
this.icon = icon; this.icon = icon;
this.changelog = changelog; this.changelog = changelog;
this.readme = readme; this.readme = readme;
this.commercial = commercial; this.licenseType = licenseType;
this.description = description; this.description = description;
this.latestVersion = latestVersion; this.latestVersion = latestVersion;
this.minServerVersion = minServerVersion; this.minServerVersion = minServerVersion;
this.name = name; this.name = name;
this.url = url; this.url = url;
this.fileSize = fileSize;
} }
/** /**
...@@ -143,7 +148,16 @@ public class AvailablePlugin { ...@@ -143,7 +148,16 @@ public class AvailablePlugin {
* @return true if the plugin is commercial. * @return true if the plugin is commercial.
*/ */
public boolean isCommercial() { public boolean isCommercial() {
return commercial; return "commercial".equals(licenseType);
}
/**
* Returns the type of license the plugin is being released under.
*
* @return the type of license of the plugin.
*/
public String getLicenseType() {
return licenseType;
} }
/** /**
...@@ -163,4 +177,17 @@ public class AvailablePlugin { ...@@ -163,4 +177,17 @@ public class AvailablePlugin {
public String getMinServerVersion() { public String getMinServerVersion() {
return minServerVersion; return minServerVersion;
} }
/**
* Returns the size in bytes of the plugin jar file.
*
* @return the size in bytes of the plugin jar file.
*/
public long getFileSize() {
if (fileSize == null) {
// Dummy value for old xml files that didn't contain this piece of information
return -1L;
}
return Long.parseLong(fileSize);
}
} }
...@@ -184,7 +184,7 @@ public class UpdateManager extends BasicModule { ...@@ -184,7 +184,7 @@ public class UpdateManager extends BasicModule {
public synchronized void checkForPluginsUpdates(boolean notificationsEnabled) throws Exception { public synchronized void checkForPluginsUpdates(boolean notificationsEnabled) throws Exception {
// Get the XML request to include in the HTTP request // Get the XML request to include in the HTTP request
String requestXML = "<available/>"; String requestXML = getAvailablePluginsUpdateRequest();
// Send the request to the server // Send the request to the server
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(updateServiceURL); PostMethod postMethod = new PostMethod(updateServiceURL);
...@@ -381,6 +381,14 @@ public class UpdateManager extends BasicModule { ...@@ -381,6 +381,14 @@ public class UpdateManager extends BasicModule {
return xmlRequest.asXML(); return xmlRequest.asXML();
} }
private String getAvailablePluginsUpdateRequest() {
Element xmlRequest = docFactory.createDocument().addElement("available");
// Add locale so we can get current name and description of plugins
Element locale = xmlRequest.addElement("locale");
locale.addText(JiveGlobals.getLocale().toString());
return xmlRequest.asXML();
}
private void processServerUpdateResponse(String response, boolean notificationsEnabled) private void processServerUpdateResponse(String response, boolean notificationsEnabled)
throws DocumentException { throws DocumentException {
// Reset last known update information // Reset last known update information
...@@ -428,12 +436,13 @@ public class UpdateManager extends BasicModule { ...@@ -428,12 +436,13 @@ public class UpdateManager extends BasicModule {
String readme = plugin.attributeValue("readme"); String readme = plugin.attributeValue("readme");
String changelog = plugin.attributeValue("changelog"); String changelog = plugin.attributeValue("changelog");
String url = plugin.attributeValue("url"); String url = plugin.attributeValue("url");
boolean isCommercial = "true".equals(plugin.attributeValue("commercial")); String licenseType = plugin.attributeValue("licenseType");
String description = plugin.attributeValue("description"); String description = plugin.attributeValue("description");
String author = plugin.attributeValue("author"); String author = plugin.attributeValue("author");
String minServerVersion = plugin.attributeValue("minServerVersion"); String minServerVersion = plugin.attributeValue("minServerVersion");
String fileSize = plugin.attributeValue("fileSize");
AvailablePlugin available = new AvailablePlugin(pluginName, description, latestVersion, AvailablePlugin available = new AvailablePlugin(pluginName, description, latestVersion,
author, icon, changelog, readme, isCommercial, minServerVersion, url); author, icon, changelog, readme, licenseType, minServerVersion, url, fileSize);
// Add plugin to the list of available plugins at js.org // Add plugin to the list of available plugins at js.org
availablePlugins.put(pluginName, available); availablePlugins.put(pluginName, available);
} }
...@@ -547,7 +556,8 @@ public class UpdateManager extends BasicModule { ...@@ -547,7 +556,8 @@ public class UpdateManager extends BasicModule {
component.addAttribute("icon", plugin.getIcon()); component.addAttribute("icon", plugin.getIcon());
component.addAttribute("minServerVersion", plugin.getMinServerVersion()); component.addAttribute("minServerVersion", plugin.getMinServerVersion());
component.addAttribute("readme", plugin.getReadme()); component.addAttribute("readme", plugin.getReadme());
component.addAttribute("commercial", Boolean.toString(plugin.isCommercial())); component.addAttribute("licenseType", plugin.getLicenseType());
component.addAttribute("fileSize", Long.toString(plugin.getFileSize()));
} }
// Write data out to conf/available-plugins.xml file. // Write data out to conf/available-plugins.xml file.
Writer writer = null; Writer writer = null;
...@@ -686,12 +696,13 @@ public class UpdateManager extends BasicModule { ...@@ -686,12 +696,13 @@ public class UpdateManager extends BasicModule {
String readme = plugin.attributeValue("readme"); String readme = plugin.attributeValue("readme");
String changelog = plugin.attributeValue("changelog"); String changelog = plugin.attributeValue("changelog");
String url = plugin.attributeValue("url"); String url = plugin.attributeValue("url");
boolean isCommercial = "true".equals(plugin.attributeValue("commercial")); String licenseType = plugin.attributeValue("licenseType");
String description = plugin.attributeValue("description"); String description = plugin.attributeValue("description");
String author = plugin.attributeValue("author"); String author = plugin.attributeValue("author");
String minServerVersion = plugin.attributeValue("minServerVersion"); String minServerVersion = plugin.attributeValue("minServerVersion");
String fileSize = plugin.attributeValue("fileSize");
AvailablePlugin available = new AvailablePlugin(pluginName, description, latestVersion, AvailablePlugin available = new AvailablePlugin(pluginName, description, latestVersion,
author, icon, changelog, readme, isCommercial, minServerVersion, url); author, icon, changelog, readme, licenseType, minServerVersion, url, fileSize);
// Add plugin to the list of available plugins at js.org // Add plugin to the list of available plugins at js.org
availablePlugins.put(pluginName, available); availablePlugins.put(pluginName, available);
} }
......
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