Issue 15048: Fix display of purpose when upgrading activated instance to MP23
authorStefan Hühner <stefan.huehner@openbravo.com>
Wed, 27 Oct 2010 15:37:03 +0200
changeset 8831 6dadb8e721ce
parent 8830 4845dd2480d5
child 8832 2b2594b366d7
Issue 15048: Fix display of purpose when upgrading activated instance to MP23
If instance purpose is not set, but the instance is activated read the purpose
from the license and display this (more correct purpose).
src/org/openbravo/erpCommon/utility/Home.java
--- a/src/org/openbravo/erpCommon/utility/Home.java	Wed Oct 27 14:44:39 2010 +0200
+++ b/src/org/openbravo/erpCommon/utility/Home.java	Wed Oct 27 15:37:03 2010 +0200
@@ -89,21 +89,24 @@
   }
 
   private static String getPurpose() {
-    String strPurpose = "";
     OBContext.setAdminMode();
     try {
       String strPurposeCode = OBDal.getInstance().get(
           org.openbravo.model.ad.system.SystemInformation.class, "0").getInstancePurpose();
-      if (strPurpose == null || "".equals(strPurposeCode)) {
-        return null;
-      } else {
-        strPurpose = Utility.getListValueName("InstancePurpose", strPurposeCode, OBContext
-            .getOBContext().getLanguage().getLanguage());
+      if (strPurposeCode == null || "".equals(strPurposeCode)) {
+        if (ActivationKey.isActiveInstance()) {
+          // use value from license if possible
+          strPurposeCode = ActivationKey.getInstance().getProperty("purpose");
+        } else {
+          // community instance without purpose configured
+          return null;
+        }
       }
+      return Utility.getListValueName("InstancePurpose", strPurposeCode, OBContext.getOBContext()
+          .getLanguage().getLanguage());
     } finally {
       OBContext.restorePreviousMode();
     }
-    return strPurpose;
   }
 
   private static String getVersion() {