fixes 27560: can't use expired instance refresed with trial without sys id
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 09 Sep 2014 09:10:32 +0200
changeset 24073 2eb08cb9faab
parent 24020 a5483762bc5d
child 24074 f192265ffb04
fixes 27560: can't use expired instance refresed with trial without sys id

An instance without sys id that was previously activated with an expired license
and is activated with a trial can't be used anymore. This was caused because:
-Expired licenses a tried to be renewed behind the scenes to do so, sys id is
required but as there is none a new one is created but not persisted in DB
-When requesting trial activation that previously generated sys id is used and
the licence is associated to it
-Finally data is refreshed from db, and as the sys id was not persisted a new one
is created and saved. Causing the mismatch with the id linked to the license
src/org/openbravo/erpCommon/utility/SystemInfo.java
--- a/src/org/openbravo/erpCommon/utility/SystemInfo.java	Thu Sep 04 11:14:09 2014 +0000
+++ b/src/org/openbravo/erpCommon/utility/SystemInfo.java	Tue Sep 09 09:10:32 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -299,9 +299,16 @@
     validateConnection(conn);
     String strSystemIdentifier = SystemInfoData.selectSystemIdentifier(conn);
     if (strSystemIdentifier == null || strSystemIdentifier.equals("")) {
-      strSystemIdentifier = UUID.randomUUID().toString();
+      if (systemIdentifier != null) {
+        // system identifier was previously calculated but it was not persisted in DB, let's update
+        // it again
+        strSystemIdentifier = systemIdentifier;
+      } else {
+        strSystemIdentifier = UUID.randomUUID().toString();
+      }
       SystemInfoData.updateSystemIdentifier(conn, strSystemIdentifier);
     }
+    systemIdentifier = strSystemIdentifier;
     return strSystemIdentifier;
   }