mirror of https://github.com/apache/nifi.git
NIFI-547:
- Setting the default charset in the content viewer page. - Using the content stream when formatting json.
This commit is contained in:
parent
0af9c75d78
commit
66365b0e1d
|
@ -64,6 +64,9 @@ public class ContentViewerController extends HttpServlet {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
|
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
|
// get the content
|
||||||
final ServletContext servletContext = request.getServletContext();
|
final ServletContext servletContext = request.getServletContext();
|
||||||
final ContentAccess contentAccess = (ContentAccess) servletContext.getAttribute("nifi-content-access");
|
final ContentAccess contentAccess = (ContentAccess) servletContext.getAttribute("nifi-content-access");
|
||||||
|
|
|
@ -44,9 +44,8 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-mapper-asl</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>1.9.13</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.nifi</groupId>
|
<groupId>org.apache.nifi</groupId>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.web;
|
package org.apache.nifi.web;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -33,7 +34,6 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
import org.apache.nifi.web.ViewableContent.DisplayMode;
|
import org.apache.nifi.web.ViewableContent.DisplayMode;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
|
||||||
|
|
||||||
@WebServlet(name = "StandardContentViewer", urlPatterns = {"/view-content"})
|
@WebServlet(name = "StandardContentViewer", urlPatterns = {"/view-content"})
|
||||||
public class StandardContentViewerController extends HttpServlet {
|
public class StandardContentViewerController extends HttpServlet {
|
||||||
|
@ -60,7 +60,7 @@ public class StandardContentViewerController extends HttpServlet {
|
||||||
if ("application/json".equals(content.getContentType())) {
|
if ("application/json".equals(content.getContentType())) {
|
||||||
// format json
|
// format json
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
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);
|
formatted = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectJson);
|
||||||
} else if ("application/xml".equals(content.getContentType())) {
|
} else if ("application/xml".equals(content.getContentType())) {
|
||||||
// format xml
|
// format xml
|
||||||
|
|
|
@ -172,7 +172,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.4.5</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.avro</groupId>
|
<groupId>org.apache.avro</groupId>
|
||||||
|
|
|
@ -53,6 +53,11 @@
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
<version>0.2.0-incubating-SNAPSHOT</version>
|
<version>0.2.0-incubating-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.4.5</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue