Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxDateState.java @ 1139:3a28fef65500
dummy merge for repo head
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:15:16 +0200 |
parents | f953c9a559d8 |
children |
rev | line source |
---|---|
1115
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
1 /* |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
3 * |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
7 */ |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
8 |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.state; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.util.Collection; |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
12 import java.util.Date; |
823
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
13 import java.util.GregorianCalendar; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import java.util.Iterator; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.util.Locale; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
823
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
18 import org.w3c.dom.Document; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
823
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
20 import de.intevation.artifacts.CallContext; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
21 import de.intevation.gnv.artifacts.ressource.RessourceFactory; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
22 import de.intevation.gnv.geobackend.util.DateUtils; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
23 import de.intevation.gnv.state.describedata.DefaultMinMaxDescribeData; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
24 import de.intevation.gnv.state.describedata.DescribeData; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
25 import de.intevation.gnv.state.describedata.MinMaxDescribeData; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
26 import de.intevation.gnv.state.exception.StateException; |
499cfbbb61bc
Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents:
796
diff
changeset
|
27 import de.intevation.gnv.utils.InputValidator; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
30 * This state handles date input. The resulting describe document of this state |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
31 * contains two fields in the user interface description to define a time range. |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
32 * |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
33 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 */ |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public class MinMaxDateState extends MinMaxState { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
38 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
39 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
40 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public static final String EXCEPTION_DATE_REQUIRED = |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 "input.is.not.valid.date.required"; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
44 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
45 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
46 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 public static final String EXCEPTION_START_AFTER_END = |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 "start.date.after.end.date"; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
50 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
51 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
52 */ |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
53 public static final String EXCEPTION_DATE_OUT_OF_RANGE = |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
54 "date.out.of.range"; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
55 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
56 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
57 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
58 */ |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
59 public static final String EXCEPTION_MISSING_DATE = |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
60 "missing.data.field"; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
61 |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 private static Logger logger = Logger.getLogger(MinMaxDateState.class); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
65 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
66 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
67 */ |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 public MinMaxDateState() { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 super(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
74 * This feed method needs a collection of two InputData objects. These |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
75 * objects' values need to be a datetime string which is turned into a Date |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
76 * object. Afterwards, the given dates are validated. Min and max date need |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
77 * to be in range of the min and max date retrieved by |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
78 * {@link #getDescibeData(java.lang.String)}. |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 */ |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 @Override |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 public Document feed( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 CallContext context, |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 Collection<InputData> inputData, |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 String uuid) |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 throws StateException { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 RessourceFactory resFactory = RessourceFactory.getInstance(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 Locale[] serverLocales = resFactory.getLocales(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 Locale locale = context.getMeta().getPreferredLocale( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 serverLocales); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 if (inputData == null) { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 String msg = "No input data given."; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 logger.warn(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 return feedFailure(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 Iterator iter = inputData.iterator(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
99 MinMaxDescribeData data = |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
100 (MinMaxDescribeData) getDescibeData(uuid).get(0); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
101 Object min = data.getMinValue(); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
102 Object max = data.getMaxValue(); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
103 |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
104 Object tmpMin = null; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
105 Object tmpMax = null; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 while (iter.hasNext()) { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 InputData tmp = (InputData) iter.next(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 InputValue meta = inputValues.get(tmp.getName()); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 String type = meta.getType(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 String value = tmp.getValue(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 String name = tmp.getName(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 if (meta == null) { |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 String msg = "Input data not expected here. Data will be ignored."; |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 logger.warn(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 return feedFailure(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
120 if (!InputValidator.isInputValid(value, type)) { |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 String msg = resFactory.getRessource( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 locale, EXCEPTION_DATE_REQUIRED, EXCEPTION_DATE_REQUIRED); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 logger.error(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 return feedFailure(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
127 Date lower = null; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
128 if (min instanceof GregorianCalendar) { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
129 lower = ((GregorianCalendar)min).getTime(); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
130 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
131 |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
132 Date upper = null; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
133 if (max instanceof GregorianCalendar) { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
134 upper = ((GregorianCalendar)max).getTime(); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
135 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
136 |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
137 Date d = null; |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
138 try { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
139 d = DateUtils.getDateFromString(value,DateUtils.DATE_PATTERN); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
140 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
141 catch (Exception e) { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
142 logger.warn(e, e); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
143 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
144 |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
145 if (d == null || lower == null || upper == null) { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
146 String msg = resFactory.getRessource( |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
147 locale, |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
148 EXCEPTION_MISSING_DATE, |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
149 EXCEPTION_MISSING_DATE); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
150 logger.warn(msg); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
151 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
152 else { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
153 if (logger.isDebugEnabled()) { |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
154 logger.debug("Date to validate: " + d.toString()); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
155 logger.debug("Lower date bound: " + lower.toString()); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
156 logger.debug("Upper date bound: " + upper.toString()); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
157 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
158 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
159 if (!InputValidator.isDateValid(d, lower, upper)) { |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
160 String msg = resFactory.getRessource( |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
161 locale, |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
162 EXCEPTION_DATE_OUT_OF_RANGE, |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
163 EXCEPTION_DATE_OUT_OF_RANGE); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
164 logger.error(msg); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
165 return feedFailure(msg); |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
166 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
167 } |
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
168 |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 if (name.equals(MINVALUEFIELDNAME)) { |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
170 tmpMin = value; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 if (name.equals(MAXVALUEFIELDNAME)) { |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
174 tmpMax = value; |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
177 if (tmpMin != null && tmpMax != null) { |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
178 if (!InputValidator.isInputValid((String) tmpMin, (String) tmpMax, type)) { |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 String msg = resFactory.getRessource( |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 locale, |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 EXCEPTION_START_AFTER_END, |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 EXCEPTION_START_AFTER_END); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 logger.error(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 return feedFailure(msg); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 DescribeData values = new DefaultMinMaxDescribeData( |
784
7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
190 dataName, tmpMin, tmpMax, getID()); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
725
diff
changeset
|
192 this.inputData.put(dataName, new DefaultInputData(dataName, values)); |
725
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 return feedSuccess(); |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 } |
dde7f51dbe1e
Improved exception handling while feeding an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 } |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
784
diff
changeset
|
197 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |