summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-12-20 09:42:36 +0000
committerGerrit Code Review <gerrit@onap.org>2019-12-20 09:42:36 +0000
commit8a3fb63de2bdf40bbf33119854d432693c2ff2e4 (patch)
tree70e529ae7db8a6a80b16a7e4115bb70ca6b4da18 /bpmn/so-bpmn-infrastructure-common/src/main
parent44cb5d927a9730c28807557360bad0e61ef4b626 (diff)
parent6939ace38f276b40b7c07be18450604c5a469607 (diff)
Merge "Externalize AssignPnf Building Block and refactor existing code accordingly"
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java
new file mode 100644
index 0000000000..9176948288
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java
@@ -0,0 +1,40 @@
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import com.google.common.base.Strings;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AssignPnfInputsCheckerDelegate implements JavaDelegate {
+
+ public static final String UUID_REGEX =
+ "(?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}$";
+
+ @Override
+ public void execute(DelegateExecution execution) {
+ validatePnfCorrelationId(execution);
+ validatePnfUuid(execution);
+ }
+
+ private void validatePnfCorrelationId(DelegateExecution execution) {
+ String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID);
+ if (Strings.isNullOrEmpty(pnfCorrelationId)) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
+ "pnfCorrelationId variable not defined");
+ }
+ }
+
+ private void validatePnfUuid(DelegateExecution execution) {
+ String pnfUuid = (String) execution.getVariable(PNF_UUID);
+ if (Strings.isNullOrEmpty(pnfUuid)) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid variable not defined");
+ }
+ if (!pnfUuid.matches(UUID_REGEX)) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid is not a valid UUID");
+ }
+ }
+}