You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/03/16 04:51:59 UTC
incubator-nifi git commit: NIFI-353: - Addressing issues when running
clustered. - Javadocs.
Repository: incubator-nifi
Updated Branches:
refs/heads/NIFI-353 73a54eeb8 -> f92090233
NIFI-353:
- Addressing issues when running clustered.
- Javadocs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/f9209023
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/f9209023
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/f9209023
Branch: refs/heads/NIFI-353
Commit: f92090233fb3ad804cb1881d183592dfd30ffc99
Parents: 73a54ee
Author: Matt Gilman <ma...@gmail.com>
Authored: Sun Mar 15 23:51:31 2015 -0400
Committer: Matt Gilman <ma...@gmail.com>
Committed: Sun Mar 15 23:51:31 2015 -0400
----------------------------------------------------------------------
.../nifi/web/StandardNiFiContentAccess.java | 12 +++++++++---
.../nifi-web/nifi-web-content-access/pom.xml | 2 --
.../apache/nifi/web/ContentViewerController.java | 19 ++++++++++++++-----
3 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f9209023/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java
index b5735d2..b44a097 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java
@@ -74,7 +74,6 @@ public class StandardNiFiContentAccess implements ContentAccess {
// set the headers
final Map<String, String> headers = new HashMap<>();
- headers.put("Accept", "application/json,application/xml");
if (StringUtils.isNotBlank(request.getProxiedEntitiesChain())) {
headers.put("X-ProxiedEntitiesChain", request.getProxiedEntitiesChain());
}
@@ -106,10 +105,17 @@ public class StandardNiFiContentAccess implements ContentAccess {
final ClientResponse clientResponse = nodeResponse.getClientResponse();
final MultivaluedMap<String, String> responseHeaders = clientResponse.getHeaders();
+ // get the file name
+ final String contentDisposition = responseHeaders.getFirst("Content-Disposition");
+ final String filename = StringUtils.substringAfterLast(contentDisposition, "filename=");
+
+ // get the content type
+ final String contentType = responseHeaders.getFirst("Content-Type");
+
// create the downloadable content
- return new DownloadableContent(null, null, clientResponse.getEntityInputStream());
+ return new DownloadableContent(filename, contentType, clientResponse.getEntityInputStream());
} else {
-// http://localhost:8080/nifi-api/controller/provenance/events/1/content/input
+ // example URI: http://localhost:8080/nifi-api/controller/provenance/events/1/content/input
final String eventDetails = StringUtils.substringAfterLast(request.getDataUri(), "events/");
final String rawEventId = StringUtils.substringBefore(eventDetails, "/content/");
final String rawDirection = StringUtils.substringAfterLast(eventDetails, "/content/");
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f9209023/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-access/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-access/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-access/pom.xml
index 4289423..6f60dbe 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-access/pom.xml
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-access/pom.xml
@@ -22,6 +22,4 @@
</parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-web-content-access</artifactId>
- <dependencies>
- </dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f9209023/nifi/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/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 771465a..5db99cf 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
@@ -30,6 +30,7 @@ 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;
import org.apache.nifi.web.ViewableContent.DisplayMode;
import org.apache.tika.detect.DefaultDetector;
import org.apache.tika.io.TikaInputStream;
@@ -40,7 +41,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
/**
- *
+ * 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
+ * combo that allows the user to choose how they wait to view the data
+ * (original, formatted, hex). If a data viewer is registered for the detected
+ * content type, it will include the markup it generates in the response.
*/
@WebServlet(name = "ContentViewerController", urlPatterns = {"/viewer"})
public class ContentViewerController extends HttpServlet {
@@ -48,7 +53,8 @@ public class ContentViewerController extends HttpServlet {
private static final Logger logger = LoggerFactory.getLogger(ContentViewerController.class);
/**
- *
+ * Gets the content and defers to registered viewers to generate the markup.
+ *
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
@@ -112,11 +118,13 @@ public class ContentViewerController extends HttpServlet {
return;
}
+ // buffer the content to support reseting in case we need to detect the content type or char encoding
+ final BufferedInputStream bis = new BufferedInputStream(downloadableContent.getContent());
+
// detect the content type
final DefaultDetector detector = new DefaultDetector();
- // create the stream for tika to process, buffer to support reseting
- final BufferedInputStream bis = new BufferedInputStream(downloadableContent.getContent());
+ // create the stream for tika to process, buffered to support reseting
final TikaInputStream tikaStream = TikaInputStream.get(bis);
// provide a hint based on the filename
@@ -227,7 +235,8 @@ public class ContentViewerController extends HttpServlet {
@Override
public String getClusterNodeId() {
- return request.getParameter("clusterNodeId");
+ final String ref = request.getParameter("ref");
+ return StringUtils.substringAfterLast(ref, "clusterNodeId=");
}
@Override