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 |
|
final String KEY = "kmldata"; |
163 |
|
|
164 |
String data = cache.get("data"); |
String kmlData = cache.get(KEY); |
165 |
|
|
166 |
if (data == null) { |
if (kmlData == null) { |
167 |
data = formatXml( getRequestsFromFile() ); |
kmlData = formatXml( getRequestsFromFile() ); |
168 |
cache.put("data", data); |
cache.put(KEY, kmlData); |
169 |
data += "<!-- from source -->"; |
kmlData += "<!-- from source -->"; |
170 |
} else { |
} else { |
171 |
data += "<!-- cached -->"; |
kmlData += "<!-- cached -->"; |
172 |
} |
} |
173 |
|
|
174 |
|
|
179 |
|
|
180 |
ZipOutputStream zip = new ZipOutputStream(baos); |
ZipOutputStream zip = new ZipOutputStream(baos); |
181 |
zip.putNextEntry( new ZipEntry("trains.kml") ); |
zip.putNextEntry( new ZipEntry("trains.kml") ); |
182 |
zip.write( data.getBytes() ); |
zip.write( kmlData.getBytes() ); |
183 |
zip.closeEntry(); |
zip.closeEntry(); |
184 |
zip.close(); |
zip.close(); |
185 |
|
|
191 |
|
|
192 |
} else { |
} else { |
193 |
resp.setContentType(KML); |
resp.setContentType(KML); |
194 |
resp.getWriter().print( data ); |
resp.getWriter().print( kmlData ); |
195 |
} |
} |
196 |
} |
} |
197 |
} |
} |