geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r641849 - /geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Date Thu, 27 Mar 2008 15:29:14 GMT
Author: gawor
Date: Thu Mar 27 08:29:12 2008
New Revision: 641849

URL: http://svn.apache.org/viewvc?rev=641849&view=rev
Log:
if plugin installation fails try to uninstall downloaded artifacts in order to prevent problems
later on. Patch from Joseph Leong. (GERONIMO-3887, GERONIMO-3939)

Modified:
    geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=641849&r1=641848&r2=641849&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Thu Mar 27 08:29:12 2008
@@ -593,6 +593,7 @@
     }
 
     public void install(PluginListType pluginsToInstall, SourceRepository defaultRepository,
boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller)
{
+        List<Artifact> downloadedArtifacts = new ArrayList<Artifact>();
         try {
             Map<Artifact, PluginType> metaMap = new HashMap<Artifact, PluginType>();
             // Step 1: validate everything
@@ -635,9 +636,11 @@
                 Set<Artifact> working = new HashSet<Artifact>();
                 Stack<Artifact> parentStack = new Stack<Artifact>();
                 if (instance.getModuleId() != null) {
+                    Artifact entry = toArtifact(instance.getModuleId());
                     List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository,
restrictToDefaultRepository, instance);
-                    downloadArtifact(toArtifact(instance.getModuleId()), metaMap, repos,
+                    downloadArtifact(entry, metaMap, repos,
                             username, password, new ResultsFileWriteMonitor(poller), working,
parentStack, false, servers, true);
+                    downloadedArtifacts.add(entry);
                 } else {
                     List<DependencyType> deps = instance.getDependency();
                     for (DependencyType dep : deps) {
@@ -645,6 +648,7 @@
                         List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository,
restrictToDefaultRepository, instance);
                         downloadArtifact(entry, metaMap, repos,
                                 username, password, new ResultsFileWriteMonitor(poller),
working, parentStack, false, servers, dep.isStart());
+                        downloadedArtifacts.add(entry);
                     }
                 }
                 // 4. Uninstall obsolete configurations
@@ -677,6 +681,14 @@
         } catch (Exception e) {
             log.error("Unable to install plugin. ", e);
             poller.setFailure(e);
+            //Attempt to cleanup a failed plugin installation
+            for (Artifact artifact : downloadedArtifacts) {
+                try {
+                    configManager.uninstallConfiguration(artifact);
+                } catch (Exception e2) {
+                    log.warn("Warning: ",e2);
+                }
+            }
         } finally {
             poller.setFinished();
         }



Mime
View raw message