summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/java
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2018-12-05 10:38:39 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2018-12-18 12:03:38 +0100
commit522bb0f585c7248a99c26cc10a5bbc0954e27e82 (patch)
tree9440bb69ac37f96b657d90d4f91059bba0c493e5 /bpmn/so-bpmn-infrastructure-common/src/main/java
parent090cb77be5c347cc764920fea491a149b5380bcf (diff)
Use UUID to fill pnf-id in PNF PnP
Issue-ID: SO-1272 Change-Id: If516b7ec38dad3fbc7409aff42275a98ef2af76b Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/java')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java (renamed from bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java)15
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java43
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java31
4 files changed, 85 insertions, 7 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java
index a8754cd4a0..12cb6ffdff 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -21,23 +23,28 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.onap.aai.domain.yang.Pnf;
import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
- * Implementation of "Create AAI entry with pnf-id = correlation_id" task in CreateAndActivatePnfResource.bpmn
+ * Implementation of "Create Pnf entry in AAI" task in CreateAndActivatePnfResource.bpmn
*
* Inputs:
* - correlationId - String
+ * - pnfUuid - String
*/
@Component
-public class CreateAaiEntryWithPnfIdDelegate implements JavaDelegate {
+public class CreatePnfEntryInAaiDelegate implements JavaDelegate {
+ private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAaiDelegate.class);
private AaiConnection aaiConnection;
@Autowired
@@ -48,10 +55,12 @@ public class CreateAaiEntryWithPnfIdDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
String correlationId = (String) execution.getVariable(CORRELATION_ID);
+ String pnfUuid = (String) execution.getVariable(PNF_UUID);
Pnf pnf = new Pnf();
pnf.setInMaint(true);
- pnf.setPnfId(correlationId);
+ pnf.setPnfId(pnfUuid);
pnf.setPnfName(correlationId);
aaiConnection.createEntry(correlationId, pnf);
+ logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", correlationId, pnfUuid);
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index b3f2f726a0..1407cb9211 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -30,4 +32,5 @@ public class ExecutionVariableNames {
public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp";
public final static String DMAAP_MESSAGE = "dmaapMessage";
public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification";
+ public final static String PNF_UUID = "pnfUuid";
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java
new file mode 100644
index 0000000000..f5483e489e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegate.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+
+import java.util.UUID;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GeneratePnfUuidDelegate implements JavaDelegate {
+
+ private static final Logger logger = LoggerFactory.getLogger(GeneratePnfUuidDelegate.class);
+
+ @Override
+ public void execute(DelegateExecution delegateExecution){
+ UUID uuid = UUID.randomUUID();
+ logger.debug("Generated UUID for pnf: {}, version: {}, variant: {}", uuid, uuid.version(), uuid.variant());
+ delegateExecution.setVariable(PNF_UUID, uuid.toString());
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
index 164f51f579..c1ddf2e04e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -21,8 +23,10 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+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;
@@ -34,6 +38,7 @@ import org.springframework.stereotype.Component;
@Component
public class PnfCheckInputs 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}$";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, PnfCheckInputs.class);
private String defaultTimeout;
@@ -45,19 +50,37 @@ public class PnfCheckInputs implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) {
+ validateCorrelationId(execution);
+ validatePnfUuid(execution);
+ validateTimeout(execution);
+ }
+
+ private void validateCorrelationId(DelegateExecution execution) {
String correlationId = (String) execution.getVariable(CORRELATION_ID);
- if (correlationId == null) {
+ if (Strings.isNullOrEmpty(correlationId)) {
new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId 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");
+ }
+ }
+
+ private void validateTimeout(DelegateExecution execution) {
String timeout = (String) execution.getVariable(TIMEOUT_FOR_NOTIFICATION);
- if (timeout == null) {
+ if (Strings.isNullOrEmpty(timeout)) {
LOGGER.debug("timeoutForPnfEntryNotification variable not found, setting default");
if (defaultTimeout == null) {
new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
- "default timeoutForPnfEntryNotification value not defined");
+ "default timeoutForPnfEntryNotification value not defined");
}
execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);
}
}
-
}