17 |
import java.util.Map; |
import java.util.Map; |
18 |
import java.util.logging.Level; |
import java.util.logging.Level; |
19 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
|
import java.util.zip.GZIPInputStream; |
|
20 |
import java.util.zip.ZipEntry; |
import java.util.zip.ZipEntry; |
21 |
import java.util.zip.ZipOutputStream; |
import java.util.zip.ZipOutputStream; |
22 |
|
|
78 |
return empty; |
return empty; |
79 |
} |
} |
80 |
|
|
81 |
int from = logFiles.length - (count); |
int from = (count>logFiles.length) ? 0 : logFiles.length - (count); |
82 |
int to = logFiles.length; |
int to = logFiles.length; |
83 |
|
|
84 |
return Arrays.copyOfRange(logFiles, from, to); |
return Arrays.copyOfRange(logFiles, from, to); |
85 |
} |
} |
86 |
|
|
87 |
protected PositionContainer getRequestsFromFileWorker(boolean multiple) throws IOException{ |
protected PositionContainer getRequestsFromFileWorker(int count) throws IOException{ |
88 |
PositionContainer positions = new PositionContainer(); |
PositionContainer positions = new PositionContainer(); |
89 |
|
|
90 |
try { |
try { |
|
|
|
|
int count; |
|
|
|
|
|
if (multiple == false) { |
|
|
count = 1; |
|
|
} else { |
|
|
count = 4; |
|
|
} |
|
91 |
|
|
92 |
File files[] = getFiles(count); |
File files[] = getFiles(count); |
93 |
|
|
336 |
return sb.toString(); |
return sb.toString(); |
337 |
} |
} |
338 |
|
|
339 |
protected String getRequestsFromFile(boolean multiple) throws IOException { |
protected String getRequestsFromFile(int count) throws IOException { |
340 |
String kmlData = null; |
String kmlData = null; |
341 |
String key; |
String key; |
342 |
|
|
343 |
if (multiple == false) { |
key = "kmldata-" + count; |
|
key = "kmldata"; |
|
|
} else { |
|
|
key = "kmldata-multi"; |
|
|
} |
|
344 |
|
|
345 |
kmlData = null;// = cache.get(key); |
kmlData = cache.get(key); |
346 |
|
|
347 |
if (kmlData == null) { |
if (kmlData == null) { |
348 |
kmlData = formatXml( getRequestsFromFileWorker(multiple) ); |
kmlData = formatXml( getRequestsFromFileWorker(count) ); |
349 |
cache.put(key, kmlData); |
cache.put(key, kmlData); |
350 |
kmlData += "<!-- from source -->"; |
kmlData += "<!-- from source -->"; |
351 |
} else { |
} else { |
368 |
return (p != 0); |
return (p != 0); |
369 |
} |
} |
370 |
|
|
371 |
|
int getCount(String param) { |
372 |
|
if (param == null || param.equals("")) { |
373 |
|
return 1; |
374 |
|
} |
375 |
|
|
376 |
|
return Integer.parseInt(param); |
377 |
|
} |
378 |
|
|
379 |
|
|
380 |
@Override |
@Override |
381 |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
382 |
|
|
|
boolean multiple = enabled( req.getParameter("multi") ); |
|
383 |
|
|
384 |
String kmlData = getRequestsFromFile(multiple); |
int count = getCount( req.getParameter("count") ); |
385 |
|
|
386 |
|
if (count > 30) //limit to 30 days |
387 |
|
count = 30; |
388 |
|
|
389 |
|
String kmlData = getRequestsFromFile(count); |
390 |
|
|
391 |
if ( enabled(req.getParameter("zip")) ) { |
if ( enabled(req.getParameter("zip")) ) { |
392 |
|
|