From: c00149107 Date: Wed, 11 Oct 2017 08:46:50 +0000 (+0800) Subject: Add progress for create workflow X-Git-Tag: v1.1.0~163^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=73bd66b7ce4bd798c33d06f8f290456d817ba81d;p=so.git Add progress for create workflow Add progress and operation content for create workflow operation Change-Id: Ib48ab5be7f65a039813db1da816dbe7ac4c0e6f1 Issue-ID:SO-206 Signed-off-by: c00149107 --- diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java index 9648922d41..43273df14f 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -55,5 +55,21 @@ public interface MsoRequestsDbAdapter { @WebMethod public boolean getSiteStatus (@WebParam(name="siteName") @XmlElement(required = true) String siteName); + + @WebMethod + public void updateServiceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = false) String operationId, + @WebParam(name = "operationType") @XmlElement(required = false) String operationType, + @WebParam(name = "userId") @XmlElement(required = false) String userId, + @WebParam(name = "result") @XmlElement(required = false) String result, + @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; + + @WebMethod + public void initResourceOperationStatus (@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = true) String operationId, + @WebParam(name = "operationType") @XmlElement(required = true) String operationType, + @WebParam(name = "resourceTemplateUUIDs") @XmlElement(required = true) String resourceTemplateUUIDs) throws MsoRequestsDbException; } diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index f8a2c986da..87be2e1ccb 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -22,20 +22,24 @@ package org.openecomp.mso.adapters.requestsdb; import java.sql.Timestamp; +import javax.jws.WebMethod; import javax.jws.WebService; -import org.openecomp.mso.requestsdb.SiteStatus; -import org.openecomp.mso.utils.UUIDChecker; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; - import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException; +import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.OperationStatus; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.requestsdb.RequestsDbConstant; +import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; +import org.openecomp.mso.requestsdb.ResourceOperationStatus; +import org.openecomp.mso.requestsdb.SiteStatus; +import org.openecomp.mso.utils.UUIDChecker; @WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.openecomp.mso/requestsdb") public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { @@ -262,4 +266,61 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { return siteStatus.getStatus(); } } + + /** + * update operation status + *
+ * + * @param serviceId + * @param operationId + * @param operationType + * @param userId + * @param result + * @param operationContent + * @param progress + * @param reason + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, + String result, String operationContent, String progress, String reason) throws MsoRequestsDbException { + OperationStatus operStatus = new OperationStatus(); + operStatus.setServiceId(serviceId); + operStatus.setOperationId(operationId); + operStatus.setUserId(userId); + operStatus.setOperation(operationType); + operStatus.setReason(reason); + operStatus.setProgress(progress); + operStatus.setOperationContent(operationContent); + RequestsDatabase.getInstance().updateOperationStatus(operStatus); + } + + /** + * init the operation status of all the resources + *
+ * + * @param serviceId the service Id + * @param operationId the operation Id + * @param operationType the operationType + * @param resourceTemplateUUIDs the resources, the UUID is split by ":" + * @throws MsoRequestsDbException + * @since ONAP Amsterdam Release + */ + @Override + public void initResourceOperationStatus(String serviceId, String operationId, String operationType, + String resourceTemplateUUIDs) throws MsoRequestsDbException{ + String[] resourceLst = resourceTemplateUUIDs.split(":"); + for(String resource: resourceLst){ + ResourceOperationStatus resourceStatus = new ResourceOperationStatus(); + resourceStatus.setOperationId(operationId); + resourceStatus.setServiceId(serviceId); + resourceStatus.setResourceTemplateUUID(resource); + resourceStatus.setOperType(operationType); + resourceStatus.setStatus(RequestsDbConstant.Status.PROCESSING); + resourceStatus.setStatusDescription("Waiting for start"); + RequestsDatabase.getInstance().updateResOperStatus(resourceStatus); + } + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index 33bbbd8e6a..7f4f78762e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -282,4 +282,59 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor } utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) } + + /** + * Init the service Operation Status + */ + public void prepareInitServiceOperationStatus(Execution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = UUID.randomUUID().toString() + String operationType = "CREATE" + String userId = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${serviceId} + ${operationId} + ${operationType} + ${userId} + ${result} + ${operationContent} + ${progress} + ${reason} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled) + utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + } } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 4129a7660a..7505eed348 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -606,4 +606,64 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) } + public void preInitResourcesOperStatus(Execution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + String incomingRequest = execution.getVariable("bpmnRequest") + Map serviceReq = jsonSlurper.parseText(incomingRequest) + def segmentList = serviceReq.service.parameters.segments + + if (segmentList != null) { + segmentList.each { + resourceTemplateUUIDs = resourcesUUIDs + it.resourceUUID + ":" + } + } + + def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${serviceId} + ${operationId} + ${operationType} + ${resourceTemplateUUIDs} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) + utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn index a0a77faf0f..0a80602705 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0s2spoq @@ -113,7 +113,7 @@ csi.sendSyncError(execution)]]> - SequenceFlow_0z4faf9 + SequenceFlow_081z8l2 SequenceFlow_19eilro - + @@ -140,14 +140,45 @@ csi.sendSyncResponse(execution)]]> + + + SequenceFlow_0z4faf9 + SequenceFlow_1euqjsp + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1euqjsp + SequenceFlow_081z8l2 + - + - + @@ -163,7 +194,7 @@ csi.sendSyncResponse(execution)]]> - + @@ -175,7 +206,7 @@ csi.sendSyncResponse(execution)]]> - + @@ -190,17 +221,17 @@ csi.sendSyncResponse(execution)]]> - - + + - + - + - + @@ -218,10 +249,10 @@ csi.sendSyncResponse(execution)]]> - - + + - + @@ -331,6 +362,26 @@ csi.sendSyncResponse(execution)]]> + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index 758de28d36..2e996e20d5 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -135,7 +135,7 @@ def csi = new DoCreateE2EServiceInstance() csi.preSDNCRequest(execution)]]> - SequenceFlow_1170ztf + SequenceFlow_05gdjox SequenceFlow_15zgrcq - + SequenceFlow_092ghvu + + + SequenceFlow_1170ztf + SequenceFlow_1qctzm0 + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1qctzm0 + SequenceFlow_05gdjox + @@ -340,69 +371,89 @@ csi.postConfigRequest(execution)]]> - + - + - + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + - + - + + + +