X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sdnr%2Fwt%2Fdevicemanager%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Ffeatures%2Fsdnr%2Fwt%2Fdevicemanager%2Fimpl%2FDeviceManagerApiServiceImpl.java;h=6e8d85bda56111614350167a2e2a47e7f30b6ff5;hb=refs%2Fheads%2Fmaster;hp=11fba81f43f2d99133d6c8c8b352854dcc99d250;hpb=1c924ae13ed9a0fc9b6afd4d16b8becdf8d0b44c;p=ccsdk%2Ffeatures.git diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java deleted file mode 100644 index 11fba81f4..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl; - -import java.util.List; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementsListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl; -import org.opendaylight.mdsal.binding.api.RpcProviderService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutput; -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.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; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResult; -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); - - private final ObjectRegistration rpcReg; - private @Nullable - final MaintenanceRPCServiceAPI maintenanceService; - private @Nullable - final PushNotifications pushNotificationsListener; - private @Nullable - final ResyncNetworkElementsListener resyncCallbackListener; - - public DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry, - MaintenanceServiceImpl maintenanceService, ResyncNetworkElementsListener listener, - PushNotifications pushNotificationsListener) { - this.maintenanceService = maintenanceService; - this.pushNotificationsListener = pushNotificationsListener; - this.resyncCallbackListener = listener; - - // Register ourselves as the REST API RPC implementation - LOG.info("Register RPC Service "+DevicemanagerService.class.getSimpleName()); - this.rpcReg = rpcProviderRegistry.registerRpcImplementation(DevicemanagerService.class, this); - } - - @Override - public void close() throws Exception { - LOG.info("Close RPC Service"); - if (rpcReg != null) { - rpcReg.close(); - } - } - - /*------------------------------- - * Interfaces for MaintenanceService - */ - - @Override - public ListenableFuture> getRequiredNetworkElementKeys( - GetRequiredNetworkElementKeysInput input) { - return getRequiredNetworkElementKeys(); - } - - // For casablanca version no input was generated. - public ListenableFuture> getRequiredNetworkElementKeys() { - - LOG.info("RPC Request: getRequiredNetworkElementKeys"); - RpcResultBuilder result; - try { - GetRequiredNetworkElementKeysOutputBuilder outputBuilder = maintenanceService.getRequiredNetworkElementKeys(); - result = RpcResultBuilder.success(outputBuilder); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - } - - @Override - public ListenableFuture> showRequiredNetworkElement( - ShowRequiredNetworkElementInput input) { - - LOG.info("RPC Request: showRequiredNetworkElement input: {}", input.getMountpointName()); - RpcResultBuilder result; - - try { - ShowRequiredNetworkElementOutputBuilder outputBuilder = maintenanceService.showRequiredNetworkElement(input); - result = RpcResultBuilder.success(outputBuilder); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - } - - @Override - public ListenableFuture> setMaintenanceMode(SetMaintenanceModeInput input) { - - LOG.info("RPC Request: setMaintenanceMode input: {}", input.getNodeId()); - RpcResultBuilder result; - - try { - SetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.setMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - - } - - - - @Override - public ListenableFuture> getMaintenanceMode(GetMaintenanceModeInput input) { - - LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName()); - RpcResultBuilder result; - - try { - GetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.getMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - - } - - @Override - public ListenableFuture> testMaintenanceMode(TestMaintenanceModeInput input) { - LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName()); - RpcResultBuilder result; - - try { - TestMaintenanceModeOutputBuilder outputBuilder = maintenanceService.testMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - - } - - - @Override - public ListenableFuture> clearCurrentFaultByNodename( - ClearCurrentFaultByNodenameInput input) { - LOG.info("RPC Request: clearNetworkElementAlarms input: {}", input.getNodenames()); - RpcResultBuilder result; - try { - if(this.resyncCallbackListener!=null) { - List nodeNames= this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames()); - ClearCurrentFaultByNodenameOutputBuilder outputBuilder = new ClearCurrentFaultByNodenameOutputBuilder(); - outputBuilder.setNodenames(nodeNames); - result = RpcResultBuilder.success(outputBuilder); - } else { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Startup running" ); - } - } catch(Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - } - - @Override - public ListenableFuture> pushFaultNotification( - PushFaultNotificationInput input) { - LOG.info("RPC Received fault notification {}", input); - RpcResultBuilder result; - try { - pushNotificationsListener.pushFaultNotification(input); - result = RpcResultBuilder.success(); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - } - - @Override - public ListenableFuture> pushAttributeChangeNotification( - PushAttributeChangeNotificationInput input) { - LOG.info("RPC Received change notification {}", input); - RpcResultBuilder result; - try { - pushNotificationsListener.pushAttributeChangeNotification(input); - result = RpcResultBuilder.success(); - } catch (Exception e) { - result = RpcResultBuilder.failed(); - result.withError(ErrorType.APPLICATION, "Exception", e); - } - return result.buildFuture(); - } - - - -}