You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2019/08/20 00:28:52 UTC

[knox] branch master updated: KNOX-1952 - Add NiFi Registry service definition (#128)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new a102269  KNOX-1952 - Add NiFi Registry service definition (#128)
a102269 is described below

commit a102269496c895067f74c0bb25a90b52281e9740
Author: Koji Kawamura <ij...@users.noreply.github.com>
AuthorDate: Tue Aug 20 09:28:47 2019 +0900

    KNOX-1952 - Add NiFi Registry service definition (#128)
---
 gateway-release/pom.xml                            |  4 ++
 .../services/nifi-registry/0.5.0/rewrite.xml       | 27 ++++++++
 .../services/nifi-registry/0.5.0/service.xml       | 30 +++++++++
 gateway-service-nifi-registry/pom.xml              | 74 ++++++++++++++++++++++
 .../gateway/dispatch/NiFiRegistryDispatch.java     | 22 +++++++
 .../gateway/dispatch/NiFiRegistryHaDispatch.java   | 26 ++++++++
 .../knox/gateway/dispatch/NiFiRequestUtil.java     |  2 +-
 pom.xml                                            |  6 ++
 8 files changed, 190 insertions(+), 1 deletion(-)

diff --git a/gateway-release/pom.xml b/gateway-release/pom.xml
index 64a3dfc..fdc4536 100644
--- a/gateway-release/pom.xml
+++ b/gateway-release/pom.xml
@@ -283,6 +283,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-service-nifi-registry</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
             <artifactId>gateway-provider-rewrite</artifactId>
         </dependency>
         <dependency>
diff --git a/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/rewrite.xml b/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/rewrite.xml
new file mode 100644
index 0000000..23c1114
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/rewrite.xml
@@ -0,0 +1,27 @@
+<!--
+   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.
+-->
+<rules>
+    <rule dir="IN" name="NIFI-REGISTRY/nifi-registry/inbound/path" pattern="*://*:*/**/nifi-registry-app/{path=**}">
+        <rewrite template="{$serviceUrl[NIFI-REGISTRY]}/{path=**}"/>
+    </rule>
+    <rule dir="IN" name="NIFI-REGISTRY/nifi-registry/inbound/path/query" pattern="*://*:*/**/nifi-registry-app/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[NIFI-REGISTRY]}/{path=**}?{**}"/>
+    </rule>
+    <rule dir="IN" name="NIFI-REGISTRY/nifi-registry/inbound/path/query-other" pattern="*://*:*/**/nifi-registry-app/{path=**}/?{**}">
+        <rewrite template="{$serviceUrl[NIFI-REGISTRY]}/{path=**}/?{**}"/>
+    </rule>
+</rules>
diff --git a/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/service.xml b/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/service.xml
new file mode 100644
index 0000000..0b1a32b
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/nifi-registry/0.5.0/service.xml
@@ -0,0 +1,30 @@
+<!--
+   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.
+-->
+<service role="NIFI-REGISTRY" name="nifi-registry" version="0.5.0">
+    <routes>
+        <route path="/nifi-registry-app/**">
+            <rewrite apply="NIFI-REGISTRY/nifi-registry/inbound/path" to="request.url"/>
+        </route>
+        <route path="/nifi-registry-app/**?**">
+            <rewrite apply="NIFI-REGISTRY/nifi-registry/inbound/path/query" to="request.url"/>
+        </route>
+        <route path="/nifi-registry-app/**/?**">
+            <rewrite apply="NIFI-REGISTRY/nifi-registry/inbound/path/query-other" to="request.url"/>
+        </route>
+    </routes>
+    <dispatch classname="org.apache.knox.gateway.dispatch.NiFiRegistryDispatch" ha-classname="org.apache.knox.gateway.dispatch.NiFiRegistryHaDispatch" />
+</service>
diff --git a/gateway-service-nifi-registry/pom.xml b/gateway-service-nifi-registry/pom.xml
new file mode 100644
index 0000000..57dae6f
--- /dev/null
+++ b/gateway-service-nifi-registry/pom.xml
@@ -0,0 +1,74 @@
+<?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.
+-->
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>gateway</artifactId>
+        <groupId>org.apache.knox</groupId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>gateway-service-nifi-registry</artifactId>
+    <name>gateway-service-nifi-registry</name>
+    <description>Extension to the gateway for supporting Apache NiFi Registry.</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-spi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-provider-ha</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-util-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-service-nifi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryDispatch.java b/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryDispatch.java
new file mode 100644
index 0000000..4ec44a5
--- /dev/null
+++ b/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryDispatch.java
@@ -0,0 +1,22 @@
+/*
+ * 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.knox.gateway.dispatch;
+
+public class NiFiRegistryDispatch extends NiFiDispatch {
+
+}
diff --git a/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryHaDispatch.java b/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryHaDispatch.java
new file mode 100644
index 0000000..41aa9c7
--- /dev/null
+++ b/gateway-service-nifi-registry/src/main/java/org/apache/knox/gateway/dispatch/NiFiRegistryHaDispatch.java
@@ -0,0 +1,26 @@
+/*
+ * 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.knox.gateway.dispatch;
+
+public class NiFiRegistryHaDispatch extends NiFiHaDispatch {
+
+  public NiFiRegistryHaDispatch() {
+    setServiceRole("NIFI-REGISTRY");
+  }
+
+}
diff --git a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
index b028695..544cde6 100644
--- a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
+++ b/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiRequestUtil.java
@@ -60,7 +60,7 @@ class NiFiRequestUtil {
         if (index >= 0) {
           knoxRouteContext = inboundRequestPathInfo.substring(0, index);
         } else {
-          Logger.getLogger(NiFiHaDispatch.class.getName()).error(String.format(Locale.ROOT, "Unable to find index of %s in %s", outboundRequestUriPathNoTrailingSlash, inboundRequestPathInfo));
+          Logger.getLogger(NiFiRequestUtil.class.getName()).error(String.format(Locale.ROOT, "Unable to find index of %s in %s", outboundRequestUriPathNoTrailingSlash, inboundRequestPathInfo));
         }
         outboundRequest.setHeader(NiFiHeaders.X_FORWARDED_CONTEXT, xForwardedContextHeaderValue + knoxRouteContext);
       }
diff --git a/pom.xml b/pom.xml
index a7cc82e..ec1bbbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,7 @@
         <module>gateway-shell-release</module>
         <module>gateway-test-release-utils</module>
         <module>gateway-service-nifi</module>
+        <module>gateway-service-nifi-registry</module>
         <module>gateway-docker</module>
         <module>gateway-service-hashicorp-vault</module>
         <module>gateway-release-common</module>
@@ -1017,6 +1018,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.knox</groupId>
+                <artifactId>gateway-service-nifi-registry</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.knox</groupId>
                 <artifactId>gateway-server</artifactId>
                 <version>${project.version}</version>
             </dependency>