Java 17 Upgrade
[policy/models.git] / models-interactions / model-actors / actor.vfc / src / main / java / org / onap / policy / controlloop / actor / vfc / Restart.java
index 2c5cf8e..76dd1db 100644 (file)
@@ -2,7 +2,8 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.controlloop.actor.vfc;
 
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.MediaType;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
@@ -30,7 +32,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
 import org.onap.policy.vfc.VfcRequest;
 
 public class Restart extends VfcOperation {
-    public static final String NAME = "VF Module Create";
+    public static final String NAME = "Restart";
 
     public Restart(ControlLoopOperationParams params, HttpConfig config) {
         super(params, config);
@@ -40,14 +42,17 @@ public class Restart extends VfcOperation {
     protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
 
         // starting a whole new attempt - reset the count
-        resetGetCount();
+        resetPollCount();
 
         Pair<String, VfcRequest> pair = makeRequest();
         Entity<VfcRequest> entity = Entity.entity(pair.getRight(), MediaType.APPLICATION_JSON);
         String path = getPath() + pair.getLeft();
         String url = getClient().getBaseUrl() + path;
 
-        return handleResponse(outcome, url, callback -> getClient().post(callback, path, entity, null));
+        Map<String, Object> headers = makeHeaders();
+        headers.put("Accept", MediaType.APPLICATION_JSON);
+
+        return handleResponse(outcome, url, callback -> getClient().post(callback, path, entity, headers));
     }
 
     /**
@@ -57,8 +62,8 @@ public class Restart extends VfcOperation {
      */
     protected Pair<String, VfcRequest> makeRequest() {
 
-        VfcRequest request = super.constructVfcRequest();
-        String requestUrl = "/ns/" + request.getNsInstanceId() + "/heal";
+        var request = super.constructVfcRequest();
+        String requestUrl = "/" + request.getNsInstanceId() + "/heal";
         return Pair.of(requestUrl, request);
     }
 }