1 package org.onap.so.bpmn.infrastructure.pnf.delegate;
3 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
4 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
5 import com.google.common.base.Strings;
6 import org.camunda.bpm.engine.delegate.DelegateExecution;
7 import org.camunda.bpm.engine.delegate.JavaDelegate;
8 import org.onap.so.bpmn.common.scripts.ExceptionUtil;
9 import org.springframework.stereotype.Component;
12 public class AssignPnfInputsCheckerDelegate implements JavaDelegate {
14 public static final String UUID_REGEX =
15 "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$";
18 public void execute(DelegateExecution execution) {
19 validatePnfCorrelationId(execution);
20 validatePnfUuid(execution);
23 private void validatePnfCorrelationId(DelegateExecution execution) {
24 String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID);
25 if (Strings.isNullOrEmpty(pnfCorrelationId)) {
26 new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
27 "pnfCorrelationId variable not defined");
31 private void validatePnfUuid(DelegateExecution execution) {
32 String pnfUuid = (String) execution.getVariable(PNF_UUID);
33 if (Strings.isNullOrEmpty(pnfUuid)) {
34 new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid variable not defined");
36 if (!pnfUuid.matches(UUID_REGEX)) {
37 new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid is not a valid UUID");