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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1105 - (show annotations) (download)
Wed Sep 22 21:09:39 2010 UTC (13 years, 7 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 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 import org.simpleframework.xml.Serializer;
11 import org.simpleframework.xml.core.Persister;
12
13 import dk.thoerup.android.traininfo.common.StationBean;
14
15
16 //@WebServlet(urlPatterns={"/LoadStations"})
17
18 public class LoadStations extends HttpServlet {
19 private static final long serialVersionUID = 1L;
20
21 public LoadStations() {
22 super();
23 }
24
25
26 @Override
27 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
28 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 try {
35 stations = serializer.read(StationBean.class, xml);
36 } catch (Exception e) {
37 throw new ServletException(e);
38 }
39
40 StationDAO stationdao = new StationDAO();
41 int count = stationdao.saveStations(stations);
42
43 resp.getWriter().print("Saved " + count + " entries");
44
45 }
46
47 }

  ViewVC Help
Powered by ViewVC 1.1.20