implement plugin update method

This commit is contained in:
Sebastian Sdorra
2010-12-18 18:21:21 +01:00
parent 0d2ec6da5e
commit a6a7d75328
3 changed files with 71 additions and 7 deletions

View File

@@ -199,7 +199,7 @@ public class AetherPluginHandler
}
catch (Exception ex)
{
throw new PluginLoadException(ex);
throw new PluginException(ex);
}
}
@@ -245,7 +245,7 @@ public class AetherPluginHandler
}
catch (JAXBException ex)
{
throw new PluginLoadException(ex);
throw new PluginException(ex);
}
}
}

View File

@@ -177,7 +177,7 @@ public class DefaultPluginManager implements PluginManager
if (plugin == null)
{
throw new PluginLoadException(id.concat(" is not install"));
throw new PluginNotInstalledException(id.concat(" is not install"));
}
if (pluginHandler == null)
@@ -199,7 +199,38 @@ public class DefaultPluginManager implements PluginManager
{
SecurityUtil.assertIsAdmin(securityContextProvicer);
throw new UnsupportedOperationException("Not supported yet.");
String[] idParts = id.split(":");
String groupId = idParts[0];
String artefactId = idParts[1];
PluginInformation installed = null;
for (PluginInformation info : getInstalled())
{
if (groupId.equals(info.getGroupId())
&& artefactId.equals(info.getArtifactId()))
{
installed = info;
break;
}
}
if (installed == null)
{
StringBuilder msg = new StringBuilder(groupId);
msg.append(":").append(groupId).append(" is not install");
throw new PluginNotInstalledException(msg.toString());
}
if (pluginHandler == null)
{
getPluginCenter();
}
pluginHandler.uninstall(installed.getId());
pluginHandler.install(id);
}
//~--- get methods ----------------------------------------------------------
@@ -370,12 +401,14 @@ public class DefaultPluginManager implements PluginManager
{
if (installed.getVersion().equals(available.getVersion()))
{
available.setState(PluginState.INSTALLED);
state = PluginState.INSTALLED;
}
else
{
available.setState(PluginState.UPDATE_AVAILABLE);
state = PluginState.UPDATE_AVAILABLE;
}
break;
}
}

View File

@@ -135,8 +135,39 @@ Sonia.plugin.uninstallPlugin = function(pluginId){
Sonia.plugin.updatePlugin = function(pluginId){
if ( debug ){
console.debug('not implemented');
console.debug( 'update plugin to ' + pluginId );
}
var loadingBox = Ext.MessageBox.show({
title: 'Please wait',
msg: 'Update Plugin.',
width: 300,
wait: true,
animate: true,
progress: true,
closable: false
});
Ext.Ajax.request({
url: restUrl + 'plugins/update/' + pluginId + '.json',
method: 'POST',
scope: this,
success: function(){
if ( debug ){
console.debug('plugin successfully updated');
}
loadingBox.hide();
Ext.MessageBox.alert('Plugin successfully updated',
'Restart the applicationserver to activate the changes.');
},
failure: function(){
if ( debug ){
console.debug('plugin updated failed');
}
alert( 'failure' );
loadingBox.hide();
}
});
}
// plugin grid