Fix netconf WebInitializer url patterns 52/102552/3
authorOleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Tue, 4 Oct 2022 09:56:19 +0000 (11:56 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 20 Oct 2022 09:47:11 +0000 (11:47 +0200)
Fixed url patterns in WebInitializer so they all correspond
to specification.

JIRA: AAA-233
Change-Id: I2cfdabc7243e2c2d94debc3e02f6875d8ad13293
Signed-off-by: OleksandrZharov <Oleksandr.Zharov@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/web/WebInitializer.java

index 3d8016c26688a52abea9a72311a74bd143e1dcbd..e37551564600270706acb71fdab20371bed36670 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.web;
 
+import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants.DATA_SUBSCRIPTION;
+import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants.NOTIFICATION_STREAM;
+import static org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants.BASE_URI_PATTERN;
+
 import java.util.List;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
@@ -24,9 +28,7 @@ import org.opendaylight.aaa.web.servlet.ServletSupport;
 import org.opendaylight.restconf.nb.rfc8040.DataStreamApplication;
 import org.opendaylight.restconf.nb.rfc8040.RestconfApplication;
 import org.opendaylight.restconf.nb.rfc8040.RootFoundApplication;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants;
 import org.opendaylight.restconf.nb.rfc8040.streams.WebSocketInitializer;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.concepts.Registration;
 
 /**
@@ -48,27 +50,25 @@ public class WebInitializer {
             .contextPath("/")
             .supportsSessions(false)
             .addServlet(ServletDetails.builder()
-                .addUrlPattern(RestconfConstants.BASE_URI_PATTERN + "/*")
+                .addUrlPattern("/" + BASE_URI_PATTERN + "/*")
                 .servlet(servletSupport.createHttpServletBuilder(webApp).build())
                 .asyncSupported(true)
                 .build())
             .addServlet(ServletDetails.builder()
-                .addUrlPattern(RestconfConstants.BASE_URI_PATTERN + "/notif/*")
+                .addUrlPattern("/" + BASE_URI_PATTERN + "/notif/*")
                 .servlet(servletSupport.createHttpServletBuilder(webAppNotif).build())
                 .name("notificationServlet")
                 .asyncSupported(true)
                 .build())
             .addServlet(ServletDetails.builder()
                 .addAllUrlPatterns(List.of(
-                    RestconfConstants.BASE_URI_PATTERN + "/" + RestconfStreamsConstants.DATA_SUBSCRIPTION + "/*",
-                    RestconfConstants.BASE_URI_PATTERN + "/" + RestconfStreamsConstants.NOTIFICATION_STREAM + "/*"))
+                    "/" + BASE_URI_PATTERN + "/" + DATA_SUBSCRIPTION + "/*",
+                    "/" + BASE_URI_PATTERN + "/" + NOTIFICATION_STREAM + "/*"))
                 .servlet(webSocketServlet)
                 .build())
             .addServlet(ServletDetails.builder()
-                .addUrlPattern(".well-known/*")
-                .servlet(servletSupport.createHttpServletBuilder(
-                    new RootFoundApplication(RestconfConstants.BASE_URI_PATTERN))
-                    .build())
+                .addUrlPattern("/.well-known/*")
+                .servlet(servletSupport.createHttpServletBuilder(new RootFoundApplication(BASE_URI_PATTERN)).build())
                 .name("Rootfound")
                 .build())
 
@@ -79,7 +79,7 @@ public class WebInitializer {
                 .asyncSupported(true)
                 .build());
 
-        webContextSecurer.requireAuthentication(webContextBuilder, true, RestconfConstants.BASE_URI_PATTERN + "/*");
+        webContextSecurer.requireAuthentication(webContextBuilder, true, "/" + BASE_URI_PATTERN + "/*");
 
         registration = webServer.registerWebContext(webContextBuilder.build());
     }