Java 17 Upgrade
[policy/models.git] / models-interactions / model-actors / actor.so / src / main / java / org / onap / policy / controlloop / actor / so / VfModuleDelete.java
index 9adb62c..8076fbc 100644 (file)
@@ -2,8 +2,9 @@
  * ============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) 2020 Wipro Limited.
+ * 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.
@@ -21,6 +22,9 @@
 
 package org.onap.policy.controlloop.actor.so;
 
+import jakarta.ws.rs.client.InvocationCallback;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
 import java.net.URI;
 import java.net.http.HttpRequest;
 import java.net.http.HttpRequest.BodyPublishers;
@@ -33,15 +37,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.CompletableFuture;
-import javax.ws.rs.client.InvocationCallback;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
-import org.onap.aai.domain.yang.CloudRegion;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.Tenant;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
@@ -50,7 +47,6 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
 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;
@@ -129,7 +125,7 @@ public class VfModuleDelete extends SoOperation {
 
         final String url = getClient().getBaseUrl() + uri;
 
-        Builder builder = HttpRequest.newBuilder(URI.create(url));
+        var builder = HttpRequest.newBuilder(URI.create(url));
         builder = builder.header("Content-type", contentType);
         builder = addAuthHeader(builder);
 
@@ -191,7 +187,7 @@ public class VfModuleDelete extends SoOperation {
      */
     @Override
     protected Status detmStatus(Response rawResponse, SoResponse response) {
-        Status status = super.detmStatus(rawResponse, response);
+        var status = super.detmStatus(rawResponse, response);
 
         if (status == Status.SUCCESS) {
             setVfCount(getVfCount() - 1);
@@ -206,20 +202,20 @@ public class VfModuleDelete extends SoOperation {
      * @return a pair containing the request URL and the new request
      */
     protected Pair<String, SoRequest> makeRequest() {
-        final SoModelInfo soModelInfo = prepareSoModelInfo();
-        final GenericVnf vnfItem = getVnfItem(soModelInfo);
-        final ServiceInstance vnfServiceItem = getServiceInstance();
-        final Tenant tenantItem = getDefaultTenant();
-        final CloudRegion cloudRegionItem = getDefaultCloudRegion();
+        final var soModelInfo = prepareSoModelInfo();
+        final var vnfItem = getVnfItem();
+        final var vnfServiceItem = getServiceInstance();
+        final var tenantItem = getDefaultTenant();
+        final var cloudRegionItem = getDefaultCloudRegion();
 
-        SoRequest request = new SoRequest();
+        var request = new SoRequest();
         request.setOperationType(SoOperationType.DELETE_VF_MODULE);
 
         //
         //
         // Do NOT send SO the requestId, they do not support this field
         //
-        SoRequestDetails details = new SoRequestDetails();
+        var details = new SoRequestDetails();
         request.setRequestDetails(details);
         details.setRelatedInstanceList(null);
         details.setConfigurationParameters(null);
@@ -239,8 +235,8 @@ public class VfModuleDelete extends SoOperation {
          */
 
         // compute the path
-        String path = PATH_PREFIX + vnfServiceItem.getServiceInstanceId() + "/vnfs/" + vnfItem.getVnfId()
-                        + "/vfModules/null";
+        String svcId = getRequiredText("service instance ID", vnfServiceItem.getServiceInstanceId());
+        String path = PATH_PREFIX + svcId + "/vnfs/" + vnfItem.getVnfId() + "/vfModules/null";
 
         return Pair.of(path, request);
     }