import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Struct;
import com.google.protobuf.Struct.Builder;
import com.google.protobuf.util.JsonFormat;
-
import io.grpc.Status;
/**
private ExceptionBuilder exceptionUtil;
/**
- * Extracting data from execution object and building the ExecutionServiceInput
- * Object
+ * Extracting data from execution object and building the ExecutionServiceInput Object
*
- * @param execution
- * DelegateExecution object
+ * @param execution DelegateExecution object
*/
public void constructExecutionServiceInputObject(DelegateExecution execution) {
logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest ");
try {
- AbstractCDSPropertiesBean executionObject = (AbstractCDSPropertiesBean) execution
- .getVariable("executionObject");
+ AbstractCDSPropertiesBean executionObject =
+ (AbstractCDSPropertiesBean) execution.getVariable("executionObject");
String payload = executionObject.getRequestObject();
CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(executionObject.getOriginatorId())
.setRequestId(executionObject.getRequestId()).setSubRequestId(executionObject.getSubRequestId())
.build();
- ActionIdentifiers actionIdentifiers = ActionIdentifiers.newBuilder()
- .setBlueprintName(executionObject.getBlueprintName())
- .setBlueprintVersion(executionObject.getBlueprintVersion())
- .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build();
+ ActionIdentifiers actionIdentifiers =
+ ActionIdentifiers.newBuilder().setBlueprintName(executionObject.getBlueprintName())
+ .setBlueprintVersion(executionObject.getBlueprintVersion())
+ .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build();
Builder struct = Struct.newBuilder();
try {
executionObject.getActionName(), e);
}
- ExecutionServiceInput executionServiceInput = ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader).setActionIdentifiers(actionIdentifiers).setPayload(struct.build())
- .build();
+ ExecutionServiceInput executionServiceInput =
+ ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifiers).setPayload(struct.build()).build();
execution.setVariable("executionServiceInput", executionServiceInput);
}
/**
- * get the executionServiceInput object from execution and send a request to CDS
- * Client and wait for TIMEOUT period
+ * get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period
*
- * @param execution
- * DelegateExecution object
+ * @param execution DelegateExecution object
*/
public void sendRequestToCDSClient(DelegateExecution execution) {
"No RestProperty.CDSProperties implementation found on classpath, can't create client.");
}
- ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution
- .getVariable("executionServiceInput");
+ ExecutionServiceInput executionServiceInput =
+ (ExecutionServiceInput) execution.getVariable("executionServiceInput");
- try(CDSProcessingClient cdsClient = new CDSProcessingClient(this)) {
+ try (CDSProcessingClient cdsClient = new CDSProcessingClient(this)) {
CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
- } catch (InterruptedException ex){
+ } catch (InterruptedException ex) {
logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
Thread.currentThread().interrupt();
}
switch (eventType) {
- case EVENT_COMPONENT_FAILURE:
- // failed processing with failure
- cdsResponse.set(FAILED);
- break;
- case EVENT_COMPONENT_PROCESSING:
- // still processing
- cdsResponse.set(PROCESSING);
- break;
- case EVENT_COMPONENT_EXECUTED:
- // done with async processing
- cdsResponse.set(SUCCESS);
- break;
- default:
- cdsResponse.set(FAILED);
- break;
+ case EVENT_COMPONENT_FAILURE:
+ // failed processing with failure
+ cdsResponse.set(FAILED);
+ break;
+ case EVENT_COMPONENT_PROCESSING:
+ // still processing
+ cdsResponse.set(PROCESSING);
+ break;
+ case EVENT_COMPONENT_EXECUTED:
+ // done with async processing
+ cdsResponse.set(SUCCESS);
+ break;
+ default:
+ cdsResponse.set(FAILED);
+ break;
}
}