-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-13632: Updating content access. (#9221)
* NIFI-13632: Updating content access. - Removing existing content viewer application. - Introduced new front end based content viewer applicaiton. - Introduced new bundled content viewers for hex and images. - Deleted previous image content viewer. - Migrated existing standard content viewer (which handles json, xml, yaml, csv, and text) to utilize new content access interface. - Moved standard content viewer into its own NAR. - Moved and renamed custom ui utils and content viewer utils into nifi-common. - Added mime type to FlowFileSummary response payload to help drive the initially opened content viewer. * NIFI-13632: Fixing rat issue. * NIFI-13632: Fixing CI issue. * NIFI-13632: Removing standard content viewer war from code coverage. * NIFI-13632: Addressing review feedback. * NIFI-13632: Fixing import. * NIFI-13632: Further simplification of content viewer state. * NIFI-13632: Removing unneeded code. * NIFI-13632: Adding a min height around codemirror. * NIFI-13632: Addressing review feedback. - Rendering mime type in the content viewer. - Preventing additions to the browser history as the user changes how the content is viewed. - Appending forward slash to content viewer UIs to prevent unnecessary redirect. - Removing Standard Content Viewer title based on review feedback. - Fixing double scroll bar in the Standard Content Viewer on small browser heights. - Removed unnecessary application.yml. - Bumping spring boot version. This closes #9221
- Loading branch information
Showing
197 changed files
with
4,836 additions
and
6,442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...tent-viewer-utils/src/main/java/org/apache/nifi/web/HttpServletContentRequestContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.nifi.web; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* An implementation of the ConfigurationRequestContext that retrieves configuration | ||
* from a HttpServletRequest instance. | ||
*/ | ||
public class HttpServletContentRequestContext implements ContentRequestContext { | ||
|
||
private final String dataRef; | ||
private final String clusterNodeId; | ||
private final String clientId; | ||
|
||
private static final String PROXY_CONTEXT_PATH_HTTP_HEADER = "X-ProxyContextPath"; | ||
private static final String FORWARDED_CONTEXT_HTTP_HEADER = "X-Forwarded-Context"; | ||
private static final String FORWARDED_PREFIX_HTTP_HEADER = "X-Forwarded-Prefix"; | ||
|
||
public HttpServletContentRequestContext(HttpServletRequest request) { | ||
final String ref = request.getParameter("ref"); | ||
final UriBuilder refUriBuilder = UriBuilder.fromUri(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 | ||
refUriBuilder.scheme(request.getScheme()); | ||
|
||
// If there is path context from a proxy, remove it since this request will be used inside the cluster | ||
final String proxyContextPath = getFirstHeaderValue(request, PROXY_CONTEXT_PATH_HTTP_HEADER, FORWARDED_CONTEXT_HTTP_HEADER, FORWARDED_PREFIX_HTTP_HEADER); | ||
if (StringUtils.isNotBlank(proxyContextPath)) { | ||
refUriBuilder.replacePath(StringUtils.substringAfter(UriBuilder.fromUri(ref).build().getPath(), proxyContextPath)); | ||
} | ||
|
||
final URI refUri = refUriBuilder.build(); | ||
|
||
final String query = refUri.getQuery(); | ||
|
||
String rawClusterNodeId = null; | ||
if (query != null) { | ||
final String[] queryParameters = query.split("&"); | ||
|
||
for (int i = 0; i < queryParameters.length; i++) { | ||
if (queryParameters[0].startsWith("clusterNodeId=")) { | ||
rawClusterNodeId = StringUtils.substringAfterLast(queryParameters[0], "clusterNodeId="); | ||
} | ||
} | ||
} | ||
final String clusterNodeId = rawClusterNodeId; | ||
|
||
this.dataRef = refUri.toString(); | ||
this.clusterNodeId = clusterNodeId; | ||
this.clientId = request.getParameter("clientId"); | ||
} | ||
|
||
/** | ||
* Returns the value for the first key discovered when inspecting the current request. Will | ||
* return null if there are no keys specified or if none of the specified keys are found. | ||
* | ||
* @param keys http header keys | ||
* @return the value for the first key found | ||
*/ | ||
private String getFirstHeaderValue(HttpServletRequest httpServletRequest, final String... keys) { | ||
if (keys == null) { | ||
return null; | ||
} | ||
|
||
for (final String key : keys) { | ||
final String value = httpServletRequest.getHeader(key); | ||
|
||
// if we found an entry for this key, return the value | ||
if (value != null) { | ||
return value; | ||
} | ||
} | ||
|
||
// unable to find any matching keys | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getDataUri() { | ||
return this.dataRef; | ||
} | ||
|
||
@Override | ||
public String getClusterNodeId() { | ||
return this.clusterNodeId; | ||
} | ||
|
||
@Override | ||
public String getClientId() { | ||
return this.clientId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.