* ============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.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;
* @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();
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) {
/**
* 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) {
* @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);
- }
}