NIFI-250: - Removing unneeded artifact. Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/1c96bd08 Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/1c96bd08 Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/1c96bd08
Branch: refs/heads/NIFI-250 Commit: 1c96bd08f7903f9acc845a542ccb7196f8a264c0 Parents: 1de514a Author: Matt Gilman <[email protected]> Authored: Mon Mar 23 09:49:18 2015 -0400 Committer: Matt Gilman <[email protected]> Committed: Mon Mar 23 09:49:18 2015 -0400 ---------------------------------------------------------------------- .../nifi-ui-extension-controller/pom.xml | 66 ----- .../extension/ConfigureComponentController.java | 254 ------------------- .../src/main/webapp/WEB-INF/web.xml | 26 -- 3 files changed, 346 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1c96bd08/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/pom.xml deleted file mode 100644 index ee2e22c..0000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <!-- - 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. - --> - <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>nifi-web</artifactId> - <groupId>org.apache.nifi</groupId> - <version>0.1.0-incubating-SNAPSHOT</version> - </parent> - <groupId>org.apache.nifi</groupId> - <artifactId>nifi-ui-extension-controller</artifactId> - <packaging>war</packaging> - <dependencies> - <dependency> - <groupId>org.apache.nifi</groupId> - <artifactId>nifi-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.nifi</groupId> - <artifactId>nifi-user-actions</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.nifi</groupId> - <artifactId>nifi-ui-extension</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <dependency> - <groupId>javax.servlet.jsp</groupId> - <artifactId>javax.servlet.jsp-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.el</groupId> - <artifactId>javax.el-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet.jsp.jstl</groupId> - <artifactId>javax.servlet.jsp.jstl-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1c96bd08/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/java/org/apache/nifi/ui/extension/ConfigureComponentController.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/java/org/apache/nifi/ui/extension/ConfigureComponentController.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/java/org/apache/nifi/ui/extension/ConfigureComponentController.java deleted file mode 100644 index c876686..0000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/java/org/apache/nifi/ui/extension/ConfigureComponentController.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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.ui.extension; - -import org.apache.nifi.web.UiExtensionType; -import org.apache.nifi.web.controller.UiExtensionControllerRequest; -import org.apache.nifi.web.controller.UiExtensionControllerFacade; -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -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.nifi.action.Action; -import org.apache.nifi.action.Component; -import org.apache.nifi.action.Operation; -import org.apache.nifi.action.component.details.ExtensionDetails; -import org.apache.nifi.action.details.ConfigureDetails; -import org.apache.nifi.controller.ControllerService; -import org.apache.nifi.web.ClusterRequestException; -import org.apache.nifi.web.ComponentDetails; -import org.apache.nifi.web.ConfigurationAction; -import org.apache.nifi.web.InvalidRevisionException; -import org.apache.nifi.web.ResourceNotFoundException; -import org.apache.nifi.web.Revision; -import org.apache.nifi.web.UiExtensionRequestContext; - - -/** - * - */ -public class ConfigureComponentController extends HttpServlet { - - public static final String ID_PARAM = "id"; - public static final String CLIENT_ID_PARAM = "clientId"; - public static final String VERSION_PARAM = "version"; - - /** - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - // get the content - final ServletContext servletContext = request.getServletContext(); - final Object extensionMappings = (Object) servletContext.getAttribute("nifi-ui-extension-mapping"); - final UiExtensionControllerFacade controllerFacade = (UiExtensionControllerFacade) servletContext.getAttribute("nifi-ui-extension-controller-facade"); - - // get the component type - final String type = request.getParameter("type"); - - // ensure the request has - if (type == null) { - response.getWriter().println("Request missing the component type."); - return; - } - - // change later - final UiExtensionType extensionType = UiExtensionType.ProcessorConfiguration; - - // build the ui extension request context config - final UiExtensionControllerRequest config = getRequestContextConig(extensionType, request); - - // get the initial component details - final ComponentDetails details = controllerFacade.getComponentDetails(config); - - // lookup a viewer for the content - final String uiExtensionUri = servletContext.getInitParameter(type); - - // ensure the registered viewer is found - if (uiExtensionUri == null) { - response.getWriter().println("No custom UI is registered for " + type); - } - - // set the attribute for the custom ui to interact with nifi - request.setAttribute(UiExtensionRequestContext.ATTRIBUTE_KEY, new UiExtensionRequestContext() { - @Override - public ControllerService getControllerService(final String serviceIdentifier) { - return controllerFacade.getControllerService(serviceIdentifier); - } - - @Override - public void saveActions(Collection<ConfigurationAction> uiExtensionActions) { - final Collection<Action> actions = new ArrayList<>(); - - // conver the action models - if (uiExtensionActions != null) { - final Date now = new Date(); - - // create the extension details - ExtensionDetails extensionDetails = new ExtensionDetails(); - extensionDetails.setType(details.getType()); - - for (final ConfigurationAction extensionAction : uiExtensionActions) { - // create the action details - final ConfigureDetails actionDetails = new ConfigureDetails(); - actionDetails.setName(extensionAction.getField()); - actionDetails.setValue(extensionAction.getValue()); - actionDetails.setPreviousValue(extensionAction.getPreviousValue()); - - // create a configuration action - Action configurationAction = new Action(); - configurationAction.setUserDn(getCurrentUserDn()); - configurationAction.setUserName(getCurrentUserName()); - configurationAction.setOperation(Operation.Configure); - configurationAction.setTimestamp(now); - configurationAction.setSourceId(details.getId()); - configurationAction.setSourceName(details.getName()); - configurationAction.setSourceType(Component.Processor); - configurationAction.setComponentDetails(extensionDetails); - configurationAction.setActionDetails(actionDetails); - - // add the action - actions.add(configurationAction); - } - } - - // save the actions - if (!actions.isEmpty()) { - controllerFacade.saveActions(actions); - } - } - - @Override - public String getCurrentUserDn() { - return controllerFacade.getCurrentUserDn(); - } - - @Override - public String getCurrentUserName() { - return controllerFacade.getCurrentUserName(); - } - - @Override - public ComponentDetails setAnnotationData(String annotationData) throws ClusterRequestException, InvalidRevisionException, ResourceNotFoundException{ - return controllerFacade.setAnnotationData(config, annotationData); - } - - @Override - public ComponentDetails getComponentDetails() throws ClusterRequestException, ResourceNotFoundException { - return controllerFacade.getComponentDetails(config); - } - }); - - // generate the content - final ServletContext customUiContext = servletContext.getContext(uiExtensionUri); - customUiContext.getRequestDispatcher("/configure").forward(request, response); - } - - /** - * Creates a UiExtensionRequestContextConfig from the specified request. - * - * @param request - * @return - */ - private UiExtensionControllerRequest getRequestContextConig(final UiExtensionType extensionType, final HttpServletRequest request) { - return new UiExtensionControllerRequest() { - - @Override - public UiExtensionType getExtensionType() { - return extensionType; - } - - @Override - public String getScheme() { - return request.getScheme(); - } - - @Override - public String getId() { - return request.getParameter(ID_PARAM); - } - - @Override - public Revision getRevision() { - final String versionParamVal = request.getParameter(VERSION_PARAM); - Long version; - try { - version = Long.parseLong(versionParamVal); - } catch (final Exception ex) { - version = null; - } - - final String clientId = request.getParameter(CLIENT_ID_PARAM); - - return new Revision(version, clientId); - } - - @Override - public String getProxiedEntitiesChain() { - String xProxiedEntitiesChain = request.getHeader("X-ProxiedEntitiesChain"); - final X509Certificate cert = extractClientCertificate(request); - if (cert != null) { - final String extractedPrincipal = extractPrincipal(cert); - final String formattedPrincipal = formatProxyDn(extractedPrincipal); - if (xProxiedEntitiesChain == null || xProxiedEntitiesChain.trim().isEmpty()) { - xProxiedEntitiesChain = formattedPrincipal; - } else { - xProxiedEntitiesChain += formattedPrincipal; - } - } - - return xProxiedEntitiesChain; - } - }; - } - - /** - * Utility methods that have been copied into this class to reduce the - * dependency footprint of this artifact. These utility methods typically - * live in web-utilities but that would pull in spring, jersey, jackson, - * etc. - */ - - private X509Certificate extractClientCertificate(HttpServletRequest request) { - X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); - - if (certs != null && certs.length > 0) { - return certs[0]; - } - - return null; - } - - private String extractPrincipal(X509Certificate cert) { - return cert.getSubjectDN().getName().trim(); - } - - private String formatProxyDn(String dn) { - return "<" + dn + ">"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/1c96bd08/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/webapp/WEB-INF/web.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index a2e6a39..0000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension-controller/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> - <display-name>nifi-ui-extension</display-name> - <servlet> - <servlet-name>configure-component-controller</servlet-name> - <servlet-class>org.apache.nifi.ui.extension.ConfigureComponentController</servlet-class> - </servlet> - <servlet-mapping> - <servlet-name>configure-component-controller</servlet-name> - <url-pattern>/configure</url-pattern> - </servlet-mapping> -</web-app>
