[life-cycle] Prevent NPE when trying to install not installable versions
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 08 Jul 2010 12:51:15 +0200
changeset 7861 0bcd6e7bde41
parent 7860 af005fa6c0b0
child 7862 afcefb4a5f98
[life-cycle] Prevent NPE when trying to install not installable versions
src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java
--- a/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Thu Jul 08 08:43:30 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java	Thu Jul 08 12:51:15 2010 +0200
@@ -659,7 +659,7 @@
     Module[] upd = null;
     OBError message = null;
     boolean found = false;
-    boolean check;
+    boolean check = false;
     // to hold (key,value) = (moduleId, minVersion)
     Map<String, String> minVersions = new HashMap<String, String>();
 
@@ -742,6 +742,28 @@
           return;
         }
 
+        // Show warning message when installing/updating modules not in production level
+        if (!islocal) {
+          if (!"500".equals((String) module.getAdditionalInfo().get("maturity.level"))) {
+            discard[6] = "";
+          } else {
+            if (inst != null) {
+              for (Module m : inst) {
+                if (!"500".equals((String) m.getAdditionalInfo().get("maturity.level"))) {
+                  discard[6] = "";
+                }
+              }
+            }
+            if (upd != null) {
+              for (Module m : upd) {
+                if (!"500".equals((String) m.getAdditionalInfo().get("maturity.level"))) {
+                  discard[6] = "";
+                }
+              }
+            }
+          }
+        }
+
       } else { // Dependencies not satisfied, do not show continue button
         message = im.getCheckError();
         discard[5] = "discardContinue";
@@ -763,28 +785,6 @@
       message.setMessage(e.toString());
     }
 
-    // Show warning message when isntalling/updating modules not in production level
-    if (!islocal) {
-      if (!"500".equals((String) module.getAdditionalInfo().get("maturity.level"))) {
-        discard[6] = "";
-      } else {
-        if (inst != null) {
-          for (Module m : inst) {
-            if (!"500".equals((String) m.getAdditionalInfo().get("maturity.level"))) {
-              discard[6] = "";
-            }
-          }
-        }
-        if (upd != null) {
-          for (Module m : upd) {
-            if (!"500".equals((String) m.getAdditionalInfo().get("maturity.level"))) {
-              discard[6] = "";
-            }
-          }
-        }
-      }
-    }
-
     final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP1", discard).createXmlDocument();
     xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
@@ -809,7 +809,7 @@
       xmlDocument.setParameter("moduleVersion", module.getVersionNo());
       xmlDocument.setParameter("linkCore", module.getModuleVersionID());
 
-      if ("500".equals((String) module.getAdditionalInfo().get("maturity.level"))) {
+      if (!check || "500".equals((String) module.getAdditionalInfo().get("maturity.level"))) {
         xmlDocument.setParameter("maturityStyle", "none");
       } else {
         xmlDocument.setParameter("maturityStyle", "yes");