- Currently local-name of the QName is used as key to the list
of created streams - that is a bug because local-name doesn't
have to be unique in scope of one module or whole schema context.
- This fix puts the whole serialized YIID to DS as stream name.
JIRA: NETCONF-726
Change-Id: I28012a478b958b933af993c2ede5f91c2eb8e211
Signed-off-by: Jaroslav Tóth <jtoth@frinx.io>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*/
abstract class SubscribeToStreamUtil {
/**
*/
abstract class SubscribeToStreamUtil {
/**
- * Implementation of {@link UrlResolver} for Server-sent events.
+ * Implementation of SubscribeToStreamUtil for Server-sent events.
*/
private static final class ServerSentEvents extends SubscribeToStreamUtil {
static final ServerSentEvents INSTANCE = new ServerSentEvents();
*/
private static final class ServerSentEvents extends SubscribeToStreamUtil {
static final ServerSentEvents INSTANCE = new ServerSentEvents();
- * Implementation of {@link UrlResolver} for Web sockets.
+ * Implementation of SubscribeToStreamUtil for Web sockets.
*/
private static final class WebSockets extends SubscribeToStreamUtil {
static final WebSockets INSTANCE = new WebSockets();
*/
private static final class WebSockets extends SubscribeToStreamUtil {
static final WebSockets INSTANCE = new WebSockets();
* @param uriInfo URI information.
* @param notificationQueryParams Query parameters of notification.
* @param handlersHolder Holder of handlers for notifications.
* @param uriInfo URI information.
* @param notificationQueryParams Query parameters of notification.
* @param handlersHolder Holder of handlers for notifications.
- * @param urlResolver Resolver for proper implementation. Possibilities is WS or SSE.
* @return Stream location for listening.
*/
final @NonNull URI subscribeToYangStream(final String identifier, final UriInfo uriInfo,
* @return Stream location for listening.
*/
final @NonNull URI subscribeToYangStream(final String identifier, final UriInfo uriInfo,
final Optional<NotificationListenerAdapter> notificationListenerAdapter =
ListenersBroker.getInstance().getNotificationListenerFor(streamName);
final Optional<NotificationListenerAdapter> notificationListenerAdapter =
ListenersBroker.getInstance().getNotificationListenerFor(streamName);
- if (!notificationListenerAdapter.isPresent()) {
+ if (notificationListenerAdapter.isEmpty()) {
throw new RestconfDocumentedException(String.format(
"Stream with name %s was not found.", streamName),
ErrorType.PROTOCOL,
throw new RestconfDocumentedException(String.format(
"Stream with name %s was not found.", streamName),
ErrorType.PROTOCOL,
final DOMTransactionChain transactionChain = handlersHolder.getTransactionChainHandler().get();
final DOMDataTreeReadWriteTransaction writeTransaction = transactionChain.newReadWriteTransaction();
final EffectiveModelContext schemaContext = handlersHolder.getSchemaHandler().get();
final DOMTransactionChain transactionChain = handlersHolder.getTransactionChainHandler().get();
final DOMDataTreeReadWriteTransaction writeTransaction = transactionChain.newReadWriteTransaction();
final EffectiveModelContext schemaContext = handlersHolder.getSchemaHandler().get();
+ final String serializedPath = IdentifierCodec.serialize(listener.get().getPath(), schemaContext);
final MapEntryNode mapToStreams =
RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(listener.get().getPath(),
notificationQueryParams.getStart(), listener.get().getOutputType(), uri,
final MapEntryNode mapToStreams =
RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(listener.get().getPath(),
notificationQueryParams.getStart(), listener.get().getOutputType(), uri,
- getMonitoringModule(schemaContext), schemaContext);
- writeDataToDS(schemaContext, listener.get().getPath().getLastPathArgument().getNodeType().getLocalName(),
- writeTransaction, mapToStreams);
+ getMonitoringModule(schemaContext), schemaContext, serializedPath);
+ writeDataToDS(schemaContext, serializedPath, writeTransaction, mapToStreams);
submitData(writeTransaction);
transactionChain.close();
return uri;
submitData(writeTransaction);
transactionChain.close();
return uri;
*/
public static MapEntryNode mapDataChangeNotificationStreamByIetfRestconfMonitoring(
final YangInstanceIdentifier path, final Instant start, final String outputType, final URI uri,
*/
public static MapEntryNode mapDataChangeNotificationStreamByIetfRestconfMonitoring(
final YangInstanceIdentifier path, final Instant start, final String outputType, final URI uri,
- final Module monitoringModule, final EffectiveModelContext schemaContext) {
+ final Module monitoringModule, final EffectiveModelContext schemaContext, final String streamName) {
final SchemaNode schemaNode = ParserIdentifier
.toInstanceIdentifier(ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContext),
schemaContext, Optional.empty())
final SchemaNode schemaNode = ParserIdentifier
.toInstanceIdentifier(ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContext),
schemaContext, Optional.empty())
final ListSchemaNode listSchema = (ListSchemaNode) streamListSchema;
prepareLeafAndFillEntryBuilder(streamEntry,
final ListSchemaNode listSchema = (ListSchemaNode) streamListSchema;
prepareLeafAndFillEntryBuilder(streamEntry,
- listSchema.getDataChildByName(MonitoringModule.LEAF_NAME_STREAM_QNAME),
- schemaNode.getQName().getLocalName());
+ listSchema.getDataChildByName(MonitoringModule.LEAF_NAME_STREAM_QNAME), streamName);
final Optional<String> optDesc = schemaNode.getDescription();
if (optDesc.isPresent()) {
final Optional<String> optDesc = schemaNode.getDescription();
if (optDesc.isPresent()) {
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;
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;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
final Map<String, ListenerAdapter> listenersByStreamNameSetter = new HashMap<>();
final ListenerAdapter adapter = mock(ListenerAdapter.class);
final YangInstanceIdentifier yiid = mock(YangInstanceIdentifier.class);
final Map<String, ListenerAdapter> listenersByStreamNameSetter = new HashMap<>();
final ListenerAdapter adapter = mock(ListenerAdapter.class);
final YangInstanceIdentifier yiid = mock(YangInstanceIdentifier.class);
- final YangInstanceIdentifier.PathArgument lastPathArgument = mock(YangInstanceIdentifier.PathArgument.class);
- final QName qname = QName.create("toaster", "2009-11-20", "toasterStatus");
Mockito.when(adapter.getPath()).thenReturn(yiid);
Mockito.when(adapter.getOutputType()).thenReturn("JSON");
Mockito.when(adapter.getPath()).thenReturn(yiid);
Mockito.when(adapter.getOutputType()).thenReturn("JSON");
- Mockito.when(yiid.getLastPathArgument()).thenReturn(lastPathArgument);
- Mockito.when(lastPathArgument.getNodeType()).thenReturn(qname);
listenersByStreamNameSetter.put(
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
adapter);
listenersByStreamNameSetter.put(
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
adapter);
final String outputType = "XML";
final URI uri = new URI("uri");
final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
final String outputType = "XML";
final URI uri = new URI("uri");
final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
+ final String streamName = "/nested-module:depth1-cont/depth2-leaf1";
- final Map<QName, Object> map = prepareMap(path.getLastPathArgument().getNodeType().getLocalName(), uri, start,
- outputType);
-
+ final Map<QName, Object> map = prepareMap(streamName, uri, start, outputType);
final MapEntryNode mappedData = RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(
final MapEntryNode mappedData = RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(
- path, start, outputType, uri, monitoringModule, schemaContextMonitoring);
+ path, start, outputType, uri, monitoringModule, schemaContextMonitoring, streamName);
assertMappedData(map, mappedData);
}
assertMappedData(map, mappedData);
}