mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-11-16 01:07:10 +00:00
[FEATURE] Design evolution of the map service
Map implementation is still an empty stub
This commit is contained in:
parent
e90fdee24b
commit
bedc5b49ce
@ -57,14 +57,8 @@ class DiagramResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendDiagram(String uml) throws IOException {
|
void sendDiagram(String uml) throws IOException {
|
||||||
long today = System.currentTimeMillis();
|
|
||||||
if (StringUtils.isDiagramCacheable(uml)) {
|
if (StringUtils.isDiagramCacheable(uml)) {
|
||||||
// Add http headers to force the browser to cache the image
|
addHeaderForCache();
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
response.setContentType(getContentType());
|
response.setContentType(getContentType());
|
||||||
SourceStringReader reader = new SourceStringReader(uml);
|
SourceStringReader reader = new SourceStringReader(uml);
|
||||||
@ -72,6 +66,27 @@ class DiagramResponse {
|
|||||||
response.flushBuffer();
|
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() {
|
private String getContentType() {
|
||||||
return contentType.get(format);
|
return contentType.get(format);
|
||||||
}
|
}
|
||||||
|
@ -23,27 +23,50 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.servlet;
|
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.FileFormat;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.servlet.utility.UmlExtractor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MAP servlet of the webapp.
|
* MAP servlet of the webapp.
|
||||||
* This servlet produces the image map of the diagram in HTML format.
|
* This servlet produces the image map of the diagram in HTML format.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class MapServlet extends UmlDiagramService {
|
public class MapServlet extends HttpServlet {
|
||||||
|
|
||||||
@Override
|
@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) {
|
public String getSource(String uri) {
|
||||||
String[] result = uri.split("/map/", 2);
|
String[] result = uri.split("/map/", 2);
|
||||||
if (result.length != 2) {
|
if (result.length != 2) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
//return result[1];
|
return result[1];
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileFormat getOutputFormat() {
|
public FileFormat getOutputFormat() {
|
||||||
return FileFormat.ATXT;
|
return FileFormat.ATXT;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ public abstract class UmlDiagramService extends HttpServlet {
|
|||||||
try {
|
try {
|
||||||
dr.sendDiagram(uml);
|
dr.sendDiagram(uml);
|
||||||
} catch (IIOException iioe) {
|
} 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;
|
dr = null;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
|
- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
|
||||||
<br>
|
<br>
|
||||||
Structure of the service part of the PlantUmlServer: <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>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user