Merge bierman02-auth and bierman02-base features 23/80123/7
authorJakub Morvay <jmorvay@frinx.io>
Sat, 2 Feb 2019 10:01:00 +0000 (11:01 +0100)
committerJakub Morvay <jmorvay@frinx.io>
Sat, 2 Feb 2019 15:33:11 +0000 (16:33 +0100)
We do not need odl-restconf-nb-bierman02-base feature now. It is
bierman-02 restconf implementations and used to be pulled by both
bierman02-auth and bierman02-noauth features. These two features just
initialized the web application (with or without authentication).

Since bierman02-noauth is no longer with us, merge remaining two
features into odl-restconf-nb-bierman02 feature.

Change-Id: I121e3c109ca1b5f60aac66e76af011cef0774f7d
Signed-off-by: Jakub Morvay <jmorvay@frinx.io>
features/restconf/odl-restconf-nb-bierman02-base/pom.xml [deleted file]
features/restconf/odl-restconf-nb-bierman02/pom.xml
features/restconf/pom.xml
restconf/pom.xml
restconf/restconf-nb-bierman02-auth/pom.xml [deleted file]
restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java [deleted file]
restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml [deleted file]
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java [deleted file]
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java [deleted file]
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java [new file with mode: 0644]
restconf/restconf-nb-bierman02/src/main/resources/OSGI-INF/blueprint/restconf-config.xml

diff --git a/features/restconf/odl-restconf-nb-bierman02-base/pom.xml b/features/restconf/odl-restconf-nb-bierman02-base/pom.xml
deleted file mode 100644 (file)
index 860e37e..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017 Red Hat, Inc. and others.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
- -->
-<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>
-        <groupId>org.opendaylight.odlparent</groupId>
-        <artifactId>single-feature-parent</artifactId>
-        <version>4.0.9</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>odl-restconf-nb-bierman02-base</artifactId>
-    <version>1.10.0-SNAPSHOT</version>
-    <packaging>feature</packaging>
-
-    <name>OpenDaylight :: Restconf :: NB :: bierman02 :: Base</name>
-
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.opendaylight.mdsal</groupId>
-                <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.netconf</groupId>
-                <artifactId>restconf-artifacts</artifactId>
-                <version>1.10.0-SNAPSHOT</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.opendaylight.mdsal.model</groupId>
-            <artifactId>odl-mdsal-model-draft-bierman-netconf-restconf-02</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>odl-restconf-common</artifactId>
-            <type>xml</type>
-            <classifier>features</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>restconf-nb-bierman02</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>sal-rest-connector-config</artifactId>
-            <version>${project.version}</version>
-            <type>cfg</type>
-            <classifier>restconf</classifier>
-        </dependency>
-    </dependencies>
-</project>
index 1234b62c5377cf6af1032e956bb1a3f797076014..b7d310347006db6b19de2c82a9dc9ec37d2aeba8 100644 (file)
 
     <name>OpenDaylight :: Restconf :: NB :: bierman02</name>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.opendaylight.mdsal</groupId>
+                <artifactId>mdsal-artifacts</artifactId>
+                <version>3.0.6</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.opendaylight.netconf</groupId>
+                <artifactId>restconf-artifacts</artifactId>
+                <version>1.10.0-SNAPSHOT</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
     <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>odl-mdsal-model-draft-bierman-netconf-restconf-02</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>odl-restconf-nb-bierman02-base</artifactId>
-            <version>${project.version}</version>
+            <artifactId>odl-restconf-common</artifactId>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>restconf-nb-bierman02-auth</artifactId>
+            <artifactId>restconf-nb-bierman02</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.netconf</groupId>
+            <artifactId>sal-rest-connector-config</artifactId>
             <version>${project.version}</version>
+            <type>cfg</type>
+            <classifier>restconf</classifier>
         </dependency>
     </dependencies>
 </project>
index 4844d3fc98b184d9efd3fa5d00ae3695946e8c8f..a7dcd5bf4375064612ecdf658e3e2748fe84b460 100644 (file)
@@ -32,7 +32,6 @@
         <module>odl-restconf</module>
         <module>odl-restconf-common</module>
         <module>odl-restconf-nb-bierman02</module>
-        <module>odl-restconf-nb-bierman02-base</module>
         <module>odl-restconf-nb-rfc8040</module>
     </modules>
 
index 858bff6f1586f630762de96bf339b8e248b6fa01..9ee1e5309afe6dfc0cf5add0fe7f396e362f849a 100644 (file)
@@ -34,7 +34,6 @@
         <module>restconf-common-models</module>
         <module>restconf-common</module>
         <module>restconf-nb-bierman02</module>
-        <module>restconf-nb-bierman02-auth</module>
         <module>restconf-nb-rfc8040</module>
         <module>sal-rest-connector-config</module>
         <module>sal-rest-docgen</module>
diff --git a/restconf/restconf-nb-bierman02-auth/pom.xml b/restconf/restconf-nb-bierman02-auth/pom.xml
deleted file mode 100644 (file)
index 741713a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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>
-    <groupId>org.opendaylight.netconf</groupId>
-    <artifactId>restconf-parent</artifactId>
-    <version>1.10.0-SNAPSHOT</version>
-    <relativePath>../restconf-parent</relativePath>
-  </parent>
-
-  <groupId>org.opendaylight.netconf</groupId>
-  <artifactId>restconf-nb-bierman02-auth</artifactId>
-  <packaging>bundle</packaging>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.netconf</groupId>
-      <artifactId>restconf-nb-bierman02</artifactId>
-    </dependency>
-  </dependencies>
-</project>
diff --git a/restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java b/restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java
deleted file mode 100644 (file)
index 4f1af41..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.nb.bierman02.web.auth;
-
-import org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar;
-
-/**
- * Initializes the bierman-02 endpoint with authentication.
- *
- * @author Thomas Pantelis
- */
-public class WebInitializer {
-    public WebInitializer(Bierman02WebRegistrar registrar) {
-        registrar.registerWithAuthentication();
-    }
-}
diff --git a/restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml b/restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml
deleted file mode 100644 (file)
index 0a0b21f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2018 Inocybe Technologies Inc. and others.  All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
-  <reference id="webRegistrar" interface="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar"/>
-
-  <bean class="org.opendaylight.restconf.nb.bierman02.web.auth.WebInitializer">
-    <argument ref="webRegistrar"/>
-  </bean>
-
-</blueprint>
diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java
deleted file mode 100644 (file)
index 7e441e9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.sal.restconf.web;
-
-/**
- * Registers the web components for the restconf bierman-02 endpoint.
- *
- * @author Thomas Pantelis
- */
-public interface Bierman02WebRegistrar {
-
-    void registerWithAuthentication();
-
-    void registerWithoutAuthentication();
-}
diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java
deleted file mode 100644 (file)
index fb6f5bc..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.sal.restconf.web;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.servlet.ServletException;
-import javax.ws.rs.core.Application;
-import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
-import org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter;
-import org.opendaylight.aaa.web.FilterDetails;
-import org.opendaylight.aaa.web.ServletDetails;
-import org.opendaylight.aaa.web.WebContext;
-import org.opendaylight.aaa.web.WebContextBuilder;
-import org.opendaylight.aaa.web.WebContextRegistration;
-import org.opendaylight.aaa.web.WebContextSecurer;
-import org.opendaylight.aaa.web.WebServer;
-import org.opendaylight.aaa.web.servlet.ServletSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of Bierman02WebRegistrar.
- *
- * @author Thomas Pantelis
- */
-public class Bierman02WebRegistrarImpl implements Bierman02WebRegistrar {
-    private static final Logger LOG = LoggerFactory.getLogger(Bierman02WebRegistrarImpl.class);
-
-    private final WebServer webServer;
-    private final WebContextSecurer webContextSecurer;
-    private final ServletSupport servletSupport;
-    private final Application webApp;
-    private final CustomFilterAdapterConfiguration customFilterAdapterConfig;
-    private volatile WebContextRegistration registraton;
-    private final AtomicBoolean registered = new AtomicBoolean(false);
-
-    public Bierman02WebRegistrarImpl(WebServer webServer,  WebContextSecurer webContextSecurer,
-            ServletSupport servletSupport, Application webApp,
-            CustomFilterAdapterConfiguration customFilterAdapterConfig) {
-        this.webServer = webServer;
-        this.webContextSecurer = webContextSecurer;
-        this.servletSupport = servletSupport;
-        this.webApp = webApp;
-        this.customFilterAdapterConfig = customFilterAdapterConfig;
-    }
-
-    public void close() {
-        if (registered.compareAndSet(true, false)) {
-            if (registraton != null) {
-                registraton.close();
-            }
-        }
-    }
-
-    @Override
-    public void registerWithAuthentication() {
-        register(true);
-    }
-
-    @Override
-    public void registerWithoutAuthentication() {
-        register(false);
-    }
-
-    private void register(boolean authenticate) {
-        if (!registered.compareAndSet(false, true)) {
-            LOG.warn("Web context has already been registered", new Exception("call site"));
-            return;
-        }
-
-        WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(true)
-                .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build())
-                    .addUrlPattern("/*").build())
-
-                // Allows user to add javax.servlet.Filter(s) in front of REST services
-                .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig))
-                    .addUrlPattern("/*").build())
-
-                .addFilter(FilterDetails.builder().filter(new org.eclipse.jetty.servlets.GzipFilter())
-                    .putInitParam("mimeTypes",
-                        "application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json")
-                    .addUrlPattern("/*").build());
-
-        if (authenticate) {
-            webContextSecurer.requireAuthentication(webContextBuilder, "/*");
-        }
-
-        try {
-            registraton = webServer.registerWebContext(webContextBuilder.build());
-        } catch (ServletException e) {
-            throw new RuntimeException("Failed to register the web context", e);
-        }
-    }
-}
diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java
new file mode 100644 (file)
index 0000000..245925c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.sal.restconf.web;
+
+import javax.servlet.ServletException;
+import javax.ws.rs.core.Application;
+import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
+import org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter;
+import org.opendaylight.aaa.web.FilterDetails;
+import org.opendaylight.aaa.web.ServletDetails;
+import org.opendaylight.aaa.web.WebContext;
+import org.opendaylight.aaa.web.WebContextBuilder;
+import org.opendaylight.aaa.web.WebContextRegistration;
+import org.opendaylight.aaa.web.WebContextSecurer;
+import org.opendaylight.aaa.web.WebServer;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+
+/**
+ * Initializes the bierman-02 endpoint.
+ *
+ * @author Thomas Pantelis
+ */
+public class WebInitializer {
+    private final WebContextRegistration registration;
+
+    public WebInitializer(final WebServer webServer, final WebContextSecurer webContextSecurer,
+            final ServletSupport servletSupport, final Application webApp,
+            final CustomFilterAdapterConfiguration customFilterAdapterConfig) throws ServletException {
+
+        final WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(true)
+                .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build())
+                    .addUrlPattern("/*").build())
+
+                // Allows user to add javax.servlet.Filter(s) in front of REST services
+                .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig))
+                    .addUrlPattern("/*").build())
+
+                .addFilter(FilterDetails.builder().filter(new org.eclipse.jetty.servlets.GzipFilter())
+                    .putInitParam("mimeTypes",
+                        "application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json")
+                    .addUrlPattern("/*").build());
+
+        webContextSecurer.requireAuthentication(webContextBuilder, "/*");
+
+        registration = webServer.registerWebContext(webContextBuilder.build());
+    }
+
+    public void close() {
+        if (registration != null) {
+            registration.close();
+        }
+    }
+}
index cad9c3d6a0b73c5306f5eceb31bf81ead2a39f02..f6e57f7f92a953e4327ad419fadb0e73c525f885 100644 (file)
@@ -99,7 +99,7 @@
   <service ref="jsonRestconfServiceDraft02" odl:type="default"
       interface="org.opendaylight.netconf.sal.restconf.api.JSONRestconfService" />
 
-  <!-- Bierman02WebRegistrar -->
+  <!-- Web app registration -->
 
   <reference id="customFilterAdapterConfig"
       interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>
 
   <reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport" />
 
-  <bean id="webRegistrar" class="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrarImpl"
-          destroy-method="close">
+  <bean class="org.opendaylight.netconf.sal.restconf.web.WebInitializer">
     <argument ref="webServer"/>
     <argument ref="webContextSecurer"/>
     <argument ref="servletSupport"/>
     <argument ref="customFilterAdapterConfig"/>
   </bean>
 
-  <service ref="webRegistrar"
-      interface="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar" />
-
 </blueprint>