Search in sources :

Example 1 with UmlSource

use of net.sourceforge.plantuml.core.UmlSource in project plantuml-server by plantuml.

the class ProxyServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    final String fmt = request.getParameter("fmt");
    final String source = request.getParameter("src");
    final String index = request.getParameter("idx");
    final URL srcUrl;
    // Check if the src URL is valid
    try {
        srcUrl = new URL(source);
    } catch (MalformedURLException mue) {
        mue.printStackTrace();
        return;
    }
    // generate the response
    String diagmarkup = getSource(srcUrl);
    SourceStringReader reader = new SourceStringReader(diagmarkup);
    int n = index == null ? 0 : Integer.parseInt(index);
    List<BlockUml> blocks = reader.getBlocks();
    BlockUml block = blocks.get(n);
    Diagram diagram = block.getDiagram();
    UmlSource umlSrc = diagram.getSource();
    String uml = umlSrc.getPlainString();
    // System.out.println("uml=" + uml);
    // generate the response
    DiagramResponse dr = new DiagramResponse(response, getOutputFormat(fmt), request);
    try {
        dr.sendDiagram(uml, 0);
    } catch (IIOException iioe) {
    // Browser has closed the connection, so the HTTP OutputStream is closed
    // Silently catch the exception to avoid annoying log
    }
    dr = null;
}
Also used : UmlSource(net.sourceforge.plantuml.core.UmlSource) MalformedURLException(java.net.MalformedURLException) SourceStringReader(net.sourceforge.plantuml.SourceStringReader) BlockUml(net.sourceforge.plantuml.BlockUml) IIOException(javax.imageio.IIOException) URL(java.net.URL) Diagram(net.sourceforge.plantuml.core.Diagram)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 IIOException (javax.imageio.IIOException)1 BlockUml (net.sourceforge.plantuml.BlockUml)1 SourceStringReader (net.sourceforge.plantuml.SourceStringReader)1 Diagram (net.sourceforge.plantuml.core.Diagram)1 UmlSource (net.sourceforge.plantuml.core.UmlSource)1