26 |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletRequest; |
27 |
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
28 |
|
|
29 |
|
import dk.thoerup.genericjavautils.HttpUtil; |
30 |
import dk.thoerup.genericjavautils.TimeoutMap; |
import dk.thoerup.genericjavautils.TimeoutMap; |
31 |
|
|
32 |
@WebServlet(urlPatterns={"/RequestPlotter"}) |
@WebServlet(urlPatterns={"/RequestPlotter"}) |
59 |
return fileStr.substring(fileStr.length() - 3).equals(".gz"); |
return fileStr.substring(fileStr.length() - 3).equals(".gz"); |
60 |
} |
} |
61 |
|
|
62 |
protected File[] getFiles(int count) { |
public static File[] getFiles(int count) { |
63 |
File accessLogDir = new File("/home/app/domain1/logs/access/"); |
File accessLogDir = new File("/home/app/domain1/logs/access/"); |
64 |
//File accessLogDir = new File("/home/torben/inst/glassfishv3/glassfish/domains/domain1/logs/access/"); |
//File accessLogDir = new File("/home/torben/inst/glassfishv3/glassfish/domains/domain1/logs/access/"); |
65 |
|
|
123 |
continue; |
continue; |
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
RequestPosition pos = new RequestPosition(); |
RequestPosition pos = new RequestPosition(); |
129 |
|
|
130 |
String toks[] = line.split(" "); |
String toks[] = line.split(" "); |
132 |
|
|
133 |
pos.time = df.parse( toks[2].replace("\"", "") ); |
pos.time = df.parse( toks[2].replace("\"", "") ); |
134 |
|
|
135 |
String argpart = toks[5].split("\\?")[1]; |
Map<String,String> params = HttpUtil.decodeUri( toks[5] ); |
|
|
|
|
String args[] = argpart.split("&"); |
|
136 |
|
|
137 |
pos.lat = args[0].split("=")[1]; |
pos.lat = params.get("latitude"); |
138 |
pos.lng = args[1].split("=")[1]; |
pos.lng = params.get("longitude"); |
139 |
|
|
140 |
|
|
141 |
long timediff = now.getTime() - pos.time.getTime(); |
long timediff = now.getTime() - pos.time.getTime(); |
268 |
for(RequestPosition current : list) { |
for(RequestPosition current : list) { |
269 |
String id = color + count++; |
String id = color + count++; |
270 |
sb.append( " <Placemark id=\"" + id + "\">\n" ); |
sb.append( " <Placemark id=\"" + id + "\">\n" ); |
271 |
|
sb.append( " <name>").append(current.time).append("</name>\n" ); |
272 |
sb.append( " <styleUrl>#").append(color).append("</styleUrl>\n" ); |
sb.append( " <styleUrl>#").append(color).append("</styleUrl>\n" ); |
273 |
sb.append( " <description><![CDATA[IP=").append(current.ip).append("<br/>Time=").append(current.time).append("]]></description>\n" ); |
sb.append( " <description><![CDATA[IP=").append(current.ip).append("<br/> ]]></description>\n" ); |
274 |
sb.append( " <Point><coordinates>").append(current.lng).append(",").append(current.lat).append(",0</coordinates></Point>\n" ); |
sb.append( " <Point><coordinates>").append(current.lng).append(",").append(current.lat).append(",0</coordinates></Point>\n" ); |
275 |
sb.append( " </Placemark>\n" ); |
sb.append( " </Placemark>\n" ); |
276 |
} |
} |
326 |
*/ |
*/ |
327 |
|
|
328 |
|
|
|
formatPositions(sb, "blue", positions.blue); |
|
|
formatPositions(sb, "green", positions.green); |
|
|
formatPositions(sb, "yellow", positions.yellow); |
|
329 |
formatPositions(sb, "red", positions.red); |
formatPositions(sb, "red", positions.red); |
330 |
|
formatPositions(sb, "yellow", positions.yellow); |
331 |
|
formatPositions(sb, "green", positions.green); |
332 |
|
formatPositions(sb, "blue", positions.blue); |
333 |
|
|
334 |
|
|
335 |
sb.append( "</Document>\n" ); |
sb.append( "</Document>\n" ); |
405 |
byte bytes[] = baos.toByteArray(); |
byte bytes[] = baos.toByteArray(); |
406 |
|
|
407 |
resp.setContentType(KMZ); |
resp.setContentType(KMZ); |
408 |
resp.setContentLength( bytes.length ); |
resp.setHeader("Content-Disposition", "attachment; filename=Traininfo-requestplotter.kmz"); |
409 |
|
resp.setContentLength( bytes.length ); |
410 |
resp.getOutputStream().write(bytes); |
resp.getOutputStream().write(bytes); |
411 |
|
|
412 |
} else { |
} else { |
413 |
resp.setContentType(KML); |
byte bytes[] = kmlData.getBytes(); |
414 |
resp.getWriter().print( kmlData ); |
|
415 |
|
resp.setContentType(KML); |
416 |
|
resp.setContentLength( bytes.length ); |
417 |
|
resp.getOutputStream().write(bytes); |
418 |
} |
} |
419 |
} |
} |
420 |
} |
} |