import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants;
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.parser.ParserIdentifier;
+import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.yang.common.ErrorTag;
private static final QName SCOPE_QNAME =
QName.create(SAL_REMOTE_AUGMENT, RestconfStreamsConstants.SCOPE_PARAM_NAME).intern();
private static final QName OUTPUT_TYPE_QNAME =
- QName.create(SAL_REMOTE_AUGMENT, RestconfStreamsConstants.OUTPUT_TYPE_PARAM_NAME).intern();
+ QName.create(SAL_REMOTE_AUGMENT, "notification-output-type").intern();
private static final NodeIdentifier DATASTORE_NODEID = NodeIdentifier.create(DATASTORE_QNAME);
private static final NodeIdentifier SCOPE_NODEID = NodeIdentifier.create(SCOPE_QNAME);
private static final NodeIdentifier OUTPUT_TYPE_NODEID = NodeIdentifier.create(OUTPUT_TYPE_QNAME);
final Scope scope = scopeName != null ? Scope.forName(scopeName).orElseThrow() : Scope.BASE;
return RestconfStreamsConstants.DATA_SUBSCRIPTION
- + "/"
- + ListenersBroker.createStreamNameFromUri(
- ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContext)
- + RestconfStreamsConstants.DS_URI
- + datastoreType
- + RestconfStreamsConstants.SCOPE_URI
- + scope);
+ + "/" + ListenersBroker.createStreamNameFromUri(IdentifierCodec.serialize(path, schemaContext)
+ + "/" + RestconfStreamsConstants.DATASTORE_PARAM_NAME + "=" + datastoreType
+ + "/" + RestconfStreamsConstants.SCOPE_PARAM_NAME + "=" + scope);
}
/**
* are going to be generated.
*/
private static YangInstanceIdentifier preparePath(final ContainerNode data, final QName qualifiedName) {
- final Optional<DataContainerChild> path = data.findChildByArg(
- new NodeIdentifier(QName.create(qualifiedName, RestconfStreamsConstants.STREAM_PATH_PARAM_NAME)));
- Object pathValue = null;
- if (path.isPresent()) {
- pathValue = path.get().body();
- }
+ final Object pathValue = data.findChildByArg(new NodeIdentifier(QName.create(qualifiedName, "path")))
+ .map(DataContainerChild::body)
+ .orElse(null);
if (!(pathValue instanceof YangInstanceIdentifier)) {
LOG.debug("Instance identifier {} was not normalized correctly", qualifiedName);
throw new RestconfDocumentedException(
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
schemaContextRef = schemaContextHandler.get();
// FIXME: this really should be a normal RPC invocation service which has its own interface with JAX-RS
if (SAL_REMOTE_NAMESPACE.equals(namespace)) {
- if (identifier.contains(RestconfStreamsConstants.CREATE_DATA_SUBSCRIPTION)) {
+ if (identifier.contains("create-data-change-event-subscription")) {
response = CreateStreamUtil.createDataChangeNotifiStream(payload, schemaContextRef);
} else {
throw new RestconfDocumentedException("Not supported operation", ErrorType.RPC,
* Constants for streams.
*/
public final class RestconfStreamsConstants {
- public static final String STREAM_PATH_PARAM_NAME = "path";
public static final String DATASTORE_PARAM_NAME = "datastore";
public static final String SCOPE_PARAM_NAME = "scope";
- public static final String OUTPUT_TYPE_PARAM_NAME = "notification-output-type";
-
- public static final String DS_URI = '/' + DATASTORE_PARAM_NAME + '=';
- public static final String SCOPE_URI = '/' + SCOPE_PARAM_NAME + '=';
public static final String DATA_SUBSCRIPTION = "data-change-event-subscription";
- public static final String CREATE_DATA_SUBSCRIPTION = "create-" + DATA_SUBSCRIPTION;
public static final String NOTIFICATION_STREAM = "notification-stream";
- public static final String CREATE_NOTIFICATION_STREAM = "create-" + NOTIFICATION_STREAM;
public static final String STREAMS_PATH = "ietf-restconf-monitoring:restconf-state/streams";
public static final String STREAM_PATH_PART = "/stream=";
public static final String STREAM_ACCESS_PATH_PART = "/access=";
public static final String STREAM_LOCATION_PATH_PART = "/location";
- public static final String DATA_CHANGE_EVENT_STREAM_PATTERN = '/' + DATA_SUBSCRIPTION + "/*";
- public static final String YANG_NOTIFICATION_STREAM_PATTERN = '/' + NOTIFICATION_STREAM + "/*";
-
private RestconfStreamsConstants() {
// Hidden on purpose
}