10 |
import java.util.ArrayList; |
import java.util.ArrayList; |
11 |
import java.util.Date; |
import java.util.Date; |
12 |
import java.util.List; |
import java.util.List; |
13 |
|
import java.util.Map; |
14 |
import java.util.logging.Level; |
import java.util.logging.Level; |
15 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
16 |
import java.util.zip.ZipEntry; |
import java.util.zip.ZipEntry; |
21 |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletRequest; |
22 |
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
23 |
|
|
24 |
|
import dk.thoerup.traininfoservice.banedk.TimeoutMap; |
25 |
|
|
26 |
public class RequestPlotter extends HttpServlet { |
public class RequestPlotter extends HttpServlet { |
27 |
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
28 |
|
|
30 |
|
|
31 |
static final String KML = "application/vnd.google-earth.kml"; |
static final String KML = "application/vnd.google-earth.kml"; |
32 |
static final String KMZ = "application/vnd.google-earth.kmz"; |
static final String KMZ = "application/vnd.google-earth.kmz"; |
33 |
|
|
34 |
|
Map<String,String> cache = new TimeoutMap<String,String>(2*60*1000); |
35 |
|
|
36 |
class RequestPosition { |
class RequestPosition { |
37 |
public String ip; |
public String ip; |
159 |
|
|
160 |
@Override |
@Override |
161 |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
162 |
|
|
163 |
|
String data = cache.get("data"); |
164 |
|
|
165 |
|
if (data == null) { |
166 |
|
data = formatXml( getRequestsFromFile() ); |
167 |
|
cache.put("data", data); |
168 |
|
data += "<!-- from source -->"; |
169 |
|
} else { |
170 |
|
data += "<!-- cached -->"; |
171 |
|
} |
172 |
|
|
173 |
String data = formatXml( getRequestsFromFile() ); |
|
174 |
|
|
175 |
if (req.getParameter("zip") != null) { |
if (req.getParameter("zip") != null) { |
176 |
|
|