Better support of ditaa diagrams.

This commit is contained in:
Maxime Sinclair
2011-08-30 16:39:12 +02:00
parent c40a3e5504
commit b75cf0b7cf
2 changed files with 39 additions and 10 deletions

View File

@@ -47,21 +47,28 @@ public abstract class UmlDiagramService extends HttpServlet {
throws IOException, ServletException {
// build the UML source from the compressed request parameter
String text = URLDecoder.decode( getSource( request.getRequestURI()), "UTF-8");
String text = URLDecoder.decode( getSource(request.getRequestURI()), "UTF-8");
Transcoder transcoder = getTranscoder();
text = transcoder.decode(text);
StringBuilder plantUmlSource = new StringBuilder();
plantUmlSource.append("@startuml\n");
plantUmlSource.append( text);
if (text.endsWith("\n") == false) {
plantUmlSource.append("\n");
// encapsulate the UML syntax if necessary
String uml;
if (text.startsWith("@start")) {
uml = text;
} else {
StringBuilder plantUmlSource = new StringBuilder();
plantUmlSource.append( "@startuml\n");
plantUmlSource.append( text);
if (text.endsWith( "\n") == false) {
plantUmlSource.append( "\n");
}
plantUmlSource.append( "@enduml");
uml = plantUmlSource.toString();
}
plantUmlSource.append("@enduml");
final String uml = plantUmlSource.toString();
// generate the response
DiagramResponse dr = new DiagramResponse( response, getOutputFormat());
dr.sendDiagram( uml);
dr.sendDiagram(uml);
dr = null;
}