Extend SDNC persistent service to store CM
[ccsdk/features.git] / sdnr / wt / devicemanager-core / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / impl / DeviceManagerApiServiceImpl.java
index 266bb04..e31b79a 100644 (file)
@@ -4,6 +4,8 @@
  * =================================================================================================
  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
  * =================================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
+ * =================================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  *
@@ -17,6 +19,7 @@
  */
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
 import org.eclipse.jdt.annotation.Nullable;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementsListener;
@@ -35,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeInput;
@@ -53,8 +58,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(DevicemanagerService.class);
@@ -219,6 +222,20 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl
         return result.buildFuture();
     }
 
+    @Override
+    public ListenableFuture<RpcResult<PushCmNotificationOutput>> pushCmNotification(PushCmNotificationInput input) {
+        LOG.info("RPC Received CM notification {}", input);
+        RpcResultBuilder<PushCmNotificationOutput> result;
+        try {
+            pushNotificationsListener.pushCMNotification(input);
+            result = RpcResultBuilder.success();
+        } catch (Exception e) {
+            result = RpcResultBuilder.failed();
+            result.withError(ErrorType.APPLICATION, "Exception", e);
+        }
+        return result.buildFuture();
+    }
+
     @Override
     public ListenableFuture<RpcResult<PushAttributeChangeNotificationOutput>> pushAttributeChangeNotification(
             PushAttributeChangeNotificationInput input) {