Mercurial > dive4elements > gnv-client
changeset 1088:46cc1ab1ee15
Improved the validation of user inserted time periods (issue286).
gnv-artifacts/trunk@1191 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Jun 2010 10:16:29 +0000 |
parents | 92fce3b3d07f |
children | 1dc08501a1be |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java |
diffstat | 2 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Thu Jun 10 09:23:33 2010 +0000 +++ b/gnv-artifacts/ChangeLog Thu Jun 10 10:16:29 2010 +0000 @@ -1,3 +1,12 @@ +2010-06-10 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + Issue286 - Input validation of time ranges + + * src/main/java/de/intevation/gnv/utils/InputValidator.java: Removed the + epsilon that has been used to compare time values. Now, we just compare + the seconds of a time value pair - background: datetime objects differ in + milliseconds. + 2010-06-10 Ingo Weinzierl <ingo.weinzierl@intevation.de> Issue290 - Centering of pdf exports
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Thu Jun 10 09:23:33 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Thu Jun 10 10:16:29 2010 +0000 @@ -28,11 +28,6 @@ */ private static Logger log = Logger.getLogger(InputValidator.class); - /** - * Epsilon for handling unprecise date objects (in ms). - */ - public final static long DATE_EPSILON = 750; - public final static String NODATASELECTEDVALUE = "n/n"; @@ -226,11 +221,19 @@ * @return true, if tmp is valid, otherwise false. */ public static boolean isDateValid(Date tmp, Date lo, Date up) { - long tmpTime = tmp.getTime(); - long tmpLow = lo.getTime(); - long tmpUp = up.getTime(); + // take the time in seconds to compare + long tmpTime = tmp.getTime() / 1000; + long tmpLow = lo.getTime() / 1000; + long tmpUp = up.getTime() / 1000; - if (tmpTime < tmpLow - DATE_EPSILON || tmpTime > tmpUp + DATE_EPSILON) { + if (log.isDebugEnabled()) { + log.debug("Date validation..."); + log.debug("-> lower bound [sec]: " + tmpLow); + log.debug("-> upper bound [sec]: " + tmpUp); + log.debug("-> input data [sec]: " + tmpTime); + } + + if (tmpTime < tmpLow || tmpTime > tmpUp) { log.warn( "Date [" + tmp.toString() + "] is out of range [" + lo.toString() + " to "+ up.toString() + "].");