From 48c44edbec6adf3a9b5b49f147cb026b8251ce7b Mon Sep 17 00:00:00 2001 From: Priyadharshini Date: Thu, 20 Aug 2020 06:06:49 -0700 Subject: Implement Workflows to handle NSSMF Common functionalities Issue-ID: SO-3190 Signed-off-by: Priyadharshini Change-Id: I38ce91415fc5ced083e017ed4306873d17d5fa24 --- .../so/bpmn/common/scripts/RequestDBUtil.groovy | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'bpmn/MSOCommonBPMN/src/main/groovy') 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 = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(resourceTemplateUUID)} + + + + """ + 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 = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(resourceTemplateUUID)} + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(jobId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(errorCode)} + ${MsoUtils.xmlEscape(statusDescription)} + + + + """ + 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") + } + } -- cgit 1.2.3-korg