lower code smells
[appc.git] / appc-oam / appc-oam-bundle / src / main / java / org / onap / appc / oam / AppcOam.java
index 9793833..1f7c989 100644 (file)
@@ -2,9 +2,11 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications (C) 2018 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +20,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  * ============LICENSE_END=========================================================
  */
 
@@ -27,14 +28,17 @@ package org.onap.appc.oam;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.AppcOamService;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.AppcState;
+import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateInput;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateOutput;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetAppcStateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsInput;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsOutput;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.GetMetricsOutputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.appc.oam.rev170303.MaintenanceModeInput;
@@ -76,7 +80,6 @@ import org.onap.appc.statemachine.impl.readers.AppcOamMetaDataReader.AppcOperati
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Future;
 
 /**
  * RPC class of APP-C OAM API.
@@ -87,7 +90,7 @@ public class AppcOam implements AutoCloseable, AppcOamService {
     /**
      * Invalid state message format with fliexible operation, appc name and state values
      */
-    public final static String INVALID_STATE_MESSAGE_FORMAT = "%s API is not allowed when %s is in the %s state.";
+    public static final String INVALID_STATE_MESSAGE_FORMAT = "%s API is not allowed when %s is in the %s state.";
 
     private final EELFLogger logger = EELFManager.getInstance().getLogger(AppcOam.class);
 
@@ -132,13 +135,13 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      *                                    and also provides the ability to subscribe for changes to data under a
      *                                    given branch
      *                                    of the tree. Not used in this class.
-     * @param notificationProviderService object of ODL Notification Service that provides publish/subscribe
+     * @param notificationPublishService object of ODL Notification Service that provides publish/subscribe
      *                                    capabilities for YANG modeled notifications. Not used in this class.
      * @param rpcProviderRegistry         object of RpcProviderResigstry. Used to register our RPCs.
      */
     @SuppressWarnings({"unused", "nls"})
     public AppcOam(DataBroker dataBroker,
-                   NotificationProviderService notificationProviderService,
+                   NotificationPublishService notificationPublishService,
                    RpcProviderRegistry rpcProviderRegistry) {
 
         configurationHelper = new ConfigurationHelper(logger);
@@ -190,7 +193,7 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<GetMetricsOutput>> getMetrics() {
+    public ListenableFuture<RpcResult<GetMetricsOutput>> getMetrics(GetMetricsInput getMetricsInput) {
 
         if (!isMetricEnabled) {
             logger.error("Metric Service not enabled returning failure");
@@ -255,12 +258,12 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<StopOutput>> stop(StopInput stopInput) {
+    public ListenableFuture<RpcResult<StopOutput>> stop(StopInput stopInput) {
         logger.debug("Entering Stop with Input : " + stopInput);
         final CommonHeader commonHeader = stopInput.getCommonHeader();
 
         OamStopProcessor oamStopProcessor =
-                new OamStopProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+                getOamStopProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
         Status status = oamStopProcessor.processRequest(stopInput);
 
         StopOutputBuilder stopOutputBuilder = new StopOutputBuilder();
@@ -273,12 +276,12 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<RestartOutput>> restart(RestartInput input) {
+    public ListenableFuture<RpcResult<RestartOutput>> restart(RestartInput input) {
         logger.debug("Entering restart with Input : " + input);
         final CommonHeader commonHeader = input.getCommonHeader();
 
         OamRestartProcessor oamRestartProcessor =
-                new OamRestartProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+                getOamRestartProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
         Status status = oamRestartProcessor.processRequest(input);
 
         RestartOutputBuilder restartOutputBuilder = new RestartOutputBuilder();
@@ -292,12 +295,12 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<MaintenanceModeOutput>> maintenanceMode(MaintenanceModeInput maintenanceModeInput) {
+    public ListenableFuture<RpcResult<MaintenanceModeOutput>> maintenanceMode(MaintenanceModeInput maintenanceModeInput) {
         logger.debug("Entering MaintenanceMode with Input : " + maintenanceModeInput);
         final CommonHeader commonHeader = maintenanceModeInput.getCommonHeader();
 
         OamMmodeProcessor oamMmodeProcessor =
-                new OamMmodeProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+                getOamMmodeProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
         Status status = oamMmodeProcessor.processRequest(maintenanceModeInput);
 
         MaintenanceModeOutputBuilder maintenanceModeOutputBuilder = new MaintenanceModeOutputBuilder();
@@ -310,7 +313,7 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<GetAppcStateOutput>> getAppcState() {
+    public ListenableFuture<RpcResult<GetAppcStateOutput>> getAppcState(GetAppcStateInput getAppcStateInput) {
         AppcState appcState = stateHelper.getCurrentOamYangState();
 
         GetAppcStateOutputBuilder builder = new GetAppcStateOutputBuilder();
@@ -322,12 +325,12 @@ public class AppcOam implements AutoCloseable, AppcOamService {
      * {@inheritDoc}
      */
     @Override
-    public Future<RpcResult<StartOutput>> start(StartInput startInput) {
+    public ListenableFuture<RpcResult<StartOutput>> start(StartInput startInput) {
         logger.debug("Input received : " + startInput);
         final CommonHeader commonHeader = startInput.getCommonHeader();
 
         OamStartProcessor oamStartProcessor =
-                new OamStartProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+                getOamStartProcessor(logger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
         Status status = oamStartProcessor.processRequest(startInput);
 
         StartOutputBuilder startOutputBuilder = new StartOutputBuilder();
@@ -336,4 +339,36 @@ public class AppcOam implements AutoCloseable, AppcOamService {
         StartOutput startOutput = startOutputBuilder.build();
         return RpcResultBuilder.success(startOutput).buildFuture();
     }
+
+    protected OamStartProcessor getOamStartProcessor(EELFLogger eelfLogger,
+            ConfigurationHelper configurationHelper,
+            StateHelper stateHelper,
+            AsyncTaskHelper asyncTaskHelper,
+            OperationHelper operationHelper) {
+        return new OamStartProcessor(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+    }
+
+    protected OamStopProcessor getOamStopProcessor(EELFLogger eelfLogger,
+            ConfigurationHelper configurationHelper,
+            StateHelper stateHelper,
+            AsyncTaskHelper asyncTaskHelper,
+            OperationHelper operationHelper) {
+        return new OamStopProcessor(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+    }
+
+    protected OamRestartProcessor getOamRestartProcessor(EELFLogger eelfLogger,
+            ConfigurationHelper configurationHelper,
+            StateHelper stateHelper,
+            AsyncTaskHelper asyncTaskHelper,
+            OperationHelper operationHelper) {
+        return new OamRestartProcessor(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+    }
+
+    protected OamMmodeProcessor getOamMmodeProcessor(EELFLogger eelfLogger,
+            ConfigurationHelper configurationHelper,
+            StateHelper stateHelper,
+            AsyncTaskHelper asyncTaskHelper,
+            OperationHelper operationHelper) {
+        return new OamMmodeProcessor(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
+    }
 }