From b6b7bef8bdcad15af01ac88a038dd763ce59f68f Mon Sep 17 00:00:00 2001 From: xg353y Date: Tue, 11 Apr 2017 13:30:42 +0200 Subject: [MSO-8] Update the maven dependency Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes. Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc Signed-off-by: xg353y --- .../groovy/com/att/bpm/scripts/VidUtils.groovy | 362 --------------------- 1 file changed, 362 deletions(-) delete mode 100644 bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/VidUtils.groovy (limited to 'bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/VidUtils.groovy') diff --git a/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/VidUtils.groovy b/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/VidUtils.groovy deleted file mode 100644 index 364c586325..0000000000 --- a/bpmn/MSOGammaBPMN/src/main/groovy/com/att/bpm/scripts/VidUtils.groovy +++ /dev/null @@ -1,362 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 com.att.bpm.scripts - -import org.json.JSONObject; -import org.json.XML; - -import org.openecomp.mso.bpmn.core.xml.XmlTool; - -import groovy.json.JsonBuilder -import groovy.json.JsonSlurper -import groovy.util.slurpersupport.GPathResult -import groovy.xml.QName - -class VidUtils { - - public MsoUtils utils = new MsoUtils() - private AbstractServiceTaskProcessor taskProcessor - - public VidUtils(AbstractServiceTaskProcessor taskProcessor) { - this.taskProcessor = taskProcessor - } - - /** - * Create a volume-request XML using a JSON string - * @param jsonReq - JSON request from VID - * @param action - * @return - */ - public String createXmlVolumeRequest(String jsonReq, String action, String serviceInstanceId) { - def jsonSlurper = new JsonSlurper() - try{ - Map reqMap = jsonSlurper.parseText(jsonReq) - return createXmlVolumeRequest(reqMap, action, serviceInstanceId) - } - catch(Exception e) { - throw e - } - } - - /** - * Create a volume-request XML using a map - * @param requestMap - map created from VID JSON - * @param action - * @param serviceInstanceId - * @return - */ - public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId) { - createXmlVolumeRequest(requestMap, action, serviceInstanceId, '') - } - - - /** - * Create a volume-request XML using a map - * @param requestMap - * @param action - * @param serviceInstanceId - * @param volumeGroupId - * @return - */ - public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId, String volumeGroupId) { - def vnfType = '' - def serviceName = '' - def modelCustomizationName = '' - def asdcServiceModelVersion = '' - - def suppressRollback = requestMap.requestDetails.requestInfo.suppressRollback - def rollbackEnabled = true - if(suppressRollback != null && suppressRollback == true) { - rollbackEnabled = false - } - - def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' - def serviceId = requestMap.requestDetails.requestParameters?.serviceId ?: '' - def relatedInstanceList = requestMap.requestDetails.relatedInstanceList - relatedInstanceList.each { - if (it.relatedInstance.modelInfo?.modelType == 'service') { - serviceName = it.relatedInstance.modelInfo?.modelName - asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion - } - if (it.relatedInstance.modelInfo?.modelType == 'vnf') { - modelCustomizationName = it.relatedInstance.modelInfo?.modelCustomizationName - } - } - - vnfType = serviceName + '/' + modelCustomizationName - - def userParams = requestMap.requestDetails?.requestParameters?.userParams - def userParamsNode = '' - if(userParams != null) { - userParamsNode = buildUserParams(userParams) - } - def xmlReq = """ - - - ${action} - ${requestMap.requestDetails.requestInfo.source} - ${serviceInstanceId} - - - ${volumeGroupId} - ${volGrpName} - ${vnfType} - ${requestMap.requestDetails.modelInfo.modelName} - ${asdcServiceModelVersion} - ${requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId} - ${requestMap.requestDetails.cloudConfiguration.tenantId} - ${serviceId} - ${rollbackEnabled} - - - $userParamsNode - - - """ - // return a pretty-print of the volume-request xml without the preamble - return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") - } - - /** - * A common method that can be used to build volume-params node from a map. - * @param Map userParams - * @return - */ - public String buildUserParams(userParams) { - if (userParams == null) return "" - def xml = "" - def key = "" - def value = "" - userParams.each {it -> - key = it.name.replaceAll(/\B[A-Z]/) { '_' + it }.toLowerCase() - value = it.value - xml += "${value}" - } - - return xml - } - - /** - * A common method that can be used to extract 'requestDetails' - * @param String json - * @return String json requestDetails - */ - @Deprecated - public getJsonRequestDetails(String jsonInput) { - String rtn = "" - if (jsonInput.isEmpty() || jsonInput == null) { - return rtn - } else { - def jsonMapObject = new JsonSlurper().parseText(jsonInput) - if (jsonMapObject instanceof Map) { - String jsonString = new JsonBuilder(jsonMapObject.requestDetails) - rtn = '{'+"requestDetails"+":"+jsonString+'}' - return rtn - } else { - return rtn - } - } - } - - /** - * A common method that can be used to extract 'requestDetails' in Xml - * @param String json - * @return String xml requestDetails - */ - @Deprecated - public getJsonRequestDetailstoXml(String jsonInput) { - String rtn = null - def jsonString = getJsonRequestDetails(jsonInput) - if (jsonString == null) { - return rtn - } else { - JSONObject jsonObj = new JSONObject(jsonString) - return XmlTool.normalize(XML.toString(jsonObj)) - } - } - - /** - * Create a network-request XML using a map - * @param execution - * @param xmlRequestDetails - requestDetails in xml - * @return - */ - public String createXmlNetworkRequestInfra(execution, def networkJsonIncoming) { - - def requestId = execution.getVariable("requestId") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def requestAction = execution.getVariable("requestAction") - def networkId = (execution.getVariable("networkId")) != null ? execution.getVariable("networkId") : "" - - def jsonSlurper = new JsonSlurper() - try { - Map reqMap = jsonSlurper.parseText(networkJsonIncoming) - def instanceName = reqMap.requestDetails.requestInfo.instanceName - def modelName = reqMap.requestDetails.modelInfo.modelName - def lcpCloudRegionId = reqMap.requestDetails.cloudConfiguration.lcpCloudRegionId - def tenantId = reqMap.requestDetails.cloudConfiguration.tenantId - def serviceId = reqMap.requestDetails.requestInfo.productFamilyId - def backoutOnFailure = reqMap.requestDetails.requestInfo.suppressRollback - - //def userParams = reqMap.requestDetails.requestParameters.userParams - //def userParamsNode = buildUserParams(userParams) - def userParams = reqMap.requestDetails?.requestParameters?.userParams - def userParamsNode = '' - if(userParams != null) { - userParamsNode = buildUserParams(userParams) - } - - def xmlReq = """ - - - ${requestId} - ${requestAction} - VID - ${serviceInstanceId} - - - ${networkId} - ${instanceName} - ${modelName} - ${lcpCloudRegionId} - ${tenantId} - ${serviceId} - ${backoutOnFailure} - - - ${userParamsNode} - - - """ - // return a pretty-print of the volume-request xml without the preamble - return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") - - } catch(Exception e) { - throw e - } - } - - /** - * Create a vnf-request XML using a map - * @param requestMap - map created from VID JSON - * @param action - * @return - */ - public String createXmlVfModuleRequest(execution, Map requestMap, String action, String serviceInstanceId) { - - //def relatedInstanceList = requestMap.requestDetails.relatedInstanceList - - //relatedInstanceList.each { - // if (it.relatedInstance.modelInfo.modelType == 'vnf') { - // vnfType = it.relatedInstance.modelInfo.modelName - // vnfId = it.relatedInstance.modelInfo.modelInvariantId - // } - //} - - def vnfName = '' - def asdcServiceModelInfo = '' - - def relatedInstanceList = requestMap.requestDetails?.relatedInstanceList - - - if (relatedInstanceList != null) { - relatedInstanceList.each { - if (it.relatedInstance.modelInfo?.modelType == 'service') { - asdcServiceModelInfo = it.relatedInstance.modelInfo?.modelVersion - } - if (it.relatedInstance.modelInfo.modelType == 'vnf') { - vnfName = it.relatedInstance.instanceName ?: '' - } - } - } - - def vnfType = execution.getVariable('vnfType') - def vnfId = execution.getVariable('vnfId') - - def vfModuleId = execution.getVariable('vfModuleId') - def volumeGroupId = execution.getVariable('volumeGroupId') - def userParams = requestMap.requestDetails?.requestParameters?.userParams - - - def userParamsNode = '' - if(userParams != null) { - userParamsNode = buildUserParams(userParams) - } - - def isBaseVfModule = "false" - if (execution.getVariable('isBaseVfModule') == true) { - isBaseVfModule = "true" - } - - def requestId = execution.getVariable("att-mso-request-id") - def vfModuleName = requestMap.requestDetails?.requestInfo?.instanceName ?: '' - def vfModuleModelName = requestMap.requestDetails?.modelInfo?.modelName ?: '' - def suppressRollback = requestMap.requestDetails?.requestInfo?.suppressRollback - def backoutOnFailure = "true" - if(suppressRollback != null && suppressRollback == true) { - backoutOnFailure = "false" - } - - def serviceId = requestMap.requestDetails?.requestParameters?.serviceId ?: '' - def aicCloudRegion = requestMap.requestDetails?.cloudConfiguration?.lcpCloudRegionId ?: '' - def tenantId = requestMap.requestDetails?.cloudConfiguration?.tenantId ?: '' - def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantId ?: '' - def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelVersion ?: '' - - def xmlReq = """ - - - ${requestId} - ${action} - VID - - ${serviceInstanceId} - - - - ${vnfName} - ${vnfType} - ${vnfId} - ${volumeGroupId} - ${vfModuleId} - ${vfModuleName} - ${vfModuleModelName} - ${isBaseVfModule} - ${asdcServiceModelInfo} - ${aicCloudRegion} - ${tenantId} - ${serviceId} - ${backoutOnFailure} - ${personaModelId} - ${personaModelVersion} - - - $userParamsNode - - - """ - - // return a pretty-print of the volume-request xml without the preamble - return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") - } - - -} -- cgit 1.2.3-korg