Java 17 Upgrade
[policy/models.git] / models-interactions / model-actors / actor.vfc / src / main / java / org / onap / policy / controlloop / actor / vfc / VfcOperation.java
index 0a1136d..a1d4960 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.
@@ -20,9 +21,8 @@
 
 package org.onap.policy.controlloop.actor.vfc;
 
+import jakarta.ws.rs.core.Response;
 import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
@@ -65,7 +65,7 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
      * @param params operation parameters
      * @param config configuration for this operation
      */
-    public VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
+    protected VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
         super(params, config, VfcResponse.class, PROPERTY_NAMES);
 
         setUsePolling();
@@ -82,14 +82,6 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
         return super.getPollingPath() + jobId;
     }
 
-    /**
-     * Starts the GUARD.
-     */
-    @Override
-    protected CompletableFuture<OperationOutcome> startPreprocessorAsync() {
-        return startGuardAsync();
-    }
-
     @Override
     protected Status detmStatus(Response rawResponse, VfcResponse response) {
         if (rawResponse.getStatus() == 200) {
@@ -140,7 +132,7 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
 
     /**
      * Treats everything as a success, so we always go into
-     * {@link #postProcessResponse(OperationOutcome, String, Response, SoResponse)}.
+     * {@link #postProcessResponse (OperationOutcome, String, Response, SoResponse)}.
      */
     @Override
     protected boolean isSuccess(Response rawResponse, VfcResponse response) {
@@ -170,53 +162,35 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
      * @return request
      */
     protected VfcRequest constructVfcRequest() {
-        final String serviceInstance = getOptProperty(OperationProperties.ENRICHMENT_SERVICE_ID,
-                        "service-instance.service-instance-id");
-        final String vmId = getOptProperty(OperationProperties.ENRICHMENT_VSERVER_ID, "vserver.vserver-id");
-        final String vmName = getOptProperty(OperationProperties.ENRICHMENT_VSERVER_NAME, "vserver.vserver-name");
-        final String vnfId = getOptProperty(OperationProperties.ENRICHMENT_GENERIC_VNF_ID, GENERIC_VNF_ID);
+        final String serviceInstance = getProperty(OperationProperties.ENRICHMENT_SERVICE_ID);
+        final String vmId = getProperty(OperationProperties.ENRICHMENT_VSERVER_ID);
+        final String vmName = getProperty(OperationProperties.ENRICHMENT_VSERVER_NAME);
+        final String vnfId = getProperty(OperationProperties.ENRICHMENT_GENERIC_VNF_ID);
 
         if (StringUtils.isBlank(serviceInstance) || StringUtils.isBlank(vmId) || StringUtils.isBlank(vmName)) {
             // original code did not check the VNF id, so we won't check it either
             throw new IllegalArgumentException(
-                            "Cannot extract enrichment data for service instance, server id, or server name.");
+                            "Missing enrichment data for service instance, server id, or server name.");
         }
 
-        VfcHealActionVmInfo vmActionInfo = new VfcHealActionVmInfo();
+        var vmActionInfo = new VfcHealActionVmInfo();
         vmActionInfo.setVmid(vmId);
         vmActionInfo.setVmname(vmName);
 
-        VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams();
+        var additionalParams = new VfcHealAdditionalParams();
         additionalParams.setAction(getName());
         additionalParams.setActionInfo(vmActionInfo);
 
-        VfcHealRequest healRequest = new VfcHealRequest();
+        var healRequest = new VfcHealRequest();
         healRequest.setVnfInstanceId(vnfId);
         healRequest.setCause(getName());
         healRequest.setAdditionalParams(additionalParams);
 
-        VfcRequest request = new VfcRequest();
+        var request = new VfcRequest();
         request.setHealRequest(healRequest);
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(params.getRequestId());
 
         return request;
     }
-
-    /**
-     * Gets an optional property, first checking the properties, then checking the
-     * enrichment data.
-     *
-     * @param propName property name
-     * @param enrichmentName property name within the enrichment data
-     * @return the property's value, or {@code null} if it is not found
-     */
-    protected String getOptProperty(String propName, String enrichmentName) {
-        if (containsProperty(propName)) {
-            // return the value, even if it's null
-            return getProperty(propName);
-        }
-
-        return params.getContext().getEnrichment().get(enrichmentName);
-    }
 }