Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
runcon
Plantuml Server
Commits
bedc5b49
Commit
bedc5b49
authored
Aug 14, 2013
by
Maxime Sinclair
Browse files
[FEATURE] Design evolution of the map service
Map implementation is still an empty stub
parent
e90fdee2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java
View file @
bedc5b49
...
...
@@ -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
);
}
...
...
src/main/java/net/sourceforge/plantuml/servlet/MapServlet.java
View file @
bedc5b49
...
...
@@ -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
UmlDiagram
Serv
ice
{
public
class
MapServlet
extends
Http
Serv
let
{
@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
;
}
...
...
src/main/java/net/sourceforge/plantuml/servlet/UmlDiagramService.java
View file @
bedc5b49
...
...
@@ -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
;
}
...
...
src/main/java/net/sourceforge/plantuml/servlet/package.html
View file @
bedc5b49
...
...
@@ -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/XP5
D
Re
Gm38NtdC9BAi4DkgbKJRkfMXNr004CH4f8nZ6eexPtR_WjC7JOaUVFVlQZaZa2QiiNqAXJ91TKIuahaw-aGgBoYaWTayWOCYMSWm-j7gKeIUW4gPKPmbS0O9jKoGnQ8tF8pHDo-CniEq8Xl-EvGST0vmXMihEcTWZax9sVCHkDmwPwWdME12Noy1NkmGcJhCiUCWrb64vAGtAFFqc59qDQSDVpsh1jU7ZxyJ-1h1cf4FwwpHRTiMiftByfMbeKtGfzECxtZFdzhQXL1DuHwivwtdGn5kw_u_Ww-Xli6vdFowW4r_ziOEhoW4ZQ8-B1PL8UC2_2_a-OU9Ddi4cy7p4sJQLTnjlShFUHpCJg1R5P9VOB
"
/>
<img
src=
"http://www.plantuml.com/plantuml/img/XP5
1
Re
Cm44Ntd6AMH0etwAPIbNPJjIhg0OoPm4WsTiPZrAZDtGk514ZIP3b_dlx_7jTK8g3riWUBja0EIJsNf7RbGjeIcavHHH1MMa0R5G9yMlD4gc9bS-IMDC9t0k1ZOKX3wwY4qZsZf2yYlYSCoWVk8WO1tgrX8GVlce30mQywZrFGQ9OBKrD1XPAxo1hJenAP5lo636uSMoKz_1R5HndcT9KSag7tMFeKshS-qzBhxTRpW6sV_FVCW4qv6apDh5diNvLVxWxJEMTPyF2JPPUNlS5snkDy0tfdzxK_OfV_DZ1DTOV8stl4Oz14_pCkEpzqCjM_ilq5
"
/>
</p>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment