details:   /erp/devel/pi/rev/4ca58960e91f
changeset: 12430:4ca58960e91f
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed May 25 13:23:07 2011 +0200
summary:   Fixes issue 17249: Use known list to build dependency list
Core has a undeclared dependency on client.kernel, client.application,
selector, etc modules.
If a module developed in 2.50 and only depends on core, tries to define a
ComponentProvider for definining a new StaticResource the order of inclusion
fails.

diffstat:

 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
 |  68 ++++++---
 1 files changed, 42 insertions(+), 26 deletions(-)

diffs (118 lines):

diff -r d134df2a8a0a -r 4ca58960e91f 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
      Wed May 25 12:48:06 2011 +0200
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
      Wed May 25 13:23:07 2011 +0200
@@ -4,14 +4,14 @@
  * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
  * Version 1.1  with a permitted attribution clause; you may not  use this
  * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
+ * the License at http://www.openbravo.com/legal/license.html
  * Software distributed under the License  is  distributed  on  an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2010 Openbravo SLU 
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010-2011 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,6 +19,7 @@
 package org.openbravo.client.kernel;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -54,7 +55,7 @@
 
   // the static dependency list is used when a cycle is detected
   // in the modules
-  private static String[] STATICDEPENDENCYLIST = new String[] { 
"org.openbravo",
+  private static final String[] STATICDEPENDENCYLIST = new String[] { 
"org.openbravo",
       "org.openbravo.base.weld", "org.openbravo.service.json", 
"org.openbravo.client.kernel",
       "org.openbravo.userinterface.smartclient", 
"org.openbravo.service.datasource",
       "org.openbravo.client.application", 
"org.openbravo.userinterface.selector" };
@@ -200,7 +201,13 @@
       final OBCriteria<Module> modules = 
OBDal.getInstance().createCriteria(Module.class);
       modules.setFetchMode(Module.PROPERTY_MODULEDEPENDENCYLIST, 
FetchMode.JOIN);
       final List<Module> handledModules = new ArrayList<Module>();
+
       try {
+        // Core has a non declared dependency on client.kernel, 
client.application
+        // Build the known dependency list and then check the rest of modules
+        // https://issues.openbravo.com/view.php?id=17249
+        buildKnownDependencies(modules, moduleLowLevelCodes, handledModules);
+
         for (Module module : modules.list()) {
           if (handledModules.contains(module)) {
             continue;
@@ -213,27 +220,9 @@
         }
       } catch (ModuleDependencyCycleException e) {
         // use static list...
-        moduleLowLevelCodes.clear();
-        handledModules.clear();
-        for (Module module : modules.list()) {
-          if (handledModules.contains(module)) {
-            continue;
-          }
-          handledModules.add(module);
-          final ModuleWithLowLevelCode moduleLowLevelCode = new 
ModuleWithLowLevelCode();
-          moduleLowLevelCode.setModule(module);
-          int index = 0;
-          for (String pkg : STATICDEPENDENCYLIST) {
-            if (pkg.equals(module.getJavaPackage())) {
-              break;
-            }
+        buildKnownDependencies(modules, moduleLowLevelCodes, handledModules);
+      }
 
-            index++;
-          }
-          moduleLowLevelCode.setLowLevelCode(index);
-          moduleLowLevelCodes.add(moduleLowLevelCode);
-        }
-      }
       Collections.sort(moduleLowLevelCodes);
       final List<Module> result = new ArrayList<Module>();
       for (ModuleWithLowLevelCode moduleLowLevelCode : moduleLowLevelCodes) {
@@ -246,6 +235,33 @@
     }
   }
 
+  private void buildKnownDependencies(OBCriteria<Module> modules,
+      List<ModuleWithLowLevelCode> moduleLowLevelCodes, List<Module> 
handledModules) {
+    final List<String> knownDependencies = Arrays.asList(STATICDEPENDENCYLIST);
+
+    moduleLowLevelCodes.clear();
+    handledModules.clear();
+
+    for (Module module : modules.list()) {
+      if (handledModules.contains(module) || 
!knownDependencies.contains(module.getJavaPackage())) {
+        continue;
+      }
+      handledModules.add(module);
+      final ModuleWithLowLevelCode moduleLowLevelCode = new 
ModuleWithLowLevelCode();
+      moduleLowLevelCode.setModule(module);
+      int index = 0;
+      for (String pkg : STATICDEPENDENCYLIST) {
+        if (pkg.equals(module.getJavaPackage())) {
+          break;
+        }
+
+        index++;
+      }
+      moduleLowLevelCode.setLowLevelCode(index);
+      moduleLowLevelCodes.add(moduleLowLevelCode);
+    }
+  }
+
   private int computeLowLevelCode(Module module, List<Module> modules) {
     if (module.getId().equals("0")) {
       return 0;

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to