Fixes BUG-42595: Don't cache StyleSheets if any module in development
authorCristian Berner <cristian.berner@openbravo.com>
Wed, 08 Jan 2020 12:48:53 +0100
changeset 36925 1287a292a138
parent 36924 2bf4a5d49474
child 36926 82de1963f8ba
Fixes BUG 42595: Don't cache StyleSheets if any module in development

Previously StyleSheets were cached if working on a module and there weren't any other module with CSS set to inDevelopment

Behaviour for checking if instance is in development is now the same for both StyleSheetResourceComponent and StaticResourceComponent. It follows BaseComponent isInDevelopment logic, if a module is in development, all the instance is in development.
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Tue Jan 14 09:06:25 2020 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Wed Jan 08 12:48:53 2020 +0100
@@ -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) 2010-2017 Openbravo SLU
+ * All portions are Copyright (C) 2010-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.openbravo.base.session.OBPropertiesProvider;
+import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource.ComponentResourceType;
 import org.openbravo.dal.core.OBContext;
@@ -57,24 +58,12 @@
   @Inject
   private StaticResourceProvider resourceProvider;
 
-  private Boolean isInDevelopment;
+  @Inject
+  private ApplicationDictionaryCachedStructures adCachedStructures;
 
   @Override
   public boolean isInDevelopment() {
-    if (isInDevelopment == null) {
-      isInDevelopment = false;
-      for (ComponentProvider provider : componentProviders) {
-        final List<ComponentResource> resources = provider.getGlobalComponentResources();
-        if (resources == null || resources.size() == 0) {
-          continue;
-        }
-        if (provider.getModule().isInDevelopment()) {
-          isInDevelopment = true;
-          return isInDevelopment;
-        }
-      }
-    }
-    return isInDevelopment;
+    return adCachedStructures.isInDevelopment();
   }
 
   /**
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java	Tue Jan 14 09:06:25 2020 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java	Wed Jan 08 12:48:53 2020 +0100
@@ -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) 2010-2017 Openbravo SLU
+ * All portions are Copyright (C) 2010-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource.ComponentResourceType;
 import org.openbravo.model.ad.module.Module;
@@ -56,33 +57,12 @@
   @Inject
   private StaticResourceProvider resourceProvider;
 
-  private Boolean isInDevelopment;
+  @Inject
+  private ApplicationDictionaryCachedStructures adCachedStructures;
 
   @Override
   public boolean isInDevelopment() {
-    if (isInDevelopment == null) {
-      isInDevelopment = false;
-      final List<Module> modules = KernelUtils.getInstance().getModulesOrderedByDependency();
-      for (Module module : modules) {
-        for (ComponentProvider provider : componentProviders) {
-          final List<ComponentResource> resources = provider.getGlobalComponentResources();
-          if (resources == null || resources.size() == 0) {
-            continue;
-          }
-
-          if (provider.getModule().getId().equals(module.getId())) {
-            for (ComponentResource resource : resources) {
-              if (resource.getType() == ComponentResourceType.Stylesheet
-                  && module.isInDevelopment()) {
-                isInDevelopment = true;
-                break;
-              }
-            }
-          }
-        }
-      }
-    }
-    return isInDevelopment;
+    return adCachedStructures.isInDevelopment();
   }
 
   /**