mirror of https://github.com/apache/nifi.git
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.
This commit is contained in:
parent
3a0cb2d634
commit
ed53b46b7a
|
@ -18,7 +18,6 @@ package org.apache.nifi.web.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
@ -44,10 +43,10 @@ public class DownloadSvg extends HttpServlet {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
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
|
// ensure the image markup has been included
|
||||||
if (rawSvg == null) {
|
if (svg == null) {
|
||||||
// set the response status
|
// set the response status
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||||
|
@ -59,9 +58,6 @@ public class DownloadSvg extends HttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(svg);
|
logger.debug(svg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,21 +406,19 @@ nf.Common = {
|
||||||
}()),
|
}()),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form inline in order to submit the specified params to the specified URL
|
* Creates a form inline in order to post the specified params to the specified URL.
|
||||||
* using the specified method.
|
|
||||||
*
|
*
|
||||||
* @param {string} method The method to use
|
|
||||||
* @param {string} url The URL
|
* @param {string} url The URL
|
||||||
* @param {object} params An object with the params to include in the submission
|
* @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
|
// temporarily override beforeunload
|
||||||
var previousBeforeUnload = window.onbeforeunload;
|
var previousBeforeUnload = window.onbeforeunload;
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
|
|
||||||
// create a form for submission
|
// create a form for submission
|
||||||
var form = $('<form></form>').attr({
|
var form = $('<form></form>').attr({
|
||||||
'method': method,
|
'method': 'POST',
|
||||||
'action': url,
|
'action': url,
|
||||||
'style': 'display: none;'
|
'style': 'display: none;'
|
||||||
});
|
});
|
||||||
|
|
|
@ -1287,9 +1287,9 @@ nf.ProvenanceLineage = (function () {
|
||||||
svg = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' + svg;
|
svg = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' + svg;
|
||||||
|
|
||||||
// send to server to initiate download... client side only support is too browser specific at this point
|
// 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',
|
'filename': 'provenance',
|
||||||
'svg': encodeURIComponent(svg)
|
'svg': svg
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue