Repository: incubator-nifi Updated Branches: refs/heads/develop 0bd27847a -> e05c9fd20
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.css index 0432340..edf66f3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.css +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.css @@ -86,3 +86,11 @@ div.combo-nifi-tooltip { background-color: #FFFFA3; color: #454545; } + +div.button-normal { + background: transparent url(../../../images/bgButton.png) repeat-x center center; +} + +div.button-over { + background: transparent url(../../../images/bgButtonOver.png) repeat-x center center; +} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/pom.xml index 11c3c0a..1218f6c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/pom.xml @@ -29,8 +29,10 @@ <module>nifi-web-api</module> <module>nifi-web-error</module> <module>nifi-web-docs</module> + <module>nifi-web-content-viewer</module> <module>nifi-web-ui</module> <module>nifi-jetty</module> + <module>nifi-web-content-access</module> </modules> <dependencyManagement> <dependencies> @@ -54,6 +56,12 @@ </dependency> <dependency> <groupId>org.apache.nifi</groupId> + <artifactId>nifi-web-content-viewer</artifactId> + <type>war</type> + <version>0.1.0-incubating-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> <artifactId>nifi-web-ui</artifactId> <type>war</type> <version>0.1.0-incubating-SNAPSHOT</version> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-framework-bundle/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/pom.xml index 074821a..28fb24c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/pom.xml @@ -65,6 +65,11 @@ </dependency> <dependency> <groupId>org.apache.nifi</groupId> + <artifactId>nifi-web-content-access</artifactId> + <version>0.1.0-incubating-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> <artifactId>nifi-security</artifactId> <version>0.1.0-incubating-SNAPSHOT</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml new file mode 100644 index 0000000..1b13178 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml @@ -0,0 +1,71 @@ +<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/maven-v4_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> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-standard-bundle</artifactId> + <version>0.1.0-incubating-SNAPSHOT</version> + </parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-standard-content-viewer</artifactId> + <packaging>war</packaging> + <dependencies> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.13</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</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/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java new file mode 100644 index 0000000..6ce315e --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/java/org/apache/nifi/web/StandardContentViewerController.java @@ -0,0 +1,103 @@ +/* + * 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 java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import org.apache.nifi.web.ViewableContent.DisplayMode; +import org.codehaus.jackson.map.ObjectMapper; + +/** + * + */ +@WebServlet(name = "StandardContentViewer", urlPatterns = {"/view-content"}) +public class StandardContentViewerController extends HttpServlet { + + /** + * + * @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 { + 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())) { + 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())) { + // format json + final ObjectMapper mapper = new ObjectMapper(); + final Object objectJson = mapper.readValue(content.getContent(), Object.class); + formatted = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(objectJson); + } else if ("application/xml".equals(content.getContentType())) { + // format xml + final StringWriter writer = new StringWriter(); + + try { + final StreamSource source = new StreamSource(content.getContentStream()); + final StreamResult result = new StreamResult(writer); + + final TransformerFactory transformFactory = TransformerFactory.newInstance(); + final Transformer transformer = transformFactory.newTransformer(); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + transformer.transform(source, result); + } catch (final TransformerFactoryConfigurationError | TransformerException te) { + throw new IOException("Unable to transform content as XML: " + te, te); + } + + // get the transformed xml + formatted = writer.toString(); + } else { + // leave plain text alone when formatting + formatted = content.getContent(); + } + } + + // defer to the jsp + request.setAttribute("mode", content.getContentType()); + 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()); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/resources/META-INF/NOTICE ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/resources/META-INF/NOTICE b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000..d91a952 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/resources/META-INF/NOTICE @@ -0,0 +1,19 @@ +nifi-web-docs +Copyright 2014-2015 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +=========================================== +Apache Software License v2 +=========================================== + +The following binary components are provided under the Apache Software License v2 + + (ASLv2) Apache Commons Lang + The following NOTICE information applies: + Apache Commons Lang + Copyright 2001-2014 The Apache Software Foundation + + This product includes software from the Spring Framework, + under the Apache License 2.0 (see: StringUtils.containsWhitespace()) http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer new file mode 100644 index 0000000..cbf30b7 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/META-INF/nifi-content-viewer @@ -0,0 +1,3 @@ +application/xml +application/json +text/plain \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/jsp/codemirror.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/jsp/codemirror.jsp b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/jsp/codemirror.jsp new file mode 100644 index 0000000..65ad826 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/jsp/codemirror.jsp @@ -0,0 +1,47 @@ +<%-- + 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. +--%> +<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %> +<link rel="stylesheet" href="../nifi/js/codemirror/lib/codemirror.css" type="text/css" /> +<link rel="stylesheet" href="../nifi/js/codemirror/addon/fold/foldgutter.css" type="text/css" /> +<script type="text/javascript" src="../nifi/js/codemirror/lib/codemirror-compressed.js"></script> +<script type="text/javascript" src="../nifi/js/jquery/jquery-2.1.1.min.js"></script> + +<textarea id="codemirror-content">${content}</textarea> + +<script type="text/javascript"> + $(document).ready(function() { + var field = document.getElementById('codemirror-content'); + var editor = CodeMirror.fromTextArea(field, { + mode: '${mode}', + lineNumbers: true, + matchBrackets: true, + foldGutter: true, + gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + readOnly: true + }); + + var setEditorSize = function() { + editor.setSize($(window).width() - 150, $(window).height() - 150); + }; + + // reset the editor size when the window changes + $(window).resize(setEditorSize); + + // initialize the editor size + setEditorSize(); + }); +</script> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/web.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..8f59916 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,29 @@ +<?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-standard-content-viewer</display-name> + <servlet> + <servlet-name>StandardContentViewer</servlet-name> + <servlet-class>org.apache.nifi.web.StandardContentViewerController</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>StandardContentViewer</servlet-name> + <url-pattern>/view-content</url-pattern> + </servlet-mapping> + <welcome-file-list> + <welcome-file>view-content</welcome-file> + </welcome-file-list> +</web-app> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/css/main.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/css/main.css b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/css/main.css new file mode 100644 index 0000000..dad3120 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/src/main/webapp/css/main.css @@ -0,0 +1,20 @@ +/* + * 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. + */ +* { + margin: 0; + padding: 0; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml index 8830a15..15b285d 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-nar/pom.xml @@ -40,5 +40,10 @@ <groupId>org.apache.nifi</groupId> <artifactId>nifi-standard-reporting-tasks</artifactId> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-standard-content-viewer</artifactId> + <type>war</type> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/e05c9fd2/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml b/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml index 1701c85..6c00f1f 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/pom.xml @@ -1,3 +1,4 @@ +<?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/maven-v4_0_0.xsd"> <!-- Licensed to the Apache Software Foundation (ASF) under one or more @@ -26,8 +27,9 @@ <module>nifi-standard-processors</module> <module>nifi-standard-prioritizers</module> <module>nifi-standard-reporting-tasks</module> + <module>nifi-standard-content-viewer</module> <module>nifi-standard-nar</module> - </modules> + </modules> <dependencyManagement> <dependencies> <dependency> @@ -45,6 +47,12 @@ <artifactId>nifi-standard-reporting-tasks</artifactId> <version>0.1.0-incubating-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-standard-content-viewer</artifactId> + <type>war</type> + <version>0.1.0-incubating-SNAPSHOT</version> + </dependency> </dependencies> </dependencyManagement>
