summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/groovy
diff options
context:
space:
mode:
authorPriyadharshini <priyadharshini.b96@wipro.com>2020-08-20 06:06:49 -0700
committerPriyadharshini <priyadharshini.b96@wipro.com>2020-09-16 21:20:33 -0700
commit48c44edbec6adf3a9b5b49f147cb026b8251ce7b (patch)
tree5a63c24b6a03a724330cfaee9175aca06c509701 /bpmn/MSOCommonBPMN/src/main/groovy
parent453353c6505d06e9bc905ca886cd7ab17e8d15db (diff)
Implement Workflows to handle NSSMF Common functionalities
Issue-ID: SO-3190 Signed-off-by: Priyadharshini <priyadharshini.b96@wipro.com> Change-Id: I38ce91415fc5ced083e017ed4306873d17d5fa24
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy97
1 files changed, 97 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy
index b35042e3c0..23dfdce753 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.db.request.beans.OperationStatus
+import org.onap.so.db.request.beans.ResourceOperationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.web.util.UriUtils
@@ -116,4 +117,100 @@ class RequestDBUtil {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
}
+
+ /**
+ * init resource operation status in requestDB
+ * @param execution
+ * @param resourceoperationStatus
+ */
+ void prepareInitResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){
+ logger.debug("start prepareinitResourceOperationStatus")
+ try{
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
+ execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+
+ String serviceId = resourceoperationStatus.getServiceId()
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ String operationId = resourceoperationStatus.getOperationId()
+ String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID()
+ String operType = resourceoperationStatus.getOperType()
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operType)}</operationType>
+ <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs>
+ </ns:initResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ execution.setVariable("initResourceOperationStatus", payload)
+
+ }catch(any){
+ String exceptionMessage = "Prepare init ResourceOperationStatus failed. cause - " + any.getMessage()
+ logger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ logger.trace("finished init ResourceOperationStatus")
+ }
+
+ /**
+ * update resource operation status in requestDB
+ * @param execution
+ * @param resourceoperationStatus
+ */
+ void prepareUpdateResourceOperationStatus(DelegateExecution execution, final ResourceOperationStatus resourceoperationStatus){
+ logger.debug("start prepareUpdateResourceOperationStatus")
+ try{
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
+ execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+
+ String serviceId = resourceoperationStatus.getServiceId()
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ String operationId = resourceoperationStatus.getOperationId()
+ String resourceTemplateUUID = resourceoperationStatus.getResourceTemplateUUID()
+ String operType = resourceoperationStatus.getOperType()
+ String resourceInstanceID = resourceoperationStatus.getResourceInstanceID()
+ String jobId = resourceoperationStatus.getJobId()
+ String status = resourceoperationStatus.getStatus()
+ String progress = resourceoperationStatus.getProgress()
+ String errorCode = resourceoperationStatus.getErrorCode()?: ""
+ String statusDescription = resourceoperationStatus.getStatusDescription()?: ""
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs>
+ <operationType>${MsoUtils.xmlEscape(operType)}</operationType>
+ <jobId>${MsoUtils.xmlEscape(jobId)}</jobId>
+ <status>${MsoUtils.xmlEscape(status)}</status>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <errorCode>${MsoUtils.xmlEscape(errorCode)}</errorCode>
+ <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription>
+ </ns:updateResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ execution.setVariable("updateResourceOperationStatus", payload)
+
+ }catch(any){
+ String exceptionMessage = "Prepare update ResourceOperationStatus failed. cause - " + any.getMessage()
+ logger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ logger.trace("finished update ResourceOperationStatus")
+ }
+
}