You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2008/06/09 22:18:13 UTC

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

Author: gawor
Date: Mon Jun  9 13:18:13 2008
New Revision: 665872

URL: http://svn.apache.org/viewvc?rev=665872&view=rev
Log:
ensure plugin validation is done once (GERONIMO-4111)

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=665872&r1=665871&r2=665872&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 Mon Jun  9 13:18:13 2008
@@ -546,6 +546,15 @@
         }
     }
 
+    private SourceRepository getDefaultSourceRepository(String defaultRepository,
+                                                        boolean restrictToDefaultRepository) {
+        if (restrictToDefaultRepository && defaultRepository == null) {
+            throw new IllegalArgumentException("You must supply a default repository if you want to restrict to it");
+        }
+        SourceRepository defaultSourceRepository = defaultRepository == null ? null : SourceRepositoryFactory.getSourceRepository(defaultRepository);
+        return defaultSourceRepository;
+    }
+    
     /**
      * Installs a configuration from a remote repository into the local Geronimo server,
      * including all its dependencies.  The caller will get the results when the
@@ -585,14 +594,15 @@
      * @param poller                      Will be notified with status updates as the download proceeds
      */
     public void install(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) {
-        if (restrictToDefaultRepository && defaultRepository == null) {
-            throw new IllegalArgumentException("You must supply a default repository if you want to restrict to it");
-        }
-        SourceRepository defaultSourceRepository = defaultRepository == null ? null : SourceRepositoryFactory.getSourceRepository(defaultRepository);
+        SourceRepository defaultSourceRepository = getDefaultSourceRepository(defaultRepository, restrictToDefaultRepository);
         install(pluginsToInstall, defaultSourceRepository, restrictToDefaultRepository, username, password, poller);
     }
 
     public void install(PluginListType pluginsToInstall, SourceRepository defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) {
+        install(pluginsToInstall, defaultRepository, restrictToDefaultRepository, username, password, poller, true);
+    }
+    
+    public void install(PluginListType pluginsToInstall, SourceRepository defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller, boolean validatePlugins) {
         List<Artifact> downloadedArtifacts = new ArrayList<Artifact>();
         try {
             Map<Artifact, PluginType> metaMap = new HashMap<Artifact, PluginType>();
@@ -600,8 +610,10 @@
             List<PluginType> toInstall = new ArrayList<PluginType>();
             for (PluginType metadata : pluginsToInstall.getPlugin()) {
                 try {
-                    validatePlugin(metadata);
-                    verifyPrerequisites(metadata);
+                    if (validatePlugins) {
+                        validatePlugin(metadata);
+                        verifyPrerequisites(metadata);
+                    }
 
                     PluginArtifactType instance = metadata.getPluginArtifact().get(0);
 
@@ -841,6 +853,8 @@
 
             // 2. Validate that we can install this
             validatePlugin(data);
+            verifyPrerequisites(data);
+            
             PluginArtifactType instance = data.getPluginArtifact().get(0);
             // 3. Install the CAR into the repository (it shouldn't be re-downloaded)
             if (instance.getModuleId() != null) {
@@ -854,11 +868,13 @@
             }
 
             // 4. Use the standard logic to remove obsoletes, install dependencies, etc.
-            //    This will validate all over again (oh, well)
             PluginListType pluginList = new PluginListType();
             pluginList.getPlugin().add(data);
             pluginList.getDefaultRepository().addAll(instance.getSourceRepository());
-            install(pluginList, defaultRepository, restrictToDefaultRepository, username, password, poller);
+            
+            SourceRepository defaultSourceRepository = getDefaultSourceRepository(defaultRepository, restrictToDefaultRepository);
+            
+            install(pluginList, defaultSourceRepository, restrictToDefaultRepository, username, password, poller, false);
         } catch (Exception e) {
             poller.setFailure(e);
         } finally {