X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=nbinotifications%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnbinotifications%2Fserialization%2FNotificationServiceDeserializer.java;h=eab7f3618f9eb031e94a0c789a850f8d2b8d62fc;hb=274148a8d813140f86e1f9770ba992b072c1a5cd;hp=81f02ac9451f230d62e4dfdf127b8c90b339efb8;hpb=1c4b0ba3a2ca77a6acfcd41453b7c9c0f2f2480d;p=transportpce.git diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java index 81f02ac94..eab7f3618 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/serialization/NotificationServiceDeserializer.java @@ -11,17 +11,17 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.kafka.common.serialization.Deserializer; import org.opendaylight.transportpce.common.converter.JsonStringConverter; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.process.service.output.NotificationsProcessServiceBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationServiceDeserializer implements Deserializer { +public class NotificationServiceDeserializer implements Deserializer { private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceDeserializer.class); - private JsonStringConverter converter; + private JsonStringConverter converter; @SuppressWarnings("unchecked") @Override @@ -29,39 +29,38 @@ public class NotificationServiceDeserializer implements Deserializer) { - converter = (JsonStringConverter) configs - .get(ConfigConstants.CONVERTER); + converter = (JsonStringConverter) configs.get(ConfigConstants.CONVERTER); } } @Override - public NotificationService deserialize(String topic, byte[] data) { + public NotificationsProcessService deserialize(String topic, byte[] data) { if (converter == null) { throw new IllegalArgumentException( "Converter should be configured through configure method of deserializer"); } String value = new String(data, StandardCharsets.UTF_8); // The message published is - // org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService + // org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService // we have to map it to // org.opendaylight.yang.gen - // .v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService mappedString = converter - .createDataObjectFromJsonString(YangInstanceIdentifier.of( - org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService.QNAME), - value, - JSONCodecFactorySupplier.RFC7951); - if (mappedString != null) { - LOG.info("Reading event {}", mappedString); - return new NotificationServiceBuilder().setCommonId(mappedString.getCommonId()) - .setConnectionType(mappedString.getConnectionType()).setMessage(mappedString.getMessage()) - .setOperationalState(mappedString.getOperationalState()) - .setResponseFailed(mappedString.getResponseFailed()).setServiceName(mappedString.getServiceName()) - .setServiceAEnd(mappedString.getServiceAEnd()).setServiceZEnd(mappedString.getServiceZEnd()) - .build(); + // .v1.nbi.notifications.rev210813.get.notifications.service.output.NotificationService + NotificationProcessService mappedString = converter.createDataObjectFromJsonString( + YangInstanceIdentifier.of(NotificationProcessService.QNAME), value, JSONCodecFactorySupplier.RFC7951); + if (mappedString == null) { + return null; } - return null; + LOG.info("Reading event {}", mappedString); + return new NotificationsProcessServiceBuilder() + .setCommonId(mappedString.getCommonId()) + .setConnectionType(mappedString.getConnectionType()) + .setMessage(mappedString.getMessage()) + .setOperationalState(mappedString.getOperationalState()) + .setResponseFailed(mappedString.getResponseFailed()) + .setServiceName(mappedString.getServiceName()) + .setServiceAEnd(mappedString.getServiceAEnd()) + .setServiceZEnd(mappedString.getServiceZEnd()) + .build(); } }