diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-08-02 10:42:37 +0530 |
---|---|---|
committer | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-08-02 11:30:40 +0530 |
commit | 191ddbe36e3ff1bbc6e9e104a8d3626f70d49ac4 (patch) | |
tree | 7910c13eab225c9650a692c30d96c75ca45463ee /sdnr/wt/websocketmanager/provider/src/main | |
parent | 0b829aa95b44134cd0b5574d32d8275fdb6b2c55 (diff) |
Update websocketmanager's NotificationOutput interface
Use new NotificationOutput interface
Issue-ID: CCSDK-3407
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: Ie6c6acfe1a86c76f7ede50cdce85b4a1b99d63d1
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/websocketmanager/provider/src/main')
2 files changed, 25 insertions, 18 deletions
diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java index 610001775..8af5cb1ee 100644 --- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java +++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerProvider.java @@ -20,6 +20,7 @@ package org.onap.ccsdk.features.sdnr.wt.websocketmanager; import java.time.Instant; import javax.servlet.ServletException; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.DOMNotificationOutput; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput; import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper; import org.opendaylight.mdsal.dom.api.DOMNotification; @@ -83,31 +84,30 @@ public class WebSocketManagerProvider implements WebsocketManagerService, AutoCl this.wsServlet = wsServlet; } - - @Override - public void sendNotification(Notification notification, NodeId nodeId, QName eventType) { - if(!assertNotificationType(notification, eventType)){ - return; - } - this.sendNotification(notification, nodeId, eventType, YangToolsMapperHelper.getTime(notification,Instant.now())); - } - public static boolean assertNotificationType(Notification notification, QName eventType) { final String yangTypeName = eventType.getLocalName(); final Class<?> cls = notification.getClass(); final String clsNameToTest = YangToolsMapperHelper.toCamelCaseClassName(yangTypeName); - if(cls.getSimpleName().equals(clsNameToTest)) { + if (cls.getSimpleName().equals(clsNameToTest)) { return true; } Class<?>[] ifs = cls.getInterfaces(); - for(Class<?> clsif:ifs) { - if(clsif.getSimpleName().equals(clsNameToTest)) { + for (Class<?> clsif : ifs) { + if (clsif.getSimpleName().equals(clsNameToTest)) { return true; } } return false; } + @Override + public void sendNotification(Notification notification, NodeId nodeId, QName eventType) { + if (!assertNotificationType(notification, eventType)) { + return; + } + this.sendNotification(notification, nodeId, eventType, + YangToolsMapperHelper.getTime(notification, Instant.now())); + } @Override public void sendNotification(Notification notification, NodeId nodeId, QName eventType, DateAndTime eventTime) { @@ -117,14 +117,14 @@ public class WebSocketManagerProvider implements WebsocketManagerService, AutoCl @Override public void sendNotification(DOMNotification notification, NodeId nodeId, QName eventType) { - LOG.warn("not yet implemented"); - + WebSocketManagerSocket.broadCast(new DOMNotificationOutput(notification, nodeId.getValue(), eventType, + YangToolsMapperHelper.getTime(notification, Instant.now()))); } @Override public void sendNotification(DOMNotification notification, NodeId nodeId, QName eventType, DateAndTime eventTime) { - LOG.warn("not yet implemented"); - + WebSocketManagerSocket + .broadCast(new DOMNotificationOutput(notification, nodeId.getValue(), eventType, eventTime)); } } diff --git a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java index a642bda69..7c12c4baa 100644 --- a/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java +++ b/sdnr/wt/websocketmanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/WebSocketManagerSocket.java @@ -33,6 +33,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.DOMNotificationOutput; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.INotificationOutput; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.NotificationOutput; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.ReducedSchemaInfo; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data.ScopeRegistration; @@ -247,7 +249,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter { return this.myUniqueSessionId; } - private void sendToAll(NotificationOutput output) { + private void sendToAll(INotificationOutput output) { try { sendToAll(output.getNodeId(), output.getType(), mapper.writeValueAsString(output)); } catch (JsonProcessingException e) { @@ -281,7 +283,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter { } } - public static void broadCast(NotificationOutput output) { + public static void broadCast(INotificationOutput output) { if (clientList.size() > 0) { Set<Entry<String, WebSocketManagerSocket>> e = clientList.entrySet(); WebSocketManagerSocket s = e.iterator().next().getValue(); @@ -291,4 +293,9 @@ public class WebSocketManagerSocket extends WebSocketAdapter { } } + public static void broadCast(DOMNotificationOutput domNotificationOutput) { + // TODO Auto-generated method stub + + } + } |