You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2016/01/03 22:12:33 UTC
nifi git commit: NIFI-1212 Treating text/csv files as plain text so
they may also be displayed. This closes #154.
Repository: nifi
Updated Branches:
refs/heads/master 236a2b72b -> c696cb09b
NIFI-1212 Treating text/csv files as plain text so they may also be displayed. This closes #154.
Signed-off-by: joewitt <jo...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/c696cb09
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/c696cb09
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/c696cb09
Branch: refs/heads/master
Commit: c696cb09b610bc91e3f2e0fcec18e2bc96fe71d5
Parents: 236a2b7
Author: Aldrin Piri <al...@apache.org>
Authored: Fri Jan 1 14:10:39 2016 -0500
Committer: joewitt <jo...@apache.org>
Committed: Sun Jan 3 16:12:06 2016 -0500
----------------------------------------------------------------------
.../nifi/web/StandardContentViewerController.java | 13 +++++++------
.../src/main/webapp/META-INF/nifi-content-viewer | 3 ++-
2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/c696cb09/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java
index a85c450..cc87e6f 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java
@@ -49,20 +49,21 @@ public class StandardContentViewerController extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final ViewableContent content = (ViewableContent) request.getAttribute(ViewableContent.CONTENT_REQUEST_ATTRIBUTE);
- // handle json/xml
- if ("application/json".equals(content.getContentType()) || "application/xml".equals(content.getContentType()) || "text/plain".equals(content.getContentType())) {
+ // handle json/xml specifically, treat others as plain text
+ final String contentType = content.getContentType();
+ if ("application/json".equals(contentType) || "application/xml".equals(contentType) || "text/plain".equals(contentType) || "text/csv".equals(contentType)) {
final String formatted;
// leave the content alone if specified
if (DisplayMode.Original.equals(content.getDisplayMode())) {
formatted = content.getContent();
} else {
- if ("application/json".equals(content.getContentType())) {
+ if ("application/json".equals(contentType)) {
// format json
final ObjectMapper mapper = new ObjectMapper();
final Object objectJson = mapper.readValue(content.getContentStream(), Object.class);
formatted = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectJson);
- } else if ("application/xml".equals(content.getContentType())) {
+ } else if ("application/xml".equals(contentType)) {
// format xml
final StringWriter writer = new StringWriter();
@@ -89,12 +90,12 @@ public class StandardContentViewerController extends HttpServlet {
}
// defer to the jsp
- request.setAttribute("mode", content.getContentType());
+ request.setAttribute("mode", contentType);
request.setAttribute("content", formatted);
request.getRequestDispatcher("/WEB-INF/jsp/codemirror.jsp").include(request, response);
} else {
final PrintWriter out = response.getWriter();
- out.println("Unexpected content type: " + content.getContentType());
+ out.println("Unexpected content type: " + contentType);
}
}
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/c696cb09/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer
index c6a78f1..302c44a 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer
@@ -14,4 +14,5 @@
# limitations under the License.
application/xml
application/json
-text/plain
\ No newline at end of file
+text/plain
+text/csv
\ No newline at end of file