54 |
resp.sendError(400, "not enough parameters"); |
resp.sendError(400, "not enough parameters"); |
55 |
return; |
return; |
56 |
} |
} |
57 |
|
|
58 |
|
boolean arrival = false; |
59 |
|
try { |
60 |
|
arrival = Integer.parseInt( req.getParameter("arrival")) != 0; |
61 |
|
} catch (Exception e) {} |
62 |
|
|
63 |
Statistics.getInstance().incrementDepartureLookups(); |
Statistics.getInstance().incrementDepartureLookups(); |
64 |
|
|
65 |
int station = Integer.parseInt( req.getParameter("station") ); |
int station = Integer.parseInt( req.getParameter("station") ); |
70 |
String stationName = StationDAO.getStationName(station); |
String stationName = StationDAO.getStationName(station); |
71 |
|
|
72 |
try { |
try { |
73 |
beans = fetcher.cachedLookupDepartures(station); |
beans = fetcher.cachedLookupDepartures(station, arrival); |
74 |
} catch (java.io.IOException ioe) { |
} catch (java.io.IOException ioe) { |
75 |
logger.warning("Read failed, station="+station + ". " + ioe.getMessage() ); |
logger.warning("Read failed, station="+station + ". " + ioe.getMessage() ); |
76 |
|
Statistics.getInstance().incrementDepartureErrors(); |
77 |
resp.sendError(500); |
resp.sendError(500); |
78 |
return; |
return; |
79 |
} catch (CircuitBreakerException cbe) { |
} catch (CircuitBreakerException cbe) { |
80 |
logger.warning("Circuitbreaker - failing fast"); |
logger.warning("Circuitbreaker - failing fast"); |
81 |
|
Statistics.getInstance().incrementDepartureErrors(); |
82 |
resp.sendError(500); |
resp.sendError(500); |
83 |
return; |
return; |
84 |
} catch (Exception e) { |
} catch (Exception e) { |
85 |
logger.log(Level.WARNING, "Unknown exception, station=" +station, e); |
logger.log(Level.WARNING, "Unknown exception, station=" +station, e); |
86 |
|
Statistics.getInstance().incrementDepartureErrors(); |
87 |
resp.sendError(500); |
resp.sendError(500); |
88 |
return; |
return; |
89 |
} |
} |
171 |
//transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); |
//transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); |
172 |
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); |
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); |
173 |
transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); |
transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); |
174 |
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); |
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1"); |
175 |
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
176 |
java.io.StringWriter sw = new java.io.StringWriter(); |
java.io.StringWriter sw = new java.io.StringWriter(); |
177 |
StreamResult sr = new StreamResult(sw); |
StreamResult sr = new StreamResult(sw); |