From ed53b46b7aac460d0b832c20332c8881419c4fab Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 4 Feb 2015 10:02:51 -0500 Subject: [PATCH] NIFI-317: - Code clean up. Earlier versions of this used a GET request which required the img be url encoded. Converted to using POST due to URL length limitations but left the encoding code in place. --- .../java/org/apache/nifi/web/servlet/DownloadSvg.java | 8 ++------ .../nifi-web-ui/src/main/webapp/js/nf/nf-common.js | 8 +++----- .../main/webapp/js/nf/provenance/nf-provenance-lineage.js | 4 ++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/servlet/DownloadSvg.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/servlet/DownloadSvg.java index ab76d4e842..d9129983ba 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/servlet/DownloadSvg.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/servlet/DownloadSvg.java @@ -18,7 +18,6 @@ package org.apache.nifi.web.servlet; import java.io.IOException; import java.io.PrintWriter; -import java.net.URLDecoder; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -44,10 +43,10 @@ public class DownloadSvg extends HttpServlet { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final String rawSvg = request.getParameter("svg"); + final String svg = request.getParameter("svg"); // ensure the image markup has been included - if (rawSvg == null) { + if (svg == null) { // set the response status response.setContentType("text/plain"); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); @@ -59,9 +58,6 @@ public class DownloadSvg extends HttpServlet { } try { - // get the svg and decode it, +'s need to be converted - final String svg = URLDecoder.decode(rawSvg.replace("+", "%2B"), "UTF-8"); - if (logger.isDebugEnabled()) { logger.debug(svg); } diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js index 171b96f3da..b49a97bd65 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js @@ -406,21 +406,19 @@ nf.Common = { }()), /** - * Creates a form inline in order to submit the specified params to the specified URL - * using the specified method. + * Creates a form inline in order to post the specified params to the specified URL. * - * @param {string} method The method to use * @param {string} url The URL * @param {object} params An object with the params to include in the submission */ - submit: function (method, url, params) { + post: function (url, params) { // temporarily override beforeunload var previousBeforeUnload = window.onbeforeunload; window.onbeforeunload = null; // create a form for submission var form = $('
').attr({ - 'method': method, + 'method': 'POST', 'action': url, 'style': 'display: none;' }); diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-lineage.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-lineage.js index 03b08f0078..583fe7e41d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-lineage.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-lineage.js @@ -1287,9 +1287,9 @@ nf.ProvenanceLineage = (function () { svg = '\n' + svg; // send to server to initiate download... client side only support is too browser specific at this point - nf.Common.submit('POST', './download-svg', { + nf.Common.post('./download-svg', { 'filename': 'provenance', - 'svg': encodeURIComponent(svg) + 'svg': svg }); });