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 {
}
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 {
public void setDownloaded(boolean 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;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import java.io.*;
import java.util.*;
import java.io.BufferedWriter;
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
* will check every 48 hours for updates. Use the system property <tt>update.frequency</tt>
* to set new values.<p>
*
* <p/>
* New versions of plugins can be downloaded and installed. However, new server releases
* should be manually installed.
*
......@@ -265,7 +278,7 @@ public class UpdateManager extends BasicModule {
// Remove installed plugins from the list of available plugins
for (Plugin plugin : server.getPluginManager().getPlugins()) {
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();
if (availablePlugin.getName().equals(pluginName)) {
it.remove();
......@@ -429,7 +442,7 @@ public class UpdateManager extends BasicModule {
Element xmlResponse = new SAXReader().read(new StringReader(response)).getRootElement();
Iterator plugins = xmlResponse.elementIterator("plugin");
while (plugins.hasNext()) {
Element plugin = (Element) plugins.next();
Element plugin = (Element)plugins.next();
String pluginName = plugin.attributeValue("name");
String latestVersion = plugin.attributeValue("latest");
String icon = plugin.attributeValue("icon");
......@@ -689,7 +702,7 @@ public class UpdateManager extends BasicModule {
// Parse info and recreate available plugins
Iterator it = xmlResponse.getRootElement().elementIterator("plugin");
while (it.hasNext()) {
Element plugin = (Element) it.next();
Element plugin = (Element)it.next();
String pluginName = plugin.attributeValue("name");
String latestVersion = plugin.attributeValue("latest");
String icon = plugin.attributeValue("icon");
......@@ -707,4 +720,13 @@ public class UpdateManager extends BasicModule {
availablePlugins.put(pluginName, available);
}
}
/**
* Returns a previously fetched list of updates.
*
* @return a previously fetched list of updates.
*/
public Collection<Update> getPluginUpdates() {
return pluginUpdates;
}
}
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
<allow>
<create creator="new" javascript="JDate">
<param name="class" value="java.util.Date"/>
</create>
</allow>
<allow>
<create creator="new" javascript="JDate">
<param name="class" value="java.util.Date"/>
</create>
</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>
This diff is collapsed.
This diff is collapsed.
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