Save sppartner to AAI and call ExternalAPI bug fix 47/59647/1
authorElaine_Han <elaine.hanyulian@huawei.com>
Wed, 8 Aug 2018 10:30:11 +0000 (18:30 +0800)
committerElaine_Han <elaine.hanyulian@huawei.com>
Wed, 8 Aug 2018 10:30:11 +0000 (18:30 +0800)
Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa70000005
Issue-ID: SO-683
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy

index 3646f26..f2f41ac 100644 (file)
@@ -63,6 +63,7 @@ class ExternalAPIUtil {
         "\t\t\"service\": {\n" +
             "\t\t\t\"serviceState\": <serviceState>,\n" +
             "\t\t\t\"name\": <serviceName>,\n" +
+            "\t\t\t\"serviceType\": <serviceType>,\n" +
             "\t\t\t\"serviceSpecification\": { \n" +
                 "\t\t\t\t\"id\": <serviceUuId> \n" +
             "\t\t\t},\n" +
index fb21574..80e6e75 100644 (file)
@@ -326,11 +326,12 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                String subscriberId = execution.getVariable("globalSubscriberId")
                String customerRole = ""
                String subscriberName = ""
-               String referredType = execution.getVariable("serviceType")
+               String referredType = "Consumer"
                String orderItemId = "1"
                String action = "add" //for create
                String serviceState = "active"
                String serviceName = execution.getVariable("serviceInstanceName")
+               String serviceType = execution.getVariable("serviceType")
                String serviceId = execution.getVariable("serviceInstanceId")
                
                Map<String, String> valueMap = new HashMap<>()
@@ -348,6 +349,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                valueMap.put("action", '"' + action + '"')
                valueMap.put("serviceState", '"' + serviceState + '"')
                valueMap.put("serviceName", '"' + serviceName + '"')
+               valueMap.put("serviceType", '"' + serviceType + '"')
                valueMap.put("serviceId", '"' + serviceId + '"')
                
                ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
@@ -493,6 +495,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
                String callSource = execution.getVariable(Prefix + "CallSource")
                String serviceInstanceId = execution.getVariable("serviceInstanceId")
+               String globalSubscriberId = execution.getVariable("globalSubscriberId")
+               String serviceType = execution.getVariable("serviceType")
                
                AaiUtil aaiUriUtil = new AaiUtil(this)
                String aai_uri = aaiUriUtil.getBusinessSPPartnerUri(execution)
@@ -502,11 +506,18 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                                """<sp-partner xmlns=\"${namespace}\">
                                <id>${sppartnerId}</id>
                                <url>${sppartnerUrl}</url>
-                               <callSource>${callSource}</callSource>
-                                       <service-instance>                                      
-                                           <service-instance-id>${serviceInstanceId}</service-instance-id>                                 
-                                   </service-instance>
-                                       </sp-partner>""".trim()
+                               <callsource>${callSource}</callsource>
+                               <relationship-list>
+                                 <relationship>
+                                   <related-to>service-instance</related-to>
+                                   <related-link>/aai/v14/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}</related-link>
+                                   <relationship-data>
+                                       <relationship-key>service-instance.service-instance-id</relationship-key>
+                                       <relationship-value>${serviceInstanceId}</relationship-value>
+                                   </relationship-data> 
+                                 </relationship>
+                               </relationship-list>
+                               </sp-partner>""".trim()
                utils.logAudit(payload)
                
                String aai_endpoint = execution.getVariable("URN_aai_endpoint")
index 122fd50..8844127 100644 (file)
@@ -56,7 +56,7 @@ import org.onap.so.rest.RESTConfig
  */
 public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
 
-       String Prefix="CRE3rdONAPESI_"
+       String Prefix = "CRE3rdONAPESI_"
 
        ExceptionUtil exceptionUtil = new ExceptionUtil()
 
@@ -249,11 +249,12 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                String subscriberId = execution.getVariable("globalSubscriberId")
                String customerRole = ""
                String subscriberName = ""
-               String referredType = execution.getVariable("serviceType")
+               String referredType = "Consumer"
                String orderItemId = "1"
                String action = "delete" //for delete
                String serviceState = "active"
                String serviceName = ""
+               String serviceType = execution.getVariable("serviceType")
                String serviceId = execution.getVariable(Prefix + "ServiceInstanceId")
                
                Map<String, String> valueMap = new HashMap<>()
@@ -271,6 +272,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                valueMap.put("action", '"' + action + '"')
                valueMap.put("serviceState", '"' + serviceState + '"')
                valueMap.put("serviceName", '"' + serviceName + '"')
+               valueMap.put("serviceType", '"' + serviceType + '"')
                valueMap.put("serviceId", '"' + serviceId + '"')
                
                ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)             
@@ -448,7 +450,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
                String sppartnerVersion = execution.getVariable(Prefix + "sppartnerVersion")
                
                AaiUtil aaiUriUtil = new AaiUtil(this)
-               String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath") + "/${sppartnerVersion}"
+               String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath") + "?resource-version=${sppartnerVersion}"
                APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath)
                int responseCode = response.getStatusCode()
                execution.setVariable(Prefix + "DeleteSppartnerResponseCode", responseCode)