details:   https://code.openbravo.com/erp/stable/2.50/rev/892c4c05a535
changeset: 9574:892c4c05a535
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Thu Jul 14 14:14:53 2011 +0200
summary:   fixed bug 17987: StackOverflow trying to install a commercial not 
subscribed module

diffstat:

 src/org/openbravo/erpCommon/obps/ActivationKey.java         |  14 ++++++++++++-
 src/org/openbravo/erpCommon/obps/ActiveInstanceProcess.java |   2 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r 21e49cfdd297 -r 892c4c05a535 
src/org/openbravo/erpCommon/obps/ActivationKey.java
--- a/src/org/openbravo/erpCommon/obps/ActivationKey.java       Thu Jul 14 
13:16:08 2011 +0200
+++ b/src/org/openbravo/erpCommon/obps/ActivationKey.java       Thu Jul 14 
14:14:53 2011 +0200
@@ -861,11 +861,19 @@
    * @return the status for the commercial module passed as parameter
    */
   public CommercialModuleStatus isModuleSubscribed(String moduleId) {
+    return isModuleSubscribed(moduleId, true);
+  }
+
+  private CommercialModuleStatus isModuleSubscribed(String moduleId, boolean 
refreshIfNeeded) {
     HashMap<String, CommercialModuleStatus> moduleList = 
getSubscribedModules();
 
     if (!moduleList.containsKey(moduleId)) {
       log4j.debug("Module " + moduleId + " is not in the list of subscribed 
modules");
 
+      if (!refreshIfNeeded) {
+        return CommercialModuleStatus.NO_SUBSCRIBED;
+      }
+
       Date timeToRefresh = null;
       if (lastRefreshTime != null) {
         Calendar calendar = Calendar.getInstance();
@@ -1008,6 +1016,10 @@
    * @return List of non allowed modules
    */
   public String verifyInstalledModules() {
+    return verifyInstalledModules(true);
+  }
+
+  String verifyInstalledModules(boolean refreshIfneeded) {
     String rt = "";
 
     OBContext.setAdminMode();
@@ -1019,7 +1031,7 @@
       mods.add(Expression.eq(Module.PROPERTY_INDEVELOPMENT, false));
       mods.addOrder(Order.asc(Module.PROPERTY_NAME));
       for (Module mod : mods.list()) {
-        if (isModuleSubscribed(mod.getId()) == 
CommercialModuleStatus.NO_SUBSCRIBED) {
+        if (isModuleSubscribed(mod.getId(), refreshIfneeded) == 
CommercialModuleStatus.NO_SUBSCRIBED) {
           rt += (rt.isEmpty() ? "" : ", ") + mod.getName();
         }
       }
diff -r 21e49cfdd297 -r 892c4c05a535 
src/org/openbravo/erpCommon/obps/ActiveInstanceProcess.java
--- a/src/org/openbravo/erpCommon/obps/ActiveInstanceProcess.java       Thu Jul 
14 13:16:08 2011 +0200
+++ b/src/org/openbravo/erpCommon/obps/ActiveInstanceProcess.java       Thu Jul 
14 14:14:53 2011 +0200
@@ -66,7 +66,7 @@
       SystemInformation sysInfo = 
OBDal.getInstance().get(SystemInformation.class, "0");
       sysInfo.setInstancePurpose(purpose);
       ActivationKey ak = new ActivationKey(publicKey, result[1]);
-      String nonAllowedMods = ak.verifyInstalledModules();
+      String nonAllowedMods = ak.verifyInstalledModules(false);
       if (!nonAllowedMods.isEmpty()) {
         msg.setType("Error");
         msg.setMessage("@LicenseWithoutAccessTo@ " + nonAllowedMods);

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to