From cfdac3be4da87218c751aeaedf8f9b0b6fe30e95 Mon Sep 17 00:00:00 2001 From: David Benson Date: Tue, 13 Sep 2016 17:29:20 +0100 Subject: [PATCH] Removed servlets --- .../mxgraph/online/ConnectImageServlet.java | 62 ------------------- .../mxgraph/online/ConnectRenderServlet.java | 53 ---------------- 2 files changed, 115 deletions(-) delete mode 100644 src/com/mxgraph/online/ConnectImageServlet.java delete mode 100644 src/com/mxgraph/online/ConnectRenderServlet.java diff --git a/src/com/mxgraph/online/ConnectImageServlet.java b/src/com/mxgraph/online/ConnectImageServlet.java deleted file mode 100644 index 646f31be..00000000 --- a/src/com/mxgraph/online/ConnectImageServlet.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mxgraph.online; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * Implements returning a 301 for the connect image placeholder to point - * at the relative PNG attachment of the diagram - * - * - */ -public class ConnectImageServlet extends HttpServlet -{ - /** - * - */ - private static final long serialVersionUID = 3143318789617797083L; - - public void doGet(HttpServletRequest request, HttpServletResponse response) - { - String redirect = "https://www.draw.io/images/logo-flat.png"; - String diagramName = request.getParameter("diagramName"); - String baseUrl = request.getParameter("baseUrl"); - String pageId = request.getParameter("pageId"); - String revision = request.getParameter("revision"); - - if (pageId != null && baseUrl != null && diagramName != null) - { - try - { - redirect = baseUrl + "/download/attachments/" + pageId + "/" - + URLEncoder.encode(diagramName, "UTF-8") - .replaceAll("\\+", "%20") - + ".png?api=v2" + (revision != null ? "&version=" + revision : ""); - } - catch (UnsupportedEncodingException e) - { - // Ignore - } - } - - response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); - response.setHeader("Location", redirect); - - try - { - response.getOutputStream().flush(); - response.getOutputStream().close(); - } - catch (Exception e) - { - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } - -} diff --git a/src/com/mxgraph/online/ConnectRenderServlet.java b/src/com/mxgraph/online/ConnectRenderServlet.java deleted file mode 100644 index 1733af09..00000000 --- a/src/com/mxgraph/online/ConnectRenderServlet.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mxgraph.online; - -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.logging.Logger; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * Returns XHTML in Confluence Storage Format indicating to display the PNG - * attachment of the diagram - * - */ -public class ConnectRenderServlet extends HttpServlet -{ - private static final long serialVersionUID = 161100757439732089L; - - public void doGet(HttpServletRequest request, HttpServletResponse response) - { - String pageId = request.getParameter("pageId"); - String diagramName = request.getParameter("diagramName"); - String filenameIntact = request.getParameter("filenameIntact"); - - try - { - diagramName = URLEncoder.encode(diagramName, "UTF-8"); - } - catch (UnsupportedEncodingException e1) - { - e1.printStackTrace(); - } - - String fileSuffix = filenameIntact != null ? "" : ".png"; - String staticMacro = ""; - - try - { - byte[] data = staticMacro.getBytes("UTF-8"); - OutputStream out = response.getOutputStream(); - out.write(data); - out.flush(); - out.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } -}