--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/10/01 05:30:32 1145 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/11/12 18:33:38 1190 @@ -1,9 +1,9 @@ package dk.thoerup.traininfoservice.banedk; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.StringWriter; import java.util.logging.Level; import java.util.logging.Logger; @@ -70,9 +70,13 @@ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req.getParameter("station") == null) { - resp.sendError(400, "not enough parameters"); + resp.sendError(400, "not enough parameters (station)"); return; } + if (req.getParameter("format") == null) { + resp.sendError(400, "not enough parameters (format)"); + return; + } boolean arrival = false; try { @@ -95,7 +99,7 @@ resp.sendError(500); return; } catch (CircuitBreakerException cbe) { - logger.warning("Circuitbreaker - failing fast"); + logger.warning("Circuitbreaker - failing fast, station=" +station); Statistics.getInstance().incrementDepartureErrors(); resp.sendError(500); return; @@ -138,7 +142,7 @@ Serializer serializer = new Persister(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + StringWriter out = new StringWriter(); try { serializer.write(beans, out); @@ -155,7 +159,7 @@ Transformer trans = xslTemplate.newTransformer(); Source xml = new StreamSource( new ByteArrayInputStream(input.getBytes() )); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + StringWriter out = new StringWriter(); trans.transform(xml, new StreamResult(out)); return out.toString();