import javax.ws.rs.core.Application;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.errors.RestconfDocumentedExceptionMapper;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RootResourceDiscoveryService;
-import org.opendaylight.restconf.nb.rfc8040.services.wrapper.RootResourceDiscoveryServiceImpl;
+import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RootResourceDiscoveryServiceImpl;
public class RootFoundApplication extends Application {
- private final RootResourceDiscoveryService rrds = new RootResourceDiscoveryServiceImpl();
+ private final RootResourceDiscoveryService rrds;
+
+ public RootFoundApplication(final String restconfRoot) {
+ rrds = new RootResourceDiscoveryServiceImpl(restconfRoot);
+ }
@Override
public Set<Class<?>> getClasses() {
--- /dev/null
+/*
+ * Copyright (c) 2020 ZTE Corp. 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.rfc8040.rests.services.impl;
+
+import static java.util.Objects.requireNonNull;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RootResourceDiscoveryService;
+
+@Path("/")
+public final class RootResourceDiscoveryServiceImpl implements RootResourceDiscoveryService {
+ private final String restconfRoot;
+
+ public RootResourceDiscoveryServiceImpl(final String restconfRoot) {
+ this.restconfRoot = requireNonNull(restconfRoot);
+ }
+
+ @Override
+ public Response readXrdData() {
+ return Response.status(Status.OK)
+ .entity("<?xml version='1.0' encoding='UTF-8'?>\n"
+ + "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n"
+ + " <Link rel='restconf' href='/" + restconfRoot + "'/>\n"
+ + "</XRD>")
+ .build();
+ }
+
+ @Override
+ public Response readJsonData() {
+ return Response.status(Status.OK)
+ .entity("{\n"
+ + " \"links\" :\n"
+ + " {\n"
+ + " \"rel\" : \"restconf\",\n"
+ + " \"href\" : \"/" + restconfRoot + "\"\n"
+ + " }\n"
+ + "}")
+ .build();
+ }
+}
+
+++ /dev/null
-/*
- * Copyright (c) 2020 ZTE Corp. 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.rfc8040.services.wrapper;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RootResourceDiscoveryService;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
-
-@Path("/")
-public final class RootResourceDiscoveryServiceImpl implements RootResourceDiscoveryService {
-
- @Override
- public Response readXrdData() {
- return Response.status(Status.OK)
- .entity("<?xml version='1.0' encoding='UTF-8'?>\n"
- + "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n"
- + " <Link rel='restconf' href='/" + RestconfConstants.BASE_URI_PATTERN + "'/>\n"
- + "</XRD>")
- .build();
- }
-
- @Override
- public Response readJsonData() {
- return Response.status(Status.OK)
- .entity("{\n"
- + " \"links\" :\n"
- + " {\n"
- + " \"rel\" : \"restconf\",\n"
- + " \"href\" : \"/" + RestconfConstants.BASE_URI_PATTERN + "/\"\n"
- + " }\n"
- + "}")
- .build();
- }
-}
-
*/
@Singleton
public class WebInitializer {
-
private final WebContextRegistration registration;
@Inject
- public WebInitializer(@Reference WebServer webServer, @Reference WebContextSecurer webContextSecurer,
- @Reference ServletSupport servletSupport, RestconfApplication webApp,RestconfNotifApplication webAppNotif,
- @Reference CustomFilterAdapterConfiguration customFilterAdapterConfig,
- WebSocketInitializer webSocketServlet) throws ServletException {
+ public WebInitializer(@Reference final WebServer webServer, @Reference final WebContextSecurer webContextSecurer,
+ @Reference final ServletSupport servletSupport, final RestconfApplication webApp,
+ final RestconfNotifApplication webAppNotif,
+ @Reference final CustomFilterAdapterConfiguration customFilterAdapterConfig,
+ final WebSocketInitializer webSocketServlet) throws ServletException {
WebContextBuilder webContextBuilder = WebContext.builder().contextPath("/")
.supportsSessions(false)
.addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build())
.build())
.addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(
- new RootFoundApplication()).build())
+ new RootFoundApplication(RestconfConstants.BASE_URI_PATTERN)).build())
.addUrlPattern(".well-known/*").name("Rootfound").build())
// Allows user to add javax.servlet.Filter(s) in front of REST services
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc8040.rests.services.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class RootResourceDiscoveryServiceTest {
+ @Test
+ public void testJsonData() {
+ assertEquals("{\n"
+ + " \"links\" :\n"
+ + " {\n"
+ + " \"rel\" : \"restconf\",\n"
+ + " \"href\" : \"/fooBarBaz\"\n"
+ + " }\n"
+ + "}", new RootResourceDiscoveryServiceImpl("fooBarBaz").readJsonData().getEntity());
+ }
+
+ @Test
+ public void testXrdData() {
+ assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n"
+ + "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n"
+ + " <Link rel='restconf' href='/fooBarBaz'/>\n"
+ + "</XRD>", new RootResourceDiscoveryServiceImpl("fooBarBaz").readXrdData().getEntity());
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc8040.services.wrapper;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class RRDSImplTest {
- @Test
- public void testHostMeta() {
- assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n"
- + "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n"
- + " <Link rel='restconf' href='/rests'/>\n"
- + "</XRD>", new RootResourceDiscoveryServiceImpl().readXrdData().getEntity());
- }
-}