/[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 716 by torben, Mon May 10 06:53:20 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                    Statistics.getInstance().incrementDepartureLookups();
58                                    
59                  int station = Integer.parseInt( req.getParameter("station") );                  int station = Integer.parseInt( req.getParameter("station") );
60                  String format = req.getParameter("format");                  String format = req.getParameter("format");
# Line 65  public class DepartureServlet extends Ht Line 67  public class DepartureServlet extends Ht
67                          beans = fetcher.cachedLookupDepartures(station);                          beans = fetcher.cachedLookupDepartures(station);
68                  } catch (java.io.IOException ioe) {                  } catch (java.io.IOException ioe) {
69                          logger.warning("Read failed, station="+station + ". " + ioe.getMessage() );                          logger.warning("Read failed, station="+station + ". " + ioe.getMessage() );
70                            Statistics.getInstance().incrementDepartureErrors();
71                          resp.sendError(500);                          resp.sendError(500);
72                          return;                          return;
73                  } catch (CircuitBreakerException cbe) {                  } catch (CircuitBreakerException cbe) {
74                          logger.warning("Circuitbreaker - failing fast");                          logger.warning("Circuitbreaker - failing fast");
75                            Statistics.getInstance().incrementDepartureErrors();
76                          resp.sendError(500);                          resp.sendError(500);
77                          return;                          return;
78                  } catch (Exception e) {                                  } catch (Exception e) {                
79                          logger.log(Level.WARNING, "Unknown exception, station=" +station, e);                          logger.log(Level.WARNING, "Unknown exception, station=" +station, e);
80                            Statistics.getInstance().incrementDepartureErrors();
81                          resp.sendError(500);                          resp.sendError(500);
82                          return;                          return;
83                  }                  }
# Line 144  public class DepartureServlet extends Ht Line 149  public class DepartureServlet extends Ht
149                          note.setTextContent( departure.getNote() );                          note.setTextContent( departure.getNote() );
150                          train.appendChild(note);                          train.appendChild(note);
151                                                    
152                            Element type = doc.createElement("type");
153                            type.setTextContent( departure.getType() );
154                            train.appendChild(type);
155                            
156                          root.appendChild(train);                          root.appendChild(train);
157                  }                  }
158                                    

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

  ViewVC Help
Powered by ViewVC 1.1.20