List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:April 4 2011 10:51pm
Subject:bzr commit into wex-installer-1.0 branch (reggie.burnett:406)
View as plain text  
#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:mike.lischke@stripped

  406 Reggie Burnett	2011-04-04
      fixed problem with how the example controller was working.  It essentially looked at the first server in the first catalog when it should have been looking for running servers in all related catalogs.  THis is not a complete fix as it just looks for the first running server instead of prompting the user for which server to target

    modified:
      StandardPlugins/Examples/ConfigurationController.cs
=== modified file 'StandardPlugins/Examples/ConfigurationController.cs'
=== modified file 'StandardPlugins/Examples/ConfigurationController.cs'
--- a/StandardPlugins/Examples/ConfigurationController.cs	2011-03-29 16:10:30 +0000
+++ b/StandardPlugins/Examples/ConfigurationController.cs	2011-04-04 22:51:44 +0000
@@ -19,9 +19,10 @@
     public class ExamplesConfigurationController : ProductConfigurationController
     {
         InstallerPanel[] p = new InstallerPanel[1];
-        ProductCatalog ourCatalog;
-        Product serverProductInCatalog;
-        bool alreadySearchedForServer;
+        List<ProductCatalog> owningCatalogs;
+        List<Product> relatedServers;
+        List<Product> installedServers;
+        List<Product> runningServers;
         string connectionString;
         List<SampleDatabase> databasesToInstall = null;
 
@@ -52,35 +53,15 @@
                 return;
             }
 
-            // determine what our catalog is
-            if (ourCatalog == null)
-                ourCatalog = GetOurCatalog();
-            if (ourCatalog == null) return;
-
-            // now find server in the catalog
-            if (serverProductInCatalog == null && !alreadySearchedForServer)
-                serverProductInCatalog = GetServerProductInCatalog();
-            if (serverProductInCatalog == null)
-            {
-                ReportStatus(ConfigurationEventType.Error, "", "Unable to configure as there is no server product available", 100);
-                return;
-            }
-
-            // now make sure the server product is installed
-            if (!serverProductInCatalog.Installed)
-            {
-                ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotInstalled, 100);
-                return;
-            }
-
-            // now make sure the server product is running
-            ServerProductConfigurationController controller = serverProductInCatalog.Controller as ServerProductConfigurationController;
-            if (!controller.IsRunning)
-            {
-                ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotRunning, 100);
-                return;
-            }
-
+            // load up our owning catalogs
+            if (!GetOwningCatalogsAndRelatedServerProducts()) return;
+
+            if (!GetInstalledServers()) return;
+            if (!GetRunningServers()) return;
+
+            Product p = runningServers[0];
+            ServerProductConfigurationController controller = p.Controller as ServerProductConfigurationController;
+            
             // now ask the controller for a connection string, prompting for credentials if we need to
             connectionString = controller.GetConnectionString(true);
             if (String.IsNullOrEmpty(connectionString))
@@ -92,6 +73,42 @@
             RunDatabaseScripts();
         }
 
+        private void GetRelatedServers()
+        {
+            if (relatedServers != null) return;
+            if (owningCatalogs == null) return;
+
+            relatedServers = new List<Product>();
+            foreach (ProductCatalog catalog in owningCatalogs)
+            {
+                foreach (CatalogProduct catalogProduct in catalog.Products)
+                {
+                    if (!catalogProduct.ReferencedProduct.IsServerProduct) continue;
+                    Product p = catalogProduct.ReferencedProduct;
+                    relatedServers.Add(p);
+                }
+            }
+        }
+
+        private bool GetRunningServers()
+        {
+            runningServers = new List<Product>();
+            if (installedServers == null || installedServers.Count == 0) return false;
+
+            foreach (Product p in installedServers)
+            {
+                ServerProductConfigurationController controller = p.Controller as ServerProductConfigurationController;
+                if (!controller.IsRunning) continue;
+                runningServers.Add(p);
+            }
+            if (runningServers == null || runningServers.Count == 0)
+            {
+                ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotRunning, 100);
+                return false;
+            }
+            return true;
+        }
+
         /// <summary>
         /// Looks at the features for this product and returns all features that installed and need configuring
         /// </summary>
@@ -164,47 +181,59 @@
             }
         }
 
-        private Product GetServerProductInCatalog()
-        {
-            if (alreadySearchedForServer) return serverProductInCatalog;
-
-            alreadySearchedForServer = true;
-            // if we are not in a catalog, then return no product
-            if (ourCatalog == null)
-            {
-                ReportStatus(ConfigurationEventType.Info, "SERVER_PRODUCT", 
-                    "Unable to determine server product as we are not in a catalog", 100);
-                return null;
-            }
-
-            // find out what catalog our owner belongs to
-            ReportStatus(ConfigurationEventType.Info, "SERVER_PRODUCT", "Determining server product in catalog", 15);
-
-            foreach (CatalogProduct catalogProduct in ourCatalog.Products)
-                if (catalogProduct.ReferencedProduct.IsServerProduct) 
-                {
-                    ReportStatus(ConfigurationEventType.Success, "SERVER_PRODUCT", 
-                        "Successfully determined server product in our catalog", 20);
-                    return catalogProduct.ReferencedProduct;
-                }
-            ReportError("SERVER_PRODUCT", "Failed to determine server product in our catalog");
-            return null;
-        }
-
-        private ProductCatalog GetOurCatalog()
-        {
+        private bool GetInstalledServers()
+        {
+            installedServers = new List<Product>();
+
+            foreach (Product p in relatedServers)
+            {
+                if (!p.Installed) continue;
+                installedServers.Add(p);
+            }
+            if (installedServers == null || installedServers.Count == 0)
+            {
+                ReportStatus(ConfigurationEventType.Error, "", Resources.ConfigErrorServerNotInstalled, 100);
+                return false;
+            }
+            return true;
+        }
+
+        private bool GetOwningCatalogsAndRelatedServerProducts()
+        {
+            GetOwningCatalogs();
+
+            if (owningCatalogs == null || owningCatalogs.Count == 0)
+            {
+                ReportStatus(ConfigurationEventType.Info, "SERVER_PRODUCT",
+                     "Unable to determine server product as we are not in a catalog", 100);
+                return false;
+            }
+
+            GetRelatedServers();
+            if (relatedServers == null || relatedServers.Count == 0)
+            {
+                ReportStatus(ConfigurationEventType.Error, "", "Unable to configure as there is no server product available", 100);
+                return false;
+            }
+            return true;
+        }
+
+
+        private void GetOwningCatalogs()
+        {
+            if (owningCatalogs != null) return;
+
             // find out what catalog our owner belongs to
             ReportStatus(ConfigurationEventType.Info, "CATALOG", "Determining product catalog", 0);
 
+            owningCatalogs = new List<ProductCatalog>();
             foreach (ProductCatalog catalog in ProductManager.Catalogs)
                 foreach (CatalogProduct catalogProduct in catalog.Products)
                     if (catalogProduct.ReferencedProduct == Owner) 
                     {
-                        ReportStatus(ConfigurationEventType.Success, "CATALOG", "Successfully determined product catalog", 10);
-                        return catalog;
+                        ReportStatus(ConfigurationEventType.Success, "CATALOG", "Found containing catalog", 10);
+                        owningCatalogs.Add(catalog);
                     }
-            ReportError("CATALOG", "Failed to determine product catalog");
-            return null;
         }
     }
 


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110404225144-4giw635xe8p3w8ss.bundle
Thread
bzr commit into wex-installer-1.0 branch (reggie.burnett:406) Reggie Burnett5 Apr