#resolve IDEMPIERE-4302 Improve Schedule discovery (#74)

This commit is contained in:
Carlos Ruiz 2020-05-19 23:20:29 +02:00 committed by GitHub
parent 5550a9633c
commit d2c02c1bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -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);
}