/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 650 by torben, Mon Apr 19 19:04:34 2010 UTC revision 829 by torben, Thu Jun 10 22:26:09 2010 UTC
# Line 23  import org.w3c.dom.Element; Line 23  import org.w3c.dom.Element;
23    
24  import dk.thoerup.circuitbreaker.CircuitBreakerException;  import dk.thoerup.circuitbreaker.CircuitBreakerException;
25  import dk.thoerup.traininfoservice.StationDAO;  import dk.thoerup.traininfoservice.StationDAO;
26    import dk.thoerup.traininfoservice.Statistics;
27    
28  /**  /**
29   * Servlet implementation class DepartureServlet   * Servlet implementation class DepartureServlet
# Line 48  public class DepartureServlet extends Ht Line 49  public class DepartureServlet extends Ht
49          }          }
50    
51          @Override          @Override
52          protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {          protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {          
53                  if (req.getParameter("station") == null) {                  if (req.getParameter("station") == null) {
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();
64                    
65                  int station = Integer.parseInt( req.getParameter("station") );                  int station = Integer.parseInt( req.getParameter("station") );
66                  String format = req.getParameter("format");                  String format = req.getParameter("format");
67    
# Line 62  public class DepartureServlet extends Ht Line 70  public class DepartureServlet extends Ht
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                  }                  }
# Line 144  public class DepartureServlet extends Ht Line 155  public class DepartureServlet extends Ht
155                          note.setTextContent( departure.getNote() );                          note.setTextContent( departure.getNote() );
156                          train.appendChild(note);                          train.appendChild(note);
157                                                    
158                            Element type = doc.createElement("type");
159                            type.setTextContent( departure.getType() );
160                            train.appendChild(type);
161                            
162                          root.appendChild(train);                          root.appendChild(train);
163                  }                  }
164                                    

Legend:
Removed from v.650  
changed lines
  Added in v.829

  ViewVC Help
Powered by ViewVC 1.1.20