@@ -213,37 +213,42 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws Ser
213
213
}
214
214
}
215
215
216
+ String periodParam = req .getParameter ("period" );
217
+ String timeBeginParam = req .getParameter ("begin" );
218
+ String timeEndParam = req .getParameter ("end" );
216
219
// To avoid ambiguity you are not allowed to specify period, begin and end time at the same time.
217
- if (req .getParameter ("period" ) != null && req .getParameter ("begin" ) != null
218
- && req .getParameter ("end" ) != null ) {
220
+ if (periodParam != null && timeBeginParam != null && timeEndParam != null ) {
219
221
res .sendError (HttpServletResponse .SC_BAD_REQUEST ,
220
222
"Do not specify the three parameters period, begin and end at the same time." );
221
223
return ;
222
224
}
223
225
224
226
// Read out the parameter period, begin and end and save them.
227
+ Long period = null ;
225
228
Date timeBegin = null ;
226
229
Date timeEnd = null ;
227
230
228
- Long period = PERIODS .get (req .getParameter ("period" ));
231
+ if (periodParam != null ) {
232
+ period = PERIODS .get (periodParam );
233
+ }
229
234
if (period == null ) {
230
235
// use a day as the default period
231
236
period = PERIODS .get ("D" );
232
237
}
233
238
234
- if (req . getParameter ( "begin" ) != null ) {
239
+ if (timeBeginParam != null ) {
235
240
try {
236
- timeBegin = new SimpleDateFormat (DATE_FORMAT ).parse (req . getParameter ( "begin" ) );
241
+ timeBegin = new SimpleDateFormat (DATE_FORMAT ).parse (timeBeginParam );
237
242
} catch (ParseException e ) {
238
243
res .sendError (HttpServletResponse .SC_BAD_REQUEST ,
239
244
"Begin and end must have this format: " + DATE_FORMAT + "." );
240
245
return ;
241
246
}
242
247
}
243
248
244
- if (req . getParameter ( "end" ) != null ) {
249
+ if (timeEndParam != null ) {
245
250
try {
246
- timeEnd = new SimpleDateFormat (DATE_FORMAT ).parse (req . getParameter ( "end" ) );
251
+ timeEnd = new SimpleDateFormat (DATE_FORMAT ).parse (timeEndParam );
247
252
} catch (ParseException e ) {
248
253
res .sendError (HttpServletResponse .SC_BAD_REQUEST ,
249
254
"Begin and end must have this format: " + DATE_FORMAT + "." );
@@ -292,9 +297,10 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws Ser
292
297
}
293
298
294
299
// Read out parameter 'legend'
300
+ String legendParam = req .getParameter ("legend" );
295
301
Boolean legend = null ;
296
- if (req . getParameter ( "legend" ) != null ) {
297
- legend = Boolean .valueOf (req . getParameter ( "legend" ) );
302
+ if (legendParam != null ) {
303
+ legend = Boolean .valueOf (legendParam );
298
304
}
299
305
300
306
if (maxWidth > 0 && width > maxWidth ) {
0 commit comments