/[projects]/android/TrainInfoServiceGoogle/src/dk/thoerup/traininfoservice/LoadStations.java
ViewVC logotype

Annotation of /android/TrainInfoServiceGoogle/src/dk/thoerup/traininfoservice/LoadStations.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1105 - (hide annotations) (download)
Wed Sep 22 21:09:39 2010 UTC (13 years, 8 months ago) by torben
File size: 1255 byte(s)
Got DAO working, now i'm just missing the last bit of loading station identifiers from app.t-hoerup.dk
1 torben 301 package dk.thoerup.traininfoservice;
2    
3     import java.io.IOException;
4    
5     import javax.servlet.ServletException;
6     import javax.servlet.http.HttpServlet;
7     import javax.servlet.http.HttpServletRequest;
8     import javax.servlet.http.HttpServletResponse;
9    
10 torben 1105 import org.simpleframework.xml.Serializer;
11     import org.simpleframework.xml.core.Persister;
12    
13     import dk.thoerup.android.traininfo.common.StationBean;
14    
15    
16 torben 1080 //@WebServlet(urlPatterns={"/LoadStations"})
17 torben 301
18     public class LoadStations extends HttpServlet {
19     private static final long serialVersionUID = 1L;
20    
21     public LoadStations() {
22     super();
23     }
24    
25    
26 torben 425 @Override
27 torben 301 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
28 torben 1105 String url = "http://app.t-hoerup.dk/TrainInfoService/LocateStations?dump";
29    
30     String xml = DownloadUtil.getContentString(url, 5000, "ISO-8859-1");
31    
32     Serializer serializer = new Persister();
33     StationBean stations;
34 torben 301 try {
35 torben 1105 stations = serializer.read(StationBean.class, xml);
36 torben 301 } catch (Exception e) {
37     throw new ServletException(e);
38 torben 1105 }
39    
40     StationDAO stationdao = new StationDAO();
41     int count = stationdao.saveStations(stations);
42    
43     resp.getWriter().print("Saved " + count + " entries");
44    
45 torben 301 }
46    
47     }

  ViewVC Help
Powered by ViewVC 1.1.20