Moving common polling code into HttpOperation
[policy/models.git] / models-interactions / model-actors / actor.so / src / main / java / org / onap / policy / controlloop / actor / so / VfModuleDelete.java
index 9dbdc58..c67243f 100644 (file)
@@ -47,12 +47,13 @@ import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
 import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
 import org.onap.policy.so.SoModelInfo;
 import org.onap.policy.so.SoOperationType;
 import org.onap.policy.so.SoRequest;
 import org.onap.policy.so.SoRequestDetails;
+import org.onap.policy.so.SoResponse;
 
 /**
  * Operation to delete a VF Module. This gets the VF count from the A&AI Custom Query
@@ -71,7 +72,7 @@ public class VfModuleDelete extends SoOperation {
      * @param params operation parameters
      * @param config configuration for this operation
      */
-    public VfModuleDelete(ControlLoopOperationParams params, HttpConfig config) {
+    public VfModuleDelete(ControlLoopOperationParams params, HttpPollingConfig config) {
         super(params, config);
 
         // ensure we have the necessary parameters
@@ -111,7 +112,7 @@ public class VfModuleDelete extends SoOperation {
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
 
         // starting a whole new attempt - reset the count
-        resetGetCount();
+        resetPollCount();
 
         Pair<String, SoRequest> pair = makeRequest();
         SoRequest request = pair.getRight();
@@ -203,12 +204,20 @@ public class VfModuleDelete extends SoOperation {
         return builder.header("Authorization", "Basic " + encoded);
     }
 
+
     /**
-     * Decrements the VF count that's stored in the context.
+     * Decrements the VF count that's stored in the context, if the request was
+     * successful.
      */
     @Override
-    protected void successfulCompletion() {
-        setVfCount(getVfCount() - 1);
+    protected Status detmStatus(Response rawResponse, SoResponse response) {
+        Status status = super.detmStatus(rawResponse, response);
+
+        if (status == Status.SUCCESS) {
+            setVfCount(getVfCount() - 1);
+        }
+
+        return status;
     }
 
     /**