details:   /erp/devel/main/rev/13c29a90462c
changeset: 8772:13c29a90462c
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Wed Oct 27 11:52:55 2010 +0200
summary:   Fixed issue 15024.Usage audit is stored on System client and * 
Organization.

details:   /erp/devel/main/rev/4845dd2480d5
changeset: 8773:4845dd2480d5
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Wed Oct 27 14:44:39 2010 +0200
summary:   Fixed issue 15048.Purpose is set on System Info if it is null and it 
is an active instance.

details:   /erp/devel/main/rev/6dadb8e721ce
changeset: 8774:6dadb8e721ce
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Wed Oct 27 15:37:03 2010 +0200
summary:   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).

diffstat:

 src/org/openbravo/base/secureApp/HttpSecureAppServlet.java   |   4 ++
 src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java |  21 ++++++++++-
 src/org/openbravo/erpCommon/utility/Home.java                |  17 +++++----
 3 files changed, 33 insertions(+), 9 deletions(-)

diffs (108 lines):

diff -r 8e09349492a6 -r 6dadb8e721ce 
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Tue Oct 
26 19:40:23 2010 +0200
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java        Wed Oct 
27 15:37:03 2010 +0200
@@ -71,6 +71,7 @@
 import org.openbravo.erpCommon.utility.PrintJRData;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.access.SessionUsageAudit;
+import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.system.SystemInformation;
 import org.openbravo.model.ad.ui.Form;
 import org.openbravo.model.ad.ui.FormTrl;
@@ -78,6 +79,7 @@
 import org.openbravo.model.ad.ui.ProcessTrl;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.WindowTrl;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.utils.FileUtility;
 import org.openbravo.utils.Replace;
 import org.openbravo.xmlEngine.XmlDocument;
@@ -395,6 +397,8 @@
               && !"".equals(vars1.getSessionValue("#AD_Session_ID"))) {
             // Session Usage Audit
             SessionUsageAudit usageAudit = 
OBProvider.getInstance().get(SessionUsageAudit.class);
+            usageAudit.setClient(OBDal.getInstance().get(Client.class, "0"));
+            
usageAudit.setOrganization(OBDal.getInstance().get(Organization.class, "0"));
             usageAudit.setJavaClassName(this.getClass().getName());
             usageAudit.setModule(OBDal.getInstance().get(
                 org.openbravo.model.ad.module.Module.class, 
SessionInfo.getModuleId()));
diff -r 8e09349492a6 -r 6dadb8e721ce 
src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java
--- a/src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java      Tue Oct 
26 19:40:23 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/HeartbeatProcess.java      Wed Oct 
27 15:37:03 2010 +0200
@@ -24,6 +24,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.GeneralSecurityException;
+import java.sql.SQLException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -52,6 +53,7 @@
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.businessUtility.HeartbeatData;
 import org.openbravo.erpCommon.businessUtility.RegistrationData;
+import org.openbravo.erpCommon.obps.ActivationKey;
 import org.openbravo.erpCommon.utility.Alert;
 import org.openbravo.erpCommon.utility.HttpsUtils;
 import org.openbravo.erpCommon.utility.SystemInfo;
@@ -633,8 +635,23 @@
   public static boolean isShowInstancePurposeRequired() {
     final SystemInformation systemInformation = 
OBDal.getInstance().get(SystemInformation.class,
         "0");
-    return (systemInformation.getInstancePurpose() == null || systemInformation
-        .getInstancePurpose().isEmpty());
+    if (systemInformation.getInstancePurpose() == null
+        || systemInformation.getInstancePurpose().isEmpty()) {
+      if (ActivationKey.isActiveInstance()) {
+        
systemInformation.setInstancePurpose(ActivationKey.getInstance().getProperty("purpose"));
+        OBDal.getInstance().save(systemInformation);
+        OBDal.getInstance().flush();
+        try {
+          OBDal.getInstance().getConnection().commit();
+        } catch (SQLException e) {
+          // ignore exception on commit
+          log.error("Error on commit", e);
+        }
+        return false;
+      }
+      return true;
+    }
+    return false;
   }
 
   public static boolean isClonedInstance() throws ServletException {
diff -r 8e09349492a6 -r 6dadb8e721ce 
src/org/openbravo/erpCommon/utility/Home.java
--- a/src/org/openbravo/erpCommon/utility/Home.java     Tue Oct 26 19:40:23 
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() {

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to