From 66365b0e1d1a290722bd1a4cfb5821b27fb68648 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 17 Jun 2015 22:43:33 -0400 Subject: [PATCH] NIFI-547: - Setting the default charset in the content viewer page. - Using the content stream when formatting json. --- .../java/org/apache/nifi/web/ContentViewerController.java | 3 +++ .../nifi-standard-content-viewer/pom.xml | 5 ++--- .../apache/nifi/web/StandardContentViewerController.java | 4 ++-- .../nifi-standard-bundle/nifi-standard-processors/pom.xml | 1 - nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml | 7 ++++++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java index 984b8a9e15..a6f6aec85c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java @@ -64,6 +64,9 @@ public class ContentViewerController extends HttpServlet { */ @Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { + // specify the charset in a response header + response.addHeader("Content-Type", "text/html; charset=UTF-8"); + // get the content final ServletContext servletContext = request.getServletContext(); final ContentAccess contentAccess = (ContentAccess) servletContext.getAttribute("nifi-content-access"); diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml index f5fdc3b095..ed97131d2e 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml @@ -44,9 +44,8 @@ provided - org.codehaus.jackson - jackson-mapper-asl - 1.9.13 + com.fasterxml.jackson.core + jackson-databind org.apache.nifi diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java index 98f7683e23..a85c450e57 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -33,7 +34,6 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.apache.nifi.web.ViewableContent.DisplayMode; -import org.codehaus.jackson.map.ObjectMapper; @WebServlet(name = "StandardContentViewer", urlPatterns = {"/view-content"}) public class StandardContentViewerController extends HttpServlet { @@ -60,7 +60,7 @@ public class StandardContentViewerController extends HttpServlet { if ("application/json".equals(content.getContentType())) { // format json final ObjectMapper mapper = new ObjectMapper(); - final Object objectJson = mapper.readValue(content.getContent(), Object.class); + final Object objectJson = mapper.readValue(content.getContentStream(), Object.class); formatted = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectJson); } else if ("application/xml".equals(content.getContentType())) { // format xml diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml index aa8bfbe323..d8cd3d2372 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml @@ -172,7 +172,6 @@ com.fasterxml.jackson.core jackson-databind - 2.4.5 org.apache.avro diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml index 55af03267d..e7eef6563b 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml @@ -29,7 +29,7 @@ nifi-standard-reporting-tasks nifi-standard-content-viewer nifi-standard-nar - + @@ -53,6 +53,11 @@ war 0.2.0-incubating-SNAPSHOT + + com.fasterxml.jackson.core + jackson-databind + 2.4.5 +