You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2017/09/27 13:51:33 UTC
nifi git commit: NIFI-4413: - Using the incoming request to determine
the appropriate scheme for the data reference URI. Necessary for cases where
the NiFi instance is behind a proxy running a different scheme.
Repository: nifi
Updated Branches:
refs/heads/master b7b6d9082 -> d47bbd12c
NIFI-4413: - Using the incoming request to determine the appropriate scheme for the data reference URI. Necessary for cases where the NiFi instance is behind a proxy running a different scheme.
This closes #2179.
Signed-off-by: Bryan Bende <bb...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d47bbd12
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d47bbd12
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d47bbd12
Branch: refs/heads/master
Commit: d47bbd12ce41d2bfebf255e303cbeb95362e7888
Parents: b7b6d90
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Sep 26 14:14:41 2017 -0400
Committer: Bryan Bende <bb...@apache.org>
Committed: Wed Sep 27 09:51:06 2017 -0400
----------------------------------------------------------------------
.../nifi-web/nifi-web-content-viewer/pom.xml | 5 ++++
.../nifi/web/ContentViewerController.java | 29 ++++++++++++--------
2 files changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/d47bbd12/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
index 0a18270..77436e6 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
@@ -84,6 +84,11 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d47bbd12/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java
----------------------------------------------------------------------
diff --git a/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-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java
index b2114d5..ab8dcc1 100644
--- a/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-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java
@@ -18,15 +18,6 @@ package org.apache.nifi.web;
import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -40,6 +31,17 @@ import org.apache.tika.mime.MediaType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.UriBuilder;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
/**
* Controller servlet for viewing content. This is responsible for generating
* the markup for the header and footer of the page. Included in that is the
@@ -299,7 +301,12 @@ public class ContentViewerController extends HttpServlet {
final String ref = request.getParameter("ref");
final String clientId = request.getParameter("clientId");
- final URI refUri = URI.create(ref);
+ // base the data ref on the request parameter but ensure the scheme is based off the incoming request...
+ // this is necessary for scenario's where the NiFi instance is behind a proxy running a different scheme
+ final URI refUri = UriBuilder.fromUri(ref)
+ .scheme(request.getScheme())
+ .build();
+
final String query = refUri.getQuery();
String rawClusterNodeId = null;
@@ -317,7 +324,7 @@ public class ContentViewerController extends HttpServlet {
return new ContentRequestContext() {
@Override
public String getDataUri() {
- return ref;
+ return refUri.toString();
}
@Override