From d2c02c1bf0a8d8a8b00ff0343d16a8ad90c07cd0 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 19 May 2020 23:20:29 +0200 Subject: [PATCH] #resolve IDEMPIERE-4302 Improve Schedule discovery (#74) --- .../i7.1/oracle/202005192306_IDEMPIERE-4302.sql | 11 +++++++++++ .../postgresql/202005192306_IDEMPIERE-4302.sql | 8 ++++++++ .../src/org/compiere/model/MSchedule.java | 14 ++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 migration/i7.1/oracle/202005192306_IDEMPIERE-4302.sql create mode 100644 migration/i7.1/postgresql/202005192306_IDEMPIERE-4302.sql diff --git a/migration/i7.1/oracle/202005192306_IDEMPIERE-4302.sql b/migration/i7.1/oracle/202005192306_IDEMPIERE-4302.sql new file mode 100644 index 0000000000..ae5a5c22ce --- /dev/null +++ b/migration/i7.1/oracle/202005192306_IDEMPIERE-4302.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-4302 Improve Schedule discovery +-- May 19, 2020, 11:04:59 PM CEST +UPDATE AD_Column SET Description='Run only on this IP address', Help='This is a list of semicolon (;) separated IP addresses or hostnames, if empty or 0.0.0.0 means the schedule can run in all servers.',Updated=TO_DATE('2020-05-19 23:04:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200486 +; + +SELECT register_migration_script('202005192306_IDEMPIERE-4302.sql') FROM dual +; + diff --git a/migration/i7.1/postgresql/202005192306_IDEMPIERE-4302.sql b/migration/i7.1/postgresql/202005192306_IDEMPIERE-4302.sql new file mode 100644 index 0000000000..c403d6dba5 --- /dev/null +++ b/migration/i7.1/postgresql/202005192306_IDEMPIERE-4302.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-4302 Improve Schedule discovery +-- May 19, 2020, 11:04:59 PM CEST +UPDATE AD_Column SET Description='Run only on this IP address', Help='This is a list of semicolon (;) separated IP addresses or hostnames, if empty or 0.0.0.0 means the schedule can run in all servers.',Updated=TO_TIMESTAMP('2020-05-19 23:04:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=200486 +; + +SELECT register_migration_script('202005192306_IDEMPIERE-4302.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MSchedule.java b/org.adempiere.base/src/org/compiere/model/MSchedule.java index a95f0ba7f4..8b82ce0b7e 100644 --- a/org.adempiere.base/src/org/compiere/model/MSchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MSchedule.java @@ -89,6 +89,9 @@ public class MSchedule extends X_AD_Schedule */ public boolean isOKtoRunOnIP() { + if (!isActive()) { + return false; + } String ipOnly = getRunOnlyOnIP(); // 0.0.0.0 = all ip address if ((ipOnly == null) || (ipOnly.length() == 0) || "0.0.0.0".equals(ipOnly)) @@ -138,6 +141,17 @@ public class MSchedule extends X_AD_Schedule } } } + if (!chekIPFormat(ipOnly)) { + // verify with the local hostname + String retVal = InetAddress.getLocalHost().getHostName(); + retVal = InetAddress.getLocalHost().getCanonicalHostName(); + if (ipOnly.equals(retVal)) { + if (log.isLoggable(Level.INFO)) log.info("Allowed here - IP=" + retVal+ " match"); + return true; + } else { + if (log.isLoggable(Level.INFO)) log.info("Not Allowed here - IP=" + retVal+ " does not match " + ipOnly); + } + } } catch (Exception e) { log.log(Level.SEVERE, "", e); }