*/
package org.opendaylight.restconf.nb.rfc8040;
+import static org.opendaylight.restconf.nb.rfc8040.URLConstants.BASE_PATH;
+import static org.opendaylight.restconf.nb.rfc8040.URLConstants.SSE_SUBPATH;
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 static org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants.NOTIF;
import com.google.common.annotations.Beta;
import javax.servlet.ServletException;
final var restconfBuilder = WebContext.builder()
.name("RFC8040 RESTCONF")
- .contextPath("/" + BASE_URI_PATTERN)
+ .contextPath("/" + BASE_PATH)
.supportsSessions(false)
.addServlet(ServletDetails.builder()
.addUrlPattern("/*")
.servlet(servletSupport.createHttpServletBuilder(
new RestconfApplication(databindProvider, mountPointService, dataBroker, rpcService, actionService,
- notificationService,schemaService, streamsConfiguration)).build())
+ notificationService, schemaService, streamsConfiguration)).build())
.asyncSupported(true)
.build())
.addServlet(ServletDetails.builder()
- .addUrlPattern("/" + NOTIF + "/*")
+ .addUrlPattern("/" + SSE_SUBPATH + "/*")
.servlet(servletSupport.createHttpServletBuilder(
new DataStreamApplication(databindProvider, mountPointService,
new RestconfDataStreamServiceImpl(scheduledThreadPool, streamsConfiguration))).build())
.supportsSessions(false)
.addServlet(ServletDetails.builder()
.addUrlPattern("/*")
- .servlet(servletSupport.createHttpServletBuilder(new RootFoundApplication(BASE_URI_PATTERN)).build())
+ .servlet(servletSupport.createHttpServletBuilder(new RootFoundApplication(BASE_PATH)).build())
.name("Rootfound")
.build());
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, 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
+ */
+package org.opendaylight.restconf.nb.rfc8040;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * Various constants related to the layout of URLs on which the implementation resides.
+ */
+@NonNullByDefault
+public final class URLConstants {
+ /**
+ * The first element URL path element for RESTCONF implementation, i.e. {@code https://localhost/BASE_PATH}.
+ */
+ public static final String BASE_PATH = "rests";
+ /**
+ * The second element for Server Sent Events support, i.e. {@code https://localhost/BASE_PATH/NOTIF}.
+ */
+ public static final String SSE_SUBPATH = "notif";
+
+ private URLConstants() {
+ // Hidden on purpose
+ }
+}
\ No newline at end of file
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.NotificationQueryParams;
+import org.opendaylight.restconf.nb.rfc8040.URLConstants;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.monitoring.RestconfStateStreams;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl.HandlersHolder;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenerAdapter;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenersBroker;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
@Override
public URI prepareUriByStreamName(final UriInfo uriInfo, final String streamName) {
- final UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
- return uriBuilder.replacePath(RestconfConstants.BASE_URI_PATTERN + '/'
- + RestconfConstants.NOTIF + '/' + streamName).build();
+ return uriInfo.getBaseUriBuilder()
+ .replacePath(URLConstants.BASE_PATH + '/' + URLConstants.SSE_SUBPATH + '/' + streamName)
+ .build();
}
}
// Unsecured HTTP and others go to unsecured WebSockets
uriBuilder.scheme("ws");
}
- return uriBuilder.replacePath(RestconfConstants.BASE_URI_PATTERN + '/' + streamName).build();
+ return uriBuilder.replacePath(URLConstants.BASE_PATH + '/' + streamName).build();
}
}
import java.util.concurrent.locks.StampedLock;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.restconf.nb.rfc8040.URLConstants;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
/**
* Creates string representation of stream name from URI. Removes slash from URI in start and end positions,
- * and optionally {@link RestconfConstants#BASE_URI_PATTERN} prefix.
+ * and optionally {@link URLConstants#BASE_PATH} prefix.
*
* @param uri URI for creation of stream name.
* @return String representation of stream name.
public static String createStreamNameFromUri(final String uri) {
String result = requireNonNull(uri);
while (true) {
- if (result.startsWith(RestconfConstants.BASE_URI_PATTERN)) {
- result = result.substring(RestconfConstants.BASE_URI_PATTERN.length());
+ if (result.startsWith(URLConstants.BASE_PATH)) {
+ result = result.substring(URLConstants.BASE_PATH.length());
} else if (result.startsWith("/")) {
result = result.substring(1);
} else {
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, 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
- */
-package org.opendaylight.restconf.nb.rfc8040.utils;
-
-/**
- * Util class for Restconf constants.
- */
-public final class RestconfConstants {
- public static final String BASE_URI_PATTERN = "rests";
- public static final String NOTIF = "notif";
-
- private RestconfConstants() {
- // Hidden on purpose
- }
-}
\ No newline at end of file
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.restconf.nb.rfc8040.URLConstants;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenerAdapter;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenersBroker;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
configurationSse);
final NormalizedNodePayload response = streamsSubscriptionService.subscribeToStream(
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", uriInfo);
- assertEquals("http://localhost:8181/" + RestconfConstants.BASE_URI_PATTERN
- + "/" + RestconfConstants.NOTIF
- + "/data-change-event-subscription/toaster:toaster/toasterStatus/"
- + "datastore=OPERATIONAL/scope=ONE", response.getNewHeaders().get("Location").toString());
+ assertEquals("http://localhost:8181/" + URLConstants.BASE_PATH + "/" + URLConstants.SSE_SUBPATH
+ + "/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
+ response.getNewHeaders().get("Location").toString());
}
@Test
configurationWs);
final NormalizedNodePayload response = streamsSubscriptionService.subscribeToStream(
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE", uriInfo);
- assertEquals("ws://localhost:8181/" + RestconfConstants.BASE_URI_PATTERN
- + "/data-change-event-subscription/toaster:toaster/toasterStatus/"
- + "datastore=OPERATIONAL/scope=ONE", response.getNewHeaders().get("Location").toString());
+ assertEquals("ws://localhost:8181/" + URLConstants.BASE_PATH
+ + "/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
+ response.getNewHeaders().get("Location").toString());
}
@Test