details:   https://code.openbravo.com/erp/devel/pi/rev/8953f39e61ca
changeset: 27880:8953f39e61ca
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Nov 13 11:33:39 2015 +0100
summary:   Fixes issue 31461: Add property to prevent import process threads to 
run in instance
Prevent threads from starting if import.disable.process property is set to true

details:   https://code.openbravo.com/erp/devel/pi/rev/6c157f30e17f
changeset: 27881:6c157f30e17f
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Nov 13 12:14:29 2015 +0100
summary:   Related to issue 31461: Add property to prevent import process 
threads to run in instance
Prevent NPE when entries are created

diffstat:

 src/org/openbravo/service/importprocess/ImportEntryManager.java |  13 
+++++++++-
 src/org/openbravo/service/importprocess/ImportProcessUtils.java |   7 +++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diffs (58 lines):

diff -r 24ecac05d0fd -r 6c157f30e17f 
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java   Fri Nov 
13 11:07:02 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java   Fri Nov 
13 12:14:29 2015 +0100
@@ -172,10 +172,16 @@
   }
 
   public synchronized void start() {
+    if (ImportProcessUtils.isImportProcessDisabled()) {
+      log.debug("Import process disabled, not starting it");
+      return;
+    }
+
     if (threadsStarted) {
       return;
     }
     threadsStarted = true;
+
     log.debug("Starting Import Entry Framework");
 
     // same as fixed threadpool, will only stop accepting new tasks (throw an 
exception)
@@ -223,6 +229,9 @@
    * Shutdown all the threads being used by the import framework
    */
   public void shutdown() {
+    if (!threadsStarted) {
+      return;
+    }
     log.debug("Shutting down Import Entry Framework");
 
     isShutDown = true;
@@ -328,7 +337,9 @@
       start();
     }
 
-    managerThread.doNotify();
+    if (managerThread != null) {
+      managerThread.doNotify();
+    }
   }
 
   private void handleImportEntry(ImportEntry importEntry) {
diff -r 24ecac05d0fd -r 6c157f30e17f 
src/org/openbravo/service/importprocess/ImportProcessUtils.java
--- a/src/org/openbravo/service/importprocess/ImportProcessUtils.java   Fri Nov 
13 11:07:02 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportProcessUtils.java   Fri Nov 
13 12:14:29 2015 +0100
@@ -42,6 +42,13 @@
  */
 public class ImportProcessUtils {
 
+  /**
+   * Returns true if the import.disable.process property is set to true, false 
otherwise
+   */
+  public static boolean isImportProcessDisabled() {
+    return 
OBPropertiesProvider.getInstance().getBooleanProperty("import.disable.process");
+  }
+
   public static List<String> getOrderedTypesOfData() {
     final Reference reference = OBDal.getInstance().get(Reference.class,
         "11F86B630ECB4A57B28927193F8AB99D");

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to