aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-09-16 14:28:26 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-16 14:28:26 +0000
commit6b0ce265b86a8c4e7f5c572229d2559124c56a82 (patch)
treebf81f2f7e9d4a191262c5d8626754bcd085be01c /bpmn/MSOCommonBPMN
parent893279c1c447cf5b61b821d4f28b0f9c57cbbfc8 (diff)
parent521f95dfd4328eeb4c1634317ed33888ba7cc5a0 (diff)
Merge "Implement subprocess for calling SDNR from RAN NSSMF -Also added common methods in oofUtils"
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy80
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java62
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java76
3 files changed, 217 insertions, 1 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 2c96e7d3bb..040fc26f23 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -42,6 +42,7 @@ import org.onap.so.db.catalog.beans.CloudSite
import org.onap.so.db.catalog.beans.HomingInstance
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import com.google.gson.JsonObject
import com.fasterxml.jackson.databind.ObjectMapper
@@ -571,5 +572,82 @@ class OofUtils {
response.append("\n }\n")
return response.toString()
}
-
+/**
+* Method to create select NSSI request
+* @param requestId - mso-request-id
+* @param messageType - Message type for callback correlation
+* @param UUID - UUID of NSST
+* @param invariantUUID - Invariant UUID of NSST
+* @param name - name of the NSST model
+* @param profileInfo - A JSON object containing slice profile parameters
+* @return
+*/
+public String buildSelectNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID,
+String name, Map<String, Object> profileInfo){
+
+def transactionId = requestId
+logger.debug( "transactionId is: " + transactionId)
+String correlator = requestId
+String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
+ObjectMapper objectMapper = new ObjectMapper();
+String profileJson = objectMapper.writeValueAsString(profileInfo);
+
+//Prepare requestInfo object
+JsonObject requestInfo = new JsonObject()
+requestInfo.addProperty("transactionId", transactionId)
+requestInfo.addProperty("requestId", requestId)
+requestInfo.addProperty("callbackUrl", callbackUrl)
+requestInfo.addProperty("sourceId","SO" )
+requestInfo.addProperty("timeout", 600)
+requestInfo.addProperty("numSolutions", 1)
+
+//Prepare serviceInfo object
+JsonObject nsstInfo = new JsonObject()
+nsstInfo.addProperty("UUID", UUID)
+nsstInfo.addProperty("invariantUUID", invariantUUID)
+nsstInfo.addProperty("name", name)
+
+JsonObject json = new JsonObject()
+json.add("requestInfo", requestInfo)
+json.add("NSSTInfo", nsstInfo)
+json.addProperty("sliceProfile", profileJson)
+return json.toString()
+}
+/**
+* Method to create NSI/NSSI termination request
+* (OOF response will be synchronous in G-Release)
+* @param requestId - mso-request-id
+* @param nxlId - NSI/NSSI Id to be terminated
+* @param messageType - Message type for callback correlation
+* @param serviceInstanceId - NSI/NSSI Id related to nxlId
+* @return
+*/
+public String buildTerminateNxiRequest(String requestId,String nxlId, String nxlType, String messageType, String serviceInstanceId) {
+def transactionId = requestId
+logger.debug( "transactionId is: " + transactionId)
+String correlator = requestId
+String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
+//Prepare Terminate Nxl Json
+JsonObject json = new JsonObject()
+json.addProperty("type", nxlType)
+json.addProperty("NxIId", nxlId)
+
+//Prepare requestInfo object
+JsonObject requestInfo = new JsonObject()
+requestInfo.addProperty("transactionId", transactionId)
+requestInfo.addProperty("requestId", requestId)
+requestInfo.addProperty("callbackUrl", callbackUrl)
+requestInfo.addProperty("sourceId","SO" )
+requestInfo.addProperty("timeout", 600)
+
+//Prepare addtnlArgs object
+JsonObject addtnlArgs = new JsonObject()
+addtnlArgs.addProperty("serviceInstanceId", serviceInstanceId)
+
+requestInfo.add("addtnlArgs", addtnlArgs)
+json.add("requestInfo", requestInfo)
+
+return json.toString()
+
+}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java
new file mode 100644
index 0000000000..0f35b38f72
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/SdnrDmaapPublisher.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * 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.client.dmaapproperties;
+
+import java.io.IOException;
+import java.util.Optional;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.dmaap.DmaapPublisher;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+@Component
+@Scope("prototype")
+public class SdnrDmaapPublisher extends DmaapPublisher {
+
+
+ public SdnrDmaapPublisher() throws IOException {
+ super();
+ }
+
+ @Override
+ public String getAuth() {
+
+ return UrnPropertiesReader.getVariable("mso.global.dmaap.auth");
+ }
+
+ @Override
+ public String getKey() {
+
+ return UrnPropertiesReader.getVariable("mso.msoKey");
+ }
+
+ @Override
+ public String getTopic() {
+ return UrnPropertiesReader.getVariable("sdnc.dmaap.publisher.topic");
+ }
+
+ @Override
+ public Optional<String> getHost() {
+ return Optional.ofNullable(UrnPropertiesReader.getVariable("sdnc.dmaap.host"));
+ }
+}
+
+
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java
new file mode 100644
index 0000000000..d9656f7ea2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SendRequestToSdnr.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * 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.client.sdnc.common;
+
+import static org.onap.so.bpmn.common.scripts.GenericUtils.isBlank;
+import javax.inject.Provider;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.dmaapproperties.SdnrDmaapPublisher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component("SendRequestToSdnr")
+public class SendRequestToSdnr implements JavaDelegate {
+ private static final Logger logger = LoggerFactory.getLogger(SendRequestToSdnr.class);
+ ExceptionUtil exceptionUtil = new ExceptionUtil();
+
+ @Autowired
+ private Provider<SdnrDmaapPublisher> sdnrDmaapPublisher;
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+
+ logger.debug("SendRequestToSdnr_start");
+
+ String requestId = (String) execution.getVariable("correlator");
+ if (isBlank(requestId)) {
+ String msg = "Cannot process SDNR Request : correlator is null";
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg);
+ }
+
+ String messageType = (String) execution.getVariable("messageType");
+ if (isBlank(messageType)) {
+ String msg = "Cannot process SDNR Request : messageType is null";
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg);
+ }
+
+ String timeout = (String) execution.getVariable("timeout");
+ if (isBlank(timeout)) {
+ timeout = UrnPropertiesReader.getVariable("sdnc.dmaap.callback.timeout", execution);
+ if (isBlank(timeout)) {
+ logger.debug("Setting SDNR timeout to default : PT30M");
+ timeout = "PT30M";
+ }
+ }
+ logger.debug("Async Callback Timeout will be: " + timeout);
+ String msg = (String) execution.getVariable("sdnrRequest");
+ logger.debug("msg to be sent on dmaap " + msg);
+ sdnrDmaapPublisher.get().send(msg);
+
+ }
+}
+
+