Commit bedc5b49 authored by Maxime Sinclair's avatar Maxime Sinclair
Browse files

[FEATURE] Design evolution of the map service

Map implementation is still an empty stub
parent e90fdee2
......@@ -57,21 +57,36 @@ class DiagramResponse {
}
void sendDiagram(String uml) throws IOException {
long today = System.currentTimeMillis();
if (StringUtils.isDiagramCacheable(uml)) {
// Add http headers to force the browser to cache the image
response.addDateHeader("Expires", today + 31536000000L);
// today + 1 year
response.addDateHeader("Last-Modified", 1261440000000L);
// 2009 dec 22 constant date in the past
response.addHeader("Cache-Control", "public");
addHeaderForCache();
}
response.setContentType(getContentType());
SourceStringReader reader = new SourceStringReader(uml);
reader.generateImage(response.getOutputStream(), new FileFormatOption(format));
response.flushBuffer();
}
void sendMap(String uml) throws IOException {
/* SourceStringReader reader = new SourceStringReader(uml);
String map = reader.generateImage(response.getOutputStream(), new FileFormatOption(FileFormat.PNG));
response.flushBuffer();
System.out.println( "map !!!" + map + "!!!");
String[] mapLines = map.split("[\\r\\n]");
for (int i=2; (i+1)<mapLines.length; i++)
System.out.println("map"+i+" !!!"+mapLines[i]+"!!!");
*/
}
private void addHeaderForCache() {
long today = System.currentTimeMillis();
// Add http headers to force the browser to cache the image
response.addDateHeader("Expires", today + 31536000000L);
// today + 1 year
response.addDateHeader("Last-Modified", 1261440000000L);
// 2009 dec 22 constant date in the past
response.addHeader("Cache-Control", "public");
}
private String getContentType() {
return contentType.get(format);
}
......
......@@ -23,27 +23,50 @@
*/
package net.sourceforge.plantuml.servlet;
import java.io.IOException;
import javax.imageio.IIOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
/*
* MAP servlet of the webapp.
* This servlet produces the image map of the diagram in HTML format.
*/
@SuppressWarnings("serial")
public class MapServlet extends UmlDiagramService {
public class MapServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// build the UML source from the compressed request parameter
String uml = UmlExtractor.getUmlSource(getSource(request.getRequestURI()));
// generate the response
DiagramResponse dr = new DiagramResponse(response, getOutputFormat());
try {
dr.sendMap(uml);
} catch (IIOException iioe) {
// Browser has closed the connection, do nothing
}
dr = null;
}
public String getSource(String uri) {
String[] result = uri.split("/map/", 2);
if (result.length != 2) {
return "";
} else {
//return result[1];
return "";
return result[1];
}
}
@Override
public FileFormat getOutputFormat() {
return FileFormat.ATXT;
}
......
......@@ -50,7 +50,8 @@ public abstract class UmlDiagramService extends HttpServlet {
try {
dr.sendDiagram(uml);
} catch (IIOException iioe) {
// Browser has closed the connection, do nothing
// Browser has closed the connection, so the HTTP OutputStream is closed
// Silently catch the exception to avoid annoying log
}
dr = null;
}
......
......@@ -6,7 +6,7 @@
- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
<br>
Structure of the service part of the PlantUmlServer: <br>
<img src="http://www.plantuml.com/plantuml/img/XP5DReGm38NtdC9BAi4DkgbKJRkfMXNr004CH4f8nZ6eexPtR_WjC7JOaUVFVlQZaZa2QiiNqAXJ91TKIuahaw-aGgBoYaWTayWOCYMSWm-j7gKeIUW4gPKPmbS0O9jKoGnQ8tF8pHDo-CniEq8Xl-EvGST0vmXMihEcTWZax9sVCHkDmwPwWdME12Noy1NkmGcJhCiUCWrb64vAGtAFFqc59qDQSDVpsh1jU7ZxyJ-1h1cf4FwwpHRTiMiftByfMbeKtGfzECxtZFdzhQXL1DuHwivwtdGn5kw_u_Ww-Xli6vdFowW4r_ziOEhoW4ZQ8-B1PL8UC2_2_a-OU9Ddi4cy7p4sJQLTnjlShFUHpCJg1R5P9VOB" />
<img src="http://www.plantuml.com/plantuml/img/XP51ReCm44Ntd6AMH0etwAPIbNPJjIhg0OoPm4WsTiPZrAZDtGk514ZIP3b_dlx_7jTK8g3riWUBja0EIJsNf7RbGjeIcavHHH1MMa0R5G9yMlD4gc9bS-IMDC9t0k1ZOKX3wwY4qZsZf2yYlYSCoWVk8WO1tgrX8GVlce30mQywZrFGQ9OBKrD1XPAxo1hJenAP5lo636uSMoKz_1R5HndcT9KSag7tMFeKshS-qzBhxTRpW6sV_FVCW4qv6apDh5diNvLVxWxJEMTPyF2JPPUNlS5snkDy0tfdzxK_OfV_DZ1DTOV8stl4Oz14_pCkEpzqCjM_ilq5" />
</p>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment