diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..39e9ddb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic", + "cSpell.words": [ + "Arnaud", + "ditaa", + "endditaa", + "enduml", + "epstext", + "etag", + "Lalloni", + "plantuml", + "Roques", + "servlet", + "servlets", + "startditaa", + "startuml" + ], + "cSpell.allowCompoundWords": true +} \ No newline at end of file diff --git a/COPYING b/COPYING index 94a9ed0..f288702 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/README.md b/README.md index 2104673..7b3c236 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,59 @@ -PlantUML Server -=============== -[![Build Status](https://travis-ci.org/plantuml/plantuml-server.png?branch=master)](https://travis-ci.org/plantuml/plantuml-server) -[![](https://images.microbadger.com/badges/image/plantuml/plantuml-server.svg)](https://microbadger.com/images/plantuml/plantuml-server "Get your own image badge on microbadger.com") -[![Docker Pull](https://img.shields.io/docker/pulls/plantuml/plantuml-server.svg)](https://hub.docker.com/r/plantuml/plantuml-server/) +# PlantUML Server + +![workflow status](https://github.com/plantuml/plantuml-server/actions/workflows/main.yml/badge.svg) +[![docker pulls](https://img.shields.io/docker/pulls/plantuml/plantuml-server.svg)](https://hub.docker.com/r/plantuml/plantuml-server) + PlantUML Server is a web application to generate UML diagrams on-the-fly. -![](https://raw.githubusercontent.com/ftomassetti/plantuml-server/readme/screenshots/screenshot.png) +![PlantUML Server](https://raw.githubusercontent.com/plantuml/plantuml-server/master/screenshots/screenshot.png) -To know more about PlantUML, please visit http://plantuml.com/. +To know more about PlantUML, please visit https://plantuml.com. -Requirements -============ +## Requirements - * jre/jdk 1.6.0 or above - * apache maven 3.0.2 or above +- jre/jdk 1.6.0 or above +- apache maven 3.0.2 or above -How to run the server -===================== + +## How to run the server Just run: -``` +```sh mvn jetty:run ``` -The server is now listing to [http://localhost:8080/plantuml](http://localhost:8080/plantuml). +The server is now listening to [http://localhost:8080/plantuml](http://localhost:8080/plantuml). In this way the server is run on an embedded jetty server. You can specify the port at which it runs: -``` +```sh mvn jetty:run -Djetty.port=9999 ``` -How to run the server with Docker -================================= + +## How to run the server with Docker You can run Plantuml with jetty or tomcat container -``` +```sh docker run -d -p 8080:8080 plantuml/plantuml-server:jetty docker run -d -p 8080:8080 plantuml/plantuml-server:tomcat ``` -The server is now listing to [http://localhost:8080](http://localhost:8080). +The server is now listening to [http://localhost:8080](http://localhost:8080). -## Read-only container +### Read-only container The jetty container supports read-only files system, you can run the read-only mode with: -``` -docker run -d -p 8080:8080 --read-only -v /tmp/jetty plantuml/plantuml-server:jetty-readonly +```sh +docker run -d -p 8080:8080 --read-only -v /tmp/jetty plantuml/plantuml-server:jetty ``` This makes the container compatible with more restricted environment such as OpenShift, just make sure you mount a volume (can be ephemeral) on `/tmp/jetty`. -## Change base URL +### Change base URL To run plantuml using different base url, change the `docker-compose.yml` file: ```yaml @@ -62,69 +61,67 @@ environment: - BASE_URL=plantuml ``` -And run `docker-compose up`. This will start a modified version of the image using -the base url `/plantuml`, e.g. http://localhost/plantuml +And run `docker-compose up`. This will start a modified version of the image using the base url `/plantuml`, e.g. http://localhost:8080/plantuml -How to set PlantUML options -================================= -You can apply some option to your PlantUML server with environement variable. +## How to set PlantUML options + +You can apply some option to your PlantUML server with environment variable. If you run the directly the jar, you can pass the option with `-D` flag -``` +```sh java -D THE_ENV_VARIABLE=THE_ENV_VALUE -Djetty.contextpath=/ -jar target/dependency/jetty-runner.jar target/plantuml.war ``` or -``` +```sh mvn jetty:run -D THE_ENV_VARIABLE=THE_ENV_VALUE -Djetty.port=9999 ``` If you use docker, you can use the `-e` flag: -``` +```sh docker run -d -p 8080:8080 -e THE_ENV_VARIABLE=THE_ENV_VALUE plantuml/plantuml-server:jetty ``` You can set all the following variables: -- `BASE_URL` - * PlantUML base url - * Default value: `ROOT` -- `PLANTUML_LIMIT_SIZE` - * Limits image width and height - * Default value: `4096` -- `PLANTUML_STATS` - * Set it to `on` to enable [statistics report](http://plantuml.com/statistics-report) - * Default value: `off` -- `HTTP_AUTHORIZATION` - * when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header - * Default value: `null` -- `ALLOW_PLANTUML_INCLUDE` - * Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory. - * Default value: `false` +* `PLANTUML_LIMIT_SIZE` + * Limits image width and height + * Default value: `4096` +* `GRAPHVIZ_DOT` + * Link to 'dot' executable + * Default value: `/usr/local/bin/dot` or `/usr/bin/dot` +* `PLANTUML_STATS` + * Set it to `on` to enable [statistics report](https://plantuml.com/statistics-report) + * Default value: `off` +* `HTTP_AUTHORIZATION` + * when calling the `proxy` endpoint, the value of `HTTP_AUTHORIZATION` will be used to set the HTTP Authorization header + * Default value: `null` +* `ALLOW_PLANTUML_INCLUDE` + * Enables `!include` processing which can read files from the server into diagrams. Files are read relative to the current working directory. + * Default value: `false` -Alternate: How to build your docker image -====================================================== + +## Alternate: How to build your docker image This method uses maven to run the application. That requires internet connectivity. So, you can use following command to create a self-contained docker image that will "just-work". *Note: Generate the WAR (instructions further below) prior to running "docker build"* +```sh +docker image build -t plantuml-server:local . +docker run -d -p 8080:8080 plantuml-server:local ``` -docker image build -t plantuml-server . -docker run -d -p 8080:8080 plantuml-server -``` -The server is now listing to [http://localhost:8080/plantuml](http://localhost:8080/plantuml). +The server is now listening to [http://localhost:8080/plantuml](http://localhost:8080/plantuml). You may specify the port in `-p` Docker command line argument. -How to generate the war -======================= +## How to generate the war To build the war, just run: -``` +```sh mvn package ``` diff --git a/pom.xml b/pom.xml index 2b56041..324e053 100644 --- a/pom.xml +++ b/pom.xml @@ -1,3 +1,4 @@ + 4.0.0 @@ -8,6 +9,28 @@ war plantuml + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.2 + + + com.puppycrawl.tools + checkstyle + 9.0.1 + + + + ${basedir}/src/main/config/checkstyle.xml + false + true + true + + + + maven-eclipse-plugin @@ -95,24 +118,17 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.11 + 3.1.2 - validate + validate - - ${basedir}/src/main/config/checkstyle.xml - UTF-8 - true - true - false - check - + @@ -129,11 +145,11 @@ - + org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.3.1 private true @@ -150,24 +166,21 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.11 - - ${basedir}/src/main/config/checkstyle.xml - UTF-8 - false - + 3.1.2 checkstyle + checkstyle-aggregate - + UTF-8 + UTF-8 8.0.4.v20111024 8080 /plantuml diff --git a/src/main/config/checkstyle.xml b/src/main/config/checkstyle.xml index 99f9b61..313d601 100644 --- a/src/main/config/checkstyle.xml +++ b/src/main/config/checkstyle.xml @@ -1,126 +1,117 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - + + + + + + + - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java index f278b43..14326fa 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/** * ASCII servlet of the webapp. * This servlet produces the UML sequence diagram in text format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class AsciiServlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for ASCII responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.UTXT; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/Base64Servlet.java b/src/main/java/net/sourceforge/plantuml/servlet/Base64Servlet.java index fcb191f..6e6c5ed 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/Base64Servlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/Base64Servlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/** * Base64 servlet of the webapp. * This servlet produces the UML diagram in Base64 format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class Base64Servlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for Base64 responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.BASE64; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/CheckSyntaxServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/CheckSyntaxServlet.java index bec6280..7f17c98 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/CheckSyntaxServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/CheckSyntaxServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -32,14 +32,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.plantuml.FileFormat; - import net.sourceforge.plantuml.servlet.utility.UmlExtractor; -/* +/** * Check servlet of the webapp. * This servlet checks the syntax of the diagram and send a report in TEXT format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class CheckSyntaxServlet extends HttpServlet { @Override @@ -52,12 +51,19 @@ public class CheckSyntaxServlet extends HttpServlet { DiagramResponse dr = new DiagramResponse(response, getOutputFormat(), request); try { dr.sendCheck(uml); - } catch (IIOException iioe) { + } catch (IIOException e) { // Browser has closed the connection, do nothing } dr = null; } + /** + * Extract UML source from URI. + * + * @param uri the complete URI as returned by `request.getRequestURI()` + * + * @return the encoded UML text + */ public String getSource(String uri) { String[] result = uri.split("/check/", 2); if (result.length != 2) { @@ -67,6 +73,12 @@ public class CheckSyntaxServlet extends HttpServlet { } } + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for check responses + */ public FileFormat getOutputFormat() { return FileFormat.UTXT; } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java index 22e8079..b914d46 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -53,7 +53,7 @@ import net.sourceforge.plantuml.ErrorUml; * Delegates the diagram generation from the UML source and the filling of the HTTP response with the diagram in the * right format. Its own responsibility is to produce the right HTTP headers. */ -class DiagramResponse { +public class DiagramResponse { private static final String POWERED_BY = "PlantUML Version " + Version.versionString(); @@ -77,22 +77,24 @@ class DiagramResponse { } } - DiagramResponse(HttpServletResponse r, FileFormat f, HttpServletRequest rq) { + public DiagramResponse(HttpServletResponse r, FileFormat f, HttpServletRequest rq) { response = r; format = f; request = rq; } - void sendDiagram(String uml, int idx) throws IOException { + public void sendDiagram(String uml, int idx) throws IOException { response.addHeader("Access-Control-Allow-Origin", "*"); response.setContentType(getContentType()); SourceStringReader reader = new SourceStringReader(uml); if (format == FileFormat.BASE64) { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final DiagramDescription result = reader.outputImage(baos, idx, new FileFormatOption(FileFormat.PNG)); - baos.close(); - final String encodedBytes = "data:image/png;base64," - + Base64Coder.encodeLines(baos.toByteArray()).replaceAll("\\s", ""); + byte[] imageBytes; + try (ByteArrayOutputStream outstream = new ByteArrayOutputStream()) { + reader.outputImage(outstream, idx, new FileFormatOption(FileFormat.PNG)); + imageBytes = outstream.toByteArray(); + } + final String base64 = Base64Coder.encodeLines(imageBytes).replaceAll("\\s", ""); + final String encodedBytes = "data:image/png;base64," + base64; response.getOutputStream().write(encodedBytes.getBytes()); return; } @@ -109,7 +111,7 @@ class DiagramResponse { if (diagram instanceof PSystemError) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } - final ImageData result = diagram.exportDiagram(response.getOutputStream(), idx, new FileFormatOption(format)); + diagram.exportDiagram(response.getOutputStream(), idx, new FileFormatOption(format)); } private boolean notModified(BlockUml blockUml) { @@ -126,7 +128,7 @@ class DiagramResponse { } - void sendMap(String uml) throws IOException { + public void sendMap(String uml) throws IOException { response.setContentType(getContentType()); SourceStringReader reader = new SourceStringReader(uml); final BlockUml blockUml = reader.getBlocks().get(0); @@ -141,16 +143,17 @@ class DiagramResponse { final String cmap = map.getCMapData("plantuml"); httpOut.print(cmap); } - } + } - void sendCheck(String uml) throws IOException { + public void sendCheck(String uml) throws IOException { response.setContentType(getContentType()); SourceStringReader reader = new SourceStringReader(uml); DiagramDescription desc = reader.outputImage( new NullOutputStream(), new FileFormatOption(FileFormat.PNG, false)); PrintWriter httpOut = response.getWriter(); httpOut.print(desc.getDescription()); - } + } + private void addHeaderForCache(BlockUml blockUml) { long today = System.currentTimeMillis(); // Add http headers to force the browser to cache the image @@ -176,11 +179,10 @@ class DiagramResponse { public static void addHeaders(HttpServletResponse response) { response.addHeader("X-Powered-By", POWERED_BY); - response.addHeader("X-Patreon", "Support us on http://plantuml.com/patreon"); - response.addHeader("X-Donate", "http://plantuml.com/paypal"); + response.addHeader("X-Patreon", "Support us on https://plantuml.com/patreon"); + response.addHeader("X-Donate", "https://plantuml.com/paypal"); } - private String getContentType() { return CONTENT_TYPE.get(format); } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java index a69b00a..aa17606 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/EpsServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/** * EPS servlet of the webapp. * This servlet produces the UML diagram in EPS format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class EpsServlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for EPS responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.EPS; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java index 5226eeb..5efbeac 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/EpsTextServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* - * EPS servlet of the webapp. - * This servlet produces the UML diagram in EPS format. +/** + * EPS Text servlet of the webapp. + * This servlet produces the UML diagram in EPS Text format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class EpsTextServlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for EPS Text responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.EPS_TEXT; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/ImgServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/ImgServlet.java index 8fae637..c90d34d 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/ImgServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/ImgServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/** * Image servlet of the webapp. * This servlet produces the UML diagram in PNG format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class ImgServlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for image responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.PNG; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/LanguageServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/LanguageServlet.java index fcbcc1e..1080f87 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/LanguageServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/LanguageServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * diff --git a/src/main/java/net/sourceforge/plantuml/servlet/MapServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/MapServlet.java index d1b1081..252b200 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/MapServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/MapServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -35,11 +35,11 @@ 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") +@SuppressWarnings("SERIAL") public class MapServlet extends HttpServlet { @Override @@ -52,7 +52,7 @@ public class MapServlet extends HttpServlet { DiagramResponse dr = new DiagramResponse(response, getOutputFormat(), request); try { dr.sendMap(uml); - } catch (IIOException iioe) { + } catch (IIOException e) { // Browser has closed the connection, do nothing } dr = null; @@ -67,6 +67,12 @@ public class MapServlet extends HttpServlet { } } + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for map responses + */ public FileFormat getOutputFormat() { return FileFormat.UTXT; } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java index 50b0684..34e181d 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/OldProxyServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -40,12 +40,12 @@ import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; -/* +/** * Proxy servlet of the webapp. * This servlet retrieves the diagram source of a web resource (web html page) * and renders it. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class OldProxyServlet extends HttpServlet { private static final Pattern PROXY_PATTERN = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(https?://.*)"); diff --git a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java index 625cc9e..e40679e 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -43,9 +43,8 @@ import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.TranscoderUtil; import net.sourceforge.plantuml.png.MetadataTag; -/* +/** * Original idea from Achim Abeling for Confluence macro - * See http://www.banapple.de/display/BANAPPLE/plantuml+user+macro * * This class is the old all-in-one historic implementation of the PlantUml server. * See package.html for the new design. It's a work in progress. @@ -53,17 +52,16 @@ import net.sourceforge.plantuml.png.MetadataTag; * Modified by Arnaud Roques * Modified by Pablo Lalloni * Modified by Maxime Sinclair - * */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class PlantUmlServlet extends HttpServlet { private static final String DEFAULT_ENCODED_TEXT = "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000"; // Last part of the URL public static final Pattern URL_PATTERN = Pattern.compile("^.*[^a-zA-Z0-9\\-\\_]([a-zA-Z0-9\\-\\_]+)"); - private static final Pattern RECOVER_UML_PATTERN = Pattern.compile("/uml/(.*)"); + static { OptionFlags.ALLOW_INCLUDE = false; if ("true".equalsIgnoreCase(System.getenv("ALLOW_PLANTUML_INCLUDE"))) { @@ -112,10 +110,10 @@ public class PlantUmlServlet extends HttpServlet { if (text != null && PlantumlUtils.hasCMapData(text)) { request.setAttribute("mapneeded", Boolean.TRUE); } + // forward to index.jsp final RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp"); dispatcher.forward(request, response); - } @Override @@ -189,6 +187,4 @@ public class PlantUmlServlet extends HttpServlet { return is; } - - } diff --git a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java index d1d0053..2d53589 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/ProxyServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -49,12 +49,12 @@ import javax.imageio.IIOException; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLPeerUnverifiedException; -/* +/** * Proxy servlet of the webapp. * This servlet retrieves the diagram source of a web resource (web html page) * and renders it. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class ProxyServlet extends HttpServlet { static { @@ -95,7 +95,7 @@ public class ProxyServlet extends HttpServlet { DiagramResponse dr = new DiagramResponse(response, getOutputFormat(fmt), request); try { dr.sendDiagram(uml, 0); - } catch (IIOException iioe) { + } catch (IIOException e) { // Browser has closed the connection, so the HTTP OutputStream is closed // Silently catch the exception to avoid annoying log } @@ -145,9 +145,9 @@ public class ProxyServlet extends HttpServlet { private HttpURLConnection getConnection(final URL url) throws IOException { final HttpURLConnection con = (HttpURLConnection) url.openConnection(); - if (con instanceof HttpsURLConnection) { - // printHttpsCert((HttpsURLConnection) con); - } + //if (con instanceof HttpsURLConnection) { + // printHttpsCert((HttpsURLConnection) con); + //} con.setRequestMethod("GET"); String token = System.getenv("HTTP_AUTHORIZATION"); if (token != null) { diff --git a/src/main/java/net/sourceforge/plantuml/servlet/SvgServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/SvgServlet.java index e70709c..6e0109d 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/SvgServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/SvgServlet.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -25,13 +25,19 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/** * SVG servlet of the webapp. * This servlet produces the UML diagram in SVG format. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class SvgServlet extends UmlDiagramService { + /** + * Gives the wished output format of the diagram. + * This value is used by the DiagramResponse class. + * + * @return the format for svg responses + */ @Override public FileFormat getOutputFormat() { return FileFormat.SVG; diff --git a/src/main/java/net/sourceforge/plantuml/servlet/UmlDiagramService.java b/src/main/java/net/sourceforge/plantuml/servlet/UmlDiagramService.java index ffde3f2..650745b 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/UmlDiagramService.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/UmlDiagramService.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -40,7 +40,7 @@ import java.util.regex.Pattern; /** * Common service servlet to produce diagram from compressed UML source contained in the end part of the requested URI. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public abstract class UmlDiagramService extends HttpServlet { static { @@ -99,7 +99,7 @@ public abstract class UmlDiagramService extends HttpServlet { DiagramResponse dr = new DiagramResponse(response, getOutputFormat(), request); try { dr.sendDiagram(uml, idx); - } catch (IIOException iioe) { + } catch (IIOException e) { // Browser has closed the connection, so the HTTP OutputStream is closed // Silently catch the exception to avoid annoying log } @@ -109,11 +109,11 @@ public abstract class UmlDiagramService extends HttpServlet { private static final Pattern RECOVER_UML_PATTERN = Pattern.compile("/\\w+/(\\d+/)?(.*)"); /** - * Extracts the compressed UML source from the HTTP URI. + * Extracts the UML source text and its index from the HTTP request. * - * @param uri - * the complete URI as returned by request.getRequestURI() - * @return the compressed UML source + * @param request http request + * + * @return the UML source text and its index */ public final String[] getSourceAndIdx(HttpServletRequest request) { final Matcher recoverUml = RECOVER_UML_PATTERN.matcher( diff --git a/src/main/java/net/sourceforge/plantuml/servlet/Welcome.java b/src/main/java/net/sourceforge/plantuml/servlet/Welcome.java index f06841c..ef9da69 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/Welcome.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/Welcome.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -31,11 +31,11 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -/* +/** * Welcome servlet of the webapp. * Displays the sample Bob and Alice sequence diagram. */ -@SuppressWarnings("serial") +@SuppressWarnings("SERIAL") public class Welcome extends HttpServlet { @Override diff --git a/src/main/java/net/sourceforge/plantuml/servlet/package.html b/src/main/java/net/sourceforge/plantuml/servlet/package.html index 18dbf9f..fe73e9f 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/package.html +++ b/src/main/java/net/sourceforge/plantuml/servlet/package.html @@ -1,15 +1,21 @@ -

This package is in charge of the JEE PlantUml Server.

-

there are 2 kind of servlets in this package :
-- Interactive servlets : Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.
-- Service servlets : ImgServlet, SvgServlet, EpsServlet, EpsTextServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.
-
-Structure of the service part of the PlantUmlServer:
- -

-

- -

+

This package is in charge of the JEE PlantUml Server.

+

There are 2 kind of servlets in this package:
+ - Interactive servlets: Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.
+ - Service servlets: ImgServlet, SvgServlet, EpsServlet, EpsTextServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.
+
+ Structure of the service part of the PlantUmlServer:
+ Class diagram of the service part of the PlantUmlServer +

+

+ Generation of a PNG image illustrated +

- \ No newline at end of file + diff --git a/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java b/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java index ed37ad7..e35b67c 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * diff --git a/src/main/java/net/sourceforge/plantuml/servlet/utility/NullOutputStream.java b/src/main/java/net/sourceforge/plantuml/servlet/utility/NullOutputStream.java index 087599b..a217010 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/utility/NullOutputStream.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/utility/NullOutputStream.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * diff --git a/src/main/java/net/sourceforge/plantuml/servlet/utility/UmlExtractor.java b/src/main/java/net/sourceforge/plantuml/servlet/utility/UmlExtractor.java index 1aeca9b..08faaa2 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/utility/UmlExtractor.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/utility/UmlExtractor.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * Project Info: http://plantuml.sourceforge.net + * Project Info: https://plantuml.com * * This file is part of PlantUML. * @@ -45,14 +45,13 @@ public class UmlExtractor { } /** - * Build the complete UML source from the compressed source extracted from the HTTP URI. + * Build the complete UML source from the compressed source extracted from the + * HTTP URI. * - * @param source - * the last part of the URI containing the compressed UML + * @param source the last part of the URI containing the compressed UML * @return the textual UML source */ static public String getUmlSource(String source) { - // build the UML source from the compressed part of the URL String text; try { @@ -89,4 +88,4 @@ public class UmlExtractor { throw new UnsupportedOperationException(); } -} \ No newline at end of file +} diff --git a/src/main/java/net/sourceforge/plantuml/servlet/utility/package.html b/src/main/java/net/sourceforge/plantuml/servlet/utility/package.html index 570e7b4..f6ce3ff 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/utility/package.html +++ b/src/main/java/net/sourceforge/plantuml/servlet/utility/package.html @@ -1,9 +1,9 @@ -

This package contains utility classes of the JEE PlantUml Server.

-
    -
  • NullOutputStream is used by the Map feature.
  • -
  • UmlExtractor encapsulates the PlantUML library to decode the UML compressed source.
  • -
+

This package contains utility classes of the JEE PlantUml Server.

+
    +
  • NullOutputStream is used by the Map feature.
  • +
  • UmlExtractor encapsulates the PlantUML library to decode the UML compressed source.
  • +
- \ No newline at end of file + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 717df36..896a4d2 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -51,7 +51,7 @@ <%@ include file="resource/githubribbon.html" %> -

Create your PlantUML diagrams directly in your browser !

+

Create your PlantUML diagrams directly in your browser !

<%-- CONTENT --%> diff --git a/src/main/webapp/resource/test2diagrams.txt b/src/main/webapp/resource/test2diagrams.txt index 77b54f2..ddba7d5 100644 --- a/src/main/webapp/resource/test2diagrams.txt +++ b/src/main/webapp/resource/test2diagrams.txt @@ -6,4 +6,4 @@ Bob -> Alice : hello @startuml version -@enduml \ No newline at end of file +@enduml