- RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
- listener.getSchemaPath().getLastComponent(), schemaContext.getNotifications(), null,
- listener.getOutputType(), uri, SubscribeToStreamUtil.getMonitoringModule(schemaContext), exist);
- SubscribeToStreamUtil.writeDataToDS(schemaContext,
- listener.getSchemaPath().getLastComponent().getLocalName(), readWriteTransaction, exist, mapToStreams);
+ RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
+ listener.getSchemaPath().getLastComponent(), schemaContext.getNotifications(), null,
+ listener.getOutputType(), uri, SubscribeToStreamUtil.getMonitoringModule(schemaContext), exist);
+ writeDataToDS(schemaContext,
+ listener.getSchemaPath().getLastComponent().getLocalName(), strategy, exist, mapToStreams);
+ }
+
+ private static boolean checkExist(final EffectiveModelContext schemaContext, final RestconfStrategy strategy) {
+ try {
+ return strategy.exists(LogicalDatastoreType.OPERATIONAL,
+ IdentifierCodec.deserialize(Rfc8040.MonitoringModule.PATH_TO_STREAMS, schemaContext)).get();
+ } catch (final InterruptedException | ExecutionException exception) {
+ throw new RestconfDocumentedException("Problem while checking data if exists", exception);
+ }
+ }
+
+ private static void writeDataToDS(final EffectiveModelContext schemaContext, final String name,
+ final RestconfStrategy strategy, final boolean exist,
+ final NormalizedNode mapToStreams) {
+ String pathId;
+ if (exist) {
+ pathId = Rfc8040.MonitoringModule.PATH_TO_STREAM_WITHOUT_KEY + name;
+ } else {
+ pathId = Rfc8040.MonitoringModule.PATH_TO_STREAMS;
+ }
+ strategy.merge(LogicalDatastoreType.OPERATIONAL,
+ IdentifierCodec.deserialize(pathId, schemaContext), mapToStreams);