<service-logic
    xmlns='http://www.onap.org/sdnc/svclogic'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='GENERIC-RESOURCE-API' version='${project.version}'>
    <method rpc='getpathsegment-create-composite-path' mode='sync'>
        <block>
            <set>
                <parameter name='match-type' value='network-name' />
            </set>
            <get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key='SELECT * from PATH_SEGMENT WHERE service_uuid = $getpathsegment-topology-operation-input.service-information.onap-model-information.model-uuid
    AND path_name = $db.forwarding-path[$path-index].path-name ORDER BY path_segment_seq'
  pfx='db.path-segment[]'>
                <outcome value='failure'>
                    <block>
                        <set>
                            <parameter name='error-message' value="`'System error reading PATH_SEGMENT table for uuid '
  + $getpathsegment-topology-operation-input.service-information.onap-model-information.model-uuid
  + ' and path '
  + $db.forwarding-path[$path-index].path-name`" />
                        </set>
                    </block>
                </outcome>
                <outcome value='not-found'>
                    <block>
                        <set>
                            <parameter name='error-message' value="`'No entries in PATH_SEGMENT table for uuid '
  + $getpathsegment-topology-operation-input.service-information.onap-model-information.model-uuid
  + ' and path '
  + $db.forwarding-path[$path-index].path-name`" />
                        </set>
                    </block>
                </outcome>
                <outcome value='success'>
                    <block>
                        <set>
                            <parameter name='serv-cust_length' value='0' />
                        </set>
                        <for index='path-segment-index' start='0' end='`$db.path-segment_length`' >
                            <block>
                                <set>
                                    <parameter name='serv-cust[$serv-cust_length].id' value='`$db.path-segment[$path-segment-index].source-association-uuid`' />
                                    <parameter name='serv-cust_length' value='`$serv-cust_length + 1`' />
                                </set>
                                <switch test='`$path-segment-index == ( $db.path-segment_length - 1) `'>
                                    <outcome value='true'>
                                        <set>
                                            <parameter name='serv-cust[$serv-cust_length].id' value='`$db.path-segment[$path-segment-index].target-association-uuid`' />
                                            <parameter name='serv-cust_length' value='`$serv-cust_length + 1`' />
                                        </set>
                                    </outcome>
                                </switch>
                            </block>
                        </for>
                        <for index='serv-index' start='0' end='`$serv-cust_length`' >
                            <get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key='select sm.invariant_uuid
    from SERVICE_PROXY sp, SERVICE_MODEL sm
    where sp.source_service_uuid = sm.service_uuid
    and sp.customization_uuid = $serv-cust[$serv-index].id'
  pfx='db'>
                                <outcome value='failure'>
                                    <set>
                                        <parameter name='error-message' value="`'Failure reading SERVICE_PROXY and SERVICE_MODEL for customization uuid ' + $serv-cust[$serv-index].id`" />
                                    </set>
                                </outcome>
                                <outcome value='not-found'>
                                    <set>
                                        <parameter name='error-message' value="`'Cannot find entries in SERVICE_PROXY and SERVICE_MODEL for customization uuid ' + $serv-cust[$serv-index].id`" />
                                    </set>
                                </outcome>
                                <outcome value='success'>
                                    <set>
                                        <parameter name='serv-cust[$serv-index].inv-id' value='`$db.invariant-uuid`' />
                                    </set>
                                </outcome>
                            </get-resource>
                        </for>
                        <for index='serv-index' start='0' end='`$serv-cust_length`' >
                            <switch test='`$serv-cust[$serv-index].inv-id`'>
                                <outcome value=''>
                                    <block></block>
                                </outcome>
                                <outcome value='Other'>
                                    <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService"
	resource="custom-query"
	key="format = 'resource'"
	force="true"
	local-only="false"
	pfx="aai.service-instances" >
                                        <parameter name="start[0]" value="`'nodes/service-instances?model-invariant-id=' + $serv-cust[$serv-index].inv-id`" />
                                        <parameter name="start_length" value="1" />
                                        <outcome value='not-found'>
                                            <set>
                                                <parameter name='error-message' value="`'Unable to find runtime service instances for invariant UUID ' + $serv-cust[$serv-index].inv-id`" />
                                            </set>
                                        </outcome>
                                        <outcome value='failure'>
                                            <set>
                                                <parameter name='error-message' value="`'System error finding runtime service instances for customization UUID ' + $serv-cust[$serv-index].inv-id`" />
                                            </set>
                                        </outcome>
                                        <outcome value='success'>
                                            <block>
                                                <set>
                                                    <parameter name='tmp.serv-insts_length' value='0' />
                                                </set>
                                                <for index='runtime-index' start='0' end='`$aai.service-instances.results_length`' >
                                                    <switch test='`$aai.service-instances.results[$runtime-index].service-instance.orchestration-status`'>
                                                        <outcome value='Active'>
                                                            <block>
                                                                <set>
                                                                    <parameter name='serv-inst.service-instance-id' value='`$aai.service-instances.results[$runtime-index].service-instance.service-instance-id`' />
                                                                </set>
                                                                <switch test='`$output-global-customer-id`'>
                                                                    <outcome value=''>
                                                                        <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService"
      resource="custom-query"
      key="format = 'resource_and_url'"
      force="true"
      local-only="false"
      pfx="tmp.AnAI-data.si">
                                                                            <parameter name="start[0]" value="`'nodes/service-instance/' + $serv-inst.service-instance-id `" />
                                                                            <parameter name="start_length" value="1" />
                                                                            <outcome value='success'>
                                                                                <block>
                                                                                    <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='split' >
                                                                                        <parameter name="original_string" value="`$tmp.AnAI-data.si.results[0].url`" />
                                                                                        <parameter name="regex" value="/"/>
                                                                                        <parameter name="limit" value="11" />
                                                                                        <parameter name="ctx_memory_result_key" value="split" />
                                                                                    </execute>
                                                                                    <set>
                                                                                        <parameter name='output-global-customer-id' value='`$split[6]`' />
                                                                                        <parameter name='output-service-type' value='`$split[9]`' />
                                                                                        <parameter name='output-service-role' value='`$tmp.AnAI-data.si.results[0].service-instance.service-role`' />
                                                                                    </set>
                                                                                </block>
                                                                            </outcome>
                                                                        </save>
                                                                    </outcome>
                                                                </switch>
                                                                <block>
                                                                    <switch test='`$runtime-index`'>
                                                                        <outcome value='0'>
                                                                            <set>
                                                                                <parameter name='service.service-role' value='`$aai.service-instances.results[0].service-instance.service-role`' />
                                                                            </set>
                                                                        </outcome>
                                                                    </switch>
                                                                    <set>
                                                                        <parameter name='mdsal-service.' value='' />
                                                                        <parameter name='serv-inst.api' value='' />
                                                                    </set>
                                                                    <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                                                                        <parameter name="source" value="`$prop.restapi.service`"/>
                                                                        <parameter name="outputPath" value="tmp.service-url"/>
                                                                        <parameter name="target" value="{service-instance-id}"/>
                                                                        <parameter name="replacement" value="`$serv-inst.service-instance-id`"/>
                                                                    </execute>
                                                                    <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                                                        <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.service-url`' />
                                                                        <parameter name='restapiUser' value='`$prop.controller.user`' />
                                                                        <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                                                                        <parameter name='format' value='json' />
                                                                        <parameter name='httpMethod' value='GET' />
                                                                        <parameter name="responsePrefix" value="mdsal-service" />
                                                                        <outcome value='success'>
                                                                            <block>
                                                                                <switch test='`$mdsal-service.service[0].service-data.vnfs.vnf_length`'>
                                                                                    <outcome value=''>
                                                                                        <set>
                                                                                            <parameter name='data-error' value="`'Service instance ' + $si.service-instance-id + ' has no VNFs, skipping'`" />
                                                                                        </set>
                                                                                    </outcome>
                                                                                    <outcome value='0'>
                                                                                        <set>
                                                                                            <parameter name='data-error' value="`'Service instance ' + $si.service-instance-id + ' has no VNFs, skipping'`" />
                                                                                        </set>
                                                                                    </outcome>
                                                                                    <outcome value='1'>
                                                                                        <block>
                                                                                            <call module='GENERIC-RESOURCE-API' rpc='getpathsegment-populate-from-grapi' mode='sync' ></call>
                                                                                            <set>
                                                                                                <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].' value='`$serv-inst.`' />
                                                                                            </set>
                                                                                            <set>
                                                                                                <parameter name='tmp.serv-insts_length' value='`$tmp.serv-insts_length + 1`' />
                                                                                            </set>
                                                                                        </block>
                                                                                    </outcome>
                                                                                    <outcome value='Other'>
                                                                                        <switch test='`$mdsal-service.service[0].service-data.forwarding-paths.forwarding-path_length`'>
                                                                                            <outcome value=''>
                                                                                                <set>
                                                                                                    <parameter name='data-error' value="`'Service instance ' + $serv-inst.service-instance-id + ' has multiple VNFs but no forwarding paths were found'`" />
                                                                                                </set>
                                                                                            </outcome>
                                                                                            <outcome value='0'>
                                                                                                <set>
                                                                                                    <parameter name='data-error' value="`'Service instance ' + $serv-inst.service-instance-id + ' has multiple VNFs but no forwarding paths were found'`" />
                                                                                                </set>
                                                                                            </outcome>
                                                                                            <outcome value='Other'>
                                                                                                <block>
                                                                                                    <call module='GENERIC-RESOURCE-API' rpc='getpathsegment-populate-from-grapi' mode='sync' ></call>
                                                                                                    <set>
                                                                                                        <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].' value='`$serv-inst.`' />
                                                                                                    </set>
                                                                                                    <set>
                                                                                                        <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].forwarding-paths.'
  value='`$mdsal-service.service[0].service-data.forwarding-paths.`' />
                                                                                                    </set>
                                                                                                    <set>
                                                                                                        <parameter name='tmp.serv-insts_length' value='`$tmp.serv-insts_length + 1`' />
                                                                                                    </set>
                                                                                                </block>
                                                                                            </outcome>
                                                                                        </switch>
                                                                                    </outcome>
                                                                                </switch>
                                                                            </block>
                                                                        </outcome>
                                                                        <outcome value='failure'>
                                                                            <block>
                                                                                <call module='GENERIC-RESOURCE-API' rpc='getpathsegment-populate-from-vnfapi' mode='sync' ></call>
                                                                                <switch test='`$serv-inst.api`'>
                                                                                    <outcome value=''>
                                                                                        <set>
                                                                                            <parameter name='data-error' value="`'Failure finding service instance ' + $si.service-instance-id + ' in either GENERIC-REOURCE-API or VNF-API'`" />
                                                                                        </set>
                                                                                    </outcome>
                                                                                    <outcome value='Other'>
                                                                                        <block>
                                                                                            <switch test='`$serv-inst.vnf-list_length`'>
                                                                                                <outcome value=''>
                                                                                                    <set>
                                                                                                        <parameter name='data-error' value="`'Service instance ' + $si.service-instance-id + ' has no VNFs, skipping'`" />
                                                                                                    </set>
                                                                                                </outcome>
                                                                                                <outcome value='0'>
                                                                                                    <set>
                                                                                                        <parameter name='data-error' value="`'Service instance ' + $si.service-instance-id + ' has no VNFs, skipping'`" />
                                                                                                    </set>
                                                                                                </outcome>
                                                                                                <outcome value='1'>
                                                                                                    <block>
                                                                                                        <set>
                                                                                                            <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].' value='`$serv-inst.`' />
                                                                                                        </set>
                                                                                                        <set>
                                                                                                            <parameter name='tmp.serv-insts_length' value='`$tmp.serv-insts_length + 1`' />
                                                                                                        </set>
                                                                                                    </block>
                                                                                                </outcome>
                                                                                                <outcome value='Other'>
                                                                                                    <get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key='SELECT forwarding_path_service_instance_id from SERVICE_INSTANCE_TO_COMPOSITE_INSTANCE_MAPPING WHERE simple_service_instance_id = $serv-inst.service-instance-id'
  pfx='db.mapped-service-instance-id'>
                                                                                                        <outcome value='failure'>
                                                                                                            <set>
                                                                                                                <parameter name='data-error' value="System error reading SERVICE_INSTANCE_TO_COMPOSITE_INSTANCE_MAPPING table" />
                                                                                                            </set>
                                                                                                        </outcome>
                                                                                                        <outcome value='not-found'>
                                                                                                            <set>
                                                                                                                <parameter name='data-error' value="`'No entry in SERVICE_INSTANCE_TO_COMPOSITE_INSTANCE_MAPPING table for service instance ' + $serv-inst.service-instance-id`" />
                                                                                                            </set>
                                                                                                        </outcome>
                                                                                                        <outcome value='success'>
                                                                                                            <block>
                                                                                                                <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                                                                                                                    <parameter name="source" value="`$prop.restapi.service`"/>
                                                                                                                    <parameter name="outputPath" value="tmp.service-url"/>
                                                                                                                    <parameter name="target" value="{service-instance-id}"/>
                                                                                                                    <parameter name="replacement" value="`$db.mapped-service-instance-id.forwarding-path-service-instance-id`"/>
                                                                                                                </execute>
                                                                                                                <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                                                                                                    <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.service-url`' />
                                                                                                                    <parameter name='restapiUser' value='`$prop.controller.user`' />
                                                                                                                    <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                                                                                                                    <parameter name='format' value='json' />
                                                                                                                    <parameter name='httpMethod' value='GET' />
                                                                                                                    <parameter name="responsePrefix" value="mdsal-service" />
                                                                                                                    <outcome value='failure'>
                                                                                                                        <set>
                                                                                                                            <parameter name='data-error' value="`'Cannot find service instance ' + $db.mapped-service-instance-id.forwarding-path-service-instance-id + ' in MD-SAL'`" />
                                                                                                                        </set>
                                                                                                                    </outcome>
                                                                                                                    <outcome value='success'>
                                                                                                                        <switch test='`$mdsal-service.service[0].service-data.forwarding-paths.forwarding-path_length`'>
                                                                                                                            <outcome value=''>
                                                                                                                                <set>
                                                                                                                                    <parameter name='data-error' value="`'Service instance ' + $db.mapped-service-instance-id.forwarding-path-service-instance-id + ' has multiple VNFs but no forwarding paths were found'`" />
                                                                                                                                </set>
                                                                                                                            </outcome>
                                                                                                                            <outcome value='0'>
                                                                                                                                <set>
                                                                                                                                    <parameter name='data-error' value="`'Service instance ' + $db.mapped-service-instance-id.forwarding-path-service-instance-id + ' has multiple VNFs but no forwarding paths were found'`" />
                                                                                                                                </set>
                                                                                                                            </outcome>
                                                                                                                            <outcome value='Other'>
                                                                                                                                <block>
                                                                                                                                    <set>
                                                                                                                                        <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].' value='`$serv-inst.`' />
                                                                                                                                    </set>
                                                                                                                                    <set>
                                                                                                                                        <parameter name='serv-cust[$serv-index].serv-insts[$tmp.serv-insts_length].forwarding-paths.'
  value='`$mdsal-service.service[0].service-data.forwarding-paths.`' />
                                                                                                                                    </set>
                                                                                                                                    <set>
                                                                                                                                        <parameter name='tmp.serv-insts_length' value='`$tmp.serv-insts_length + 1`' />
                                                                                                                                    </set>
                                                                                                                                </block>
                                                                                                                            </outcome>
                                                                                                                        </switch>
                                                                                                                    </outcome>
                                                                                                                </execute>
                                                                                                            </block>
                                                                                                        </outcome>
                                                                                                    </get-resource>
                                                                                                </outcome>
                                                                                            </switch>
                                                                                        </block>
                                                                                    </outcome>
                                                                                </switch>
                                                                            </block>
                                                                        </outcome>
                                                                    </execute>
                                                                    <set>
                                                                        <parameter name='serv-inst.' value='' />
                                                                    </set>
                                                                </block>
                                                            </block>
                                                        </outcome>
                                                    </switch>
                                                </for>
                                                <set>
                                                    <parameter name='serv-cust[$serv-index].serv-insts_length' value='`$tmp.serv-insts_length`' />
                                                </set>
                                            </block>
                                        </outcome>
                                    </save>
                                </outcome>
                            </switch>
                        </for>
                        <call module='GENERIC-RESOURCE-API' rpc='getpathsegment-composite-match-pair' mode='sync' ></call>
                        <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='printContext' >
                            <parameter name='filename' value='/var/tmp/gpsx.log' />
                        </execute>
                        <switch test='`$service-paths.service-path_length`'>
                            <outcome value=''>
                                <block></block>
                            </outcome>
                            <outcome value='0'>
                                <block></block>
                            </outcome>
                            <outcome value='Other'>
                                <block>
                                    <set>
                                        <parameter name='found-service-path' value='false' />
                                    </set>
                                    <for index='sp-index' start='0' end='`$service-paths.service-path_length`' >
                                        <switch test='`$service-paths.service-path[$sp-index].service_length == $serv-cust_length`'>
                                            <outcome value='true'>
                                                <block>
                                                    <set>
                                                        <parameter name='found-service-path' value='true' />
                                                    </set>
                                                    <break/>
                                                </block>
                                            </outcome>
                                        </switch>
                                    </for>
                                    <switch test='`$found-service-path`'>
                                        <outcome value='false'>
                                            <set>
                                                <parameter name='error-message' value="`'No service paths found for path name '
  + $db.path-segment[0].path-name`" />
                                            </set>
                                        </outcome>
                                        <outcome value='true'>
                                            <block>
                                                <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID" >
                                                    <parameter name="ctx-destination" value="forwarding-path.forwarding-path-id" />
                                                </execute>
                                                <set>
                                                    <parameter name='forwarding-path.forwarding-path-name' value='`$db.path-segment[0].path-name`' />
                                                    <parameter name='forwarding-path.forwarding-path-type' value='Service' />
                                                    <parameter name='forwarding-path.onap-model-information.model-name' value='`$db.path-segment[0].path-name`' />
                                                </set>
                                                <set>
                                                    <parameter name='forwarding-path.service-paths.' value='`$service-paths.`' />
                                                </set>
                                                <switch test='`$output-service-instance-id`'>
                                                    <outcome value=''>
                                                        <block>
                                                            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID" >
                                                                <parameter name="ctx-destination" value="tmp.service-instance-id" />
                                                            </execute>
                                                            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                                                                <parameter name="source" value="`$prop.restapi.service`"/>
                                                                <parameter name="outputPath" value="tmp.service-url"/>
                                                                <parameter name="target" value="{service-instance-id}"/>
                                                                <parameter name="replacement" value="`$tmp.service-instance-id`"/>
                                                            </execute>
                                                            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                                                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.csm.serviceinstance.templatefile`" />
                                                                <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.service-url`' />
                                                                <parameter name='restapiUser' value='`$prop.controller.user`' />
                                                                <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                                                                <parameter name='format' value='json' />
                                                                <parameter name='httpMethod' value='PUT' />
                                                                <parameter name="responsePrefix" value="mdsal-sr" />
                                                                <outcome value='failure'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in MD-SAL" />
                                                                    </set>
                                                                </outcome>
                                                            </execute>
                                                            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
	resource="service-instance" 
	key="customer.global-customer-id = $output-global-customer-id
	  AND service-subscription.service-type = $output-service-type
	  AND service-instance.service-instance-id = $tmp.service-instance-id" >
                                                                <parameter name="service-instance-id" value="`$tmp.service-instance-id`" />
                                                                <parameter name="global-customer-id" value="`$output-global-customer-id`" />
                                                                <parameter name="service-type" value="`$output-service-type`" />
                                                                <parameter name="service-role" value="`$output-service-role`" />
                                                                <outcome value='failure'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in AAI" />
                                                                    </set>
                                                                </outcome>
                                                                <outcome value='not-found'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in AAI" />
                                                                    </set>
                                                                </outcome>
                                                            </save>
                                                            <set>
                                                                <parameter name='output-service-instance-id' value='`$tmp.service-instance-id`' />
                                                            </set>
                                                        </block>
                                                    </outcome>
                                                    <outcome value='0'>
                                                        <block>
                                                            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID" >
                                                                <parameter name="ctx-destination" value="tmp.service-instance-id" />
                                                            </execute>
                                                            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                                                                <parameter name="source" value="`$prop.restapi.service`"/>
                                                                <parameter name="outputPath" value="tmp.service-url"/>
                                                                <parameter name="target" value="{service-instance-id}"/>
                                                                <parameter name="replacement" value="`$tmp.service-instance-id`"/>
                                                            </execute>
                                                            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                                                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.csm.serviceinstance.templatefile`" />
                                                                <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.service-url`' />
                                                                <parameter name='restapiUser' value='`$prop.controller.user`' />
                                                                <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                                                                <parameter name='format' value='json' />
                                                                <parameter name='httpMethod' value='PUT' />
                                                                <parameter name="responsePrefix" value="mdsal-sr" />
                                                                <outcome value='failure'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in MD-SAL" />
                                                                    </set>
                                                                </outcome>
                                                            </execute>
                                                            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
	resource="service-instance" 
	key="customer.global-customer-id = $output-global-customer-id
	  AND service-subscription.service-type = $output-service-type
	  AND service-instance.service-instance-id = $tmp.service-instance-id" >
                                                                <parameter name="service-instance-id" value="`$tmp.service-instance-id`" />
                                                                <parameter name="global-customer-id" value="`$output-global-customer-id`" />
                                                                <parameter name="service-type" value="`$output-service-type`" />
                                                                <parameter name="service-role" value="`$output-service-role`" />
                                                                <outcome value='failure'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in AAI" />
                                                                    </set>
                                                                </outcome>
                                                                <outcome value='not-found'>
                                                                    <set>
                                                                        <parameter name='error-message' value="Failure creating service instance in AAI" />
                                                                    </set>
                                                                </outcome>
                                                            </save>
                                                            <set>
                                                                <parameter name='output-service-instance-id' value='`$tmp.service-instance-id`' />
                                                            </set>
                                                        </block>
                                                    </outcome>
                                                </switch>
                                                <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                                                    <parameter name="source" value="`$prop.restapi.forwarding-path`"/>
                                                    <parameter name="outputPath" value="tmp.fp-url"/>
                                                    <parameter name="target" value="{service-instance-id}"/>
                                                    <parameter name="replacement" value="`$output-service-instance-id`"/>
                                                </execute>
                                                <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                                    <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.forwardingpath.templatefile`" />
                                                    <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.fp-url + $forwarding-path.forwarding-path-id`' />
                                                    <parameter name='restapiUser' value='`$prop.controller.user`' />
                                                    <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                                                    <parameter name='format' value='json' />
                                                    <parameter name='httpMethod' value='PUT' />
                                                    <parameter name="responsePrefix" value="mdsal-fp" />
                                                    <outcome value='failure'>
                                                        <set>
                                                            <parameter name='error-message' value="Failure writing forwarding-path to MD-SAL" />
                                                        </set>
                                                    </outcome>
                                                    <outcome value='not-found'>
                                                        <set>
                                                            <parameter name='error-message' value="Failure writing forwarding-path to MD-SAL" />
                                                        </set>
                                                    </outcome>
                                                </execute>
                                                <for index='sp-index' start='0' end='`$service-paths.service-path_length`' >
                                                    <switch test='`$service-paths.service-path[$sp-index].service_length == $serv-cust_length`'>
                                                        <outcome value='true'>
                                                            <block>
                                                                <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
	resource="forwarding-path" 
	key="forwarding-path.forwarding-path-id = $forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id" >
                                                                    <parameter name="forwarding-path-id" value="`$forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id`" />
                                                                    <parameter name="forwarding-path-name" value="`$forwarding-path.service-paths.service-path[$sp-index].service-path-instance-name`" />
                                                                    <parameter name="selflink" value="`'/restconf/config/GENERIC-RESOURCE-API:services/service/'
  + $output-service-instance-id
  + '/forwarding-paths/forwarding-path/'
  + $forwarding-path.forwarding-path-id
  + '/services-paths/service-path/'
  + $forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id`" />
                                                                    <outcome value='failure'>
                                                                        <set>
                                                                            <parameter name='error-message' value="Failure writing forwarding-path to AAI" />
                                                                        </set>
                                                                    </outcome>
                                                                    <outcome value='not-found'>
                                                                        <set>
                                                                            <parameter name='error-message' value="Failure writing forwarding-path to AAI" />
                                                                        </set>
                                                                    </outcome>
                                                                </save>
                                                                <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService"
   resource="forwarding-path:relationship-list"
   key="forwarding-path.forwarding-path-id = $forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id"
   force="true" pfx="tmp.AnAI-data">
                                                                    <parameter name="relationship-list.relationship[0].related-to" value="service-instance" />
                                                                    <parameter name="relationship-list.relationship[0].related-link"
      value="`'/aai/v$/business/customers/customer/'
        + $output-global-customer-id
        + '/service-subscriptions/service-subscription/'
        + $output-service-type
        + '/service-instances/service-instance/'
        + $output-service-instance-id`" />
                                                                    <outcome value='failure'>
                                                                        <set>
                                                                            <parameter name='error-message' value="Failure writing forwarding-path relationship to AAI" />
                                                                        </set>
                                                                    </outcome>
                                                                    <outcome value='not-found'>
                                                                        <set>
                                                                            <parameter name='error-message' value="Failure writing forwarding-path relationship to AAI" />
                                                                        </set>
                                                                    </outcome>
                                                                </save>
                                                                <for index='service-index' start='0' end='`$service-paths.service-path[$sp-index].service_length`' >
                                                                    <for index='vnf-index' start='0' end='`$forwarding-path.service-paths.service-path[$sp-index].service[$service-index].vnfs.vnf_length`' >
                                                                        <block>
                                                                            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
	resource="forwarder" 
	key="forwarding-path.forwarding-path-id = $forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id
	  AND forwarder.sequence = $forwarding-path.service-paths.service-path[$sp-index].service[$service-index].vnfs.vnf[$vnf-index].vnf-path-sequence-id" >
                                                                                <parameter name="sequence" value="`$forwarding-path.service-paths.service-path[$sp-index].service[$service-index].vnfs.vnf[$vnf-index].vnf-path-sequence-id`" />
                                                                                <outcome value='failure'>
                                                                                    <set>
                                                                                        <parameter name='error-message' value="Failure writing forwarder to AAI" />
                                                                                    </set>
                                                                                </outcome>
                                                                                <outcome value='not-found'>
                                                                                    <set>
                                                                                        <parameter name='error-message' value="Failure writing forwarder to AAI" />
                                                                                    </set>
                                                                                </outcome>
                                                                            </save>
                                                                            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService"
   resource="forwarder:relationship-list"
   key="forwarding-path.forwarding-path-id = $forwarding-path.service-paths.service-path[$sp-index].service-path-instance-id
     AND forwarder.sequence = $forwarding-path.service-paths.service-path[$sp-index].service[$service-index].vnfs.vnf[$vnf-index].vnf-path-sequence-id"
   force="true" pfx="tmp.AnAI-data">
                                                                                <parameter name="relationship-list.relationship[0].related-to" value="generic-vnf" />
                                                                                <parameter name="relationship-list.relationship[0].related-link"
      value="`'/aai/v$/network/generic-vnfs/generic-vnf/'
        + $forwarding-path.service-paths.service-path[$sp-index].service[$service-index].vnfs.vnf[$vnf-index].vnf-instance-id`" />
                                                                                <outcome value='failure'>
                                                                                    <set>
                                                                                        <parameter name='error-message' value="Failure writing forwarder relationship to AAI" />
                                                                                    </set>
                                                                                </outcome>
                                                                                <outcome value='not-found'>
                                                                                    <set>
                                                                                        <parameter name='error-message' value="Failure writing forwarder relationship to AAI" />
                                                                                    </set>
                                                                                </outcome>
                                                                            </save>
                                                                        </block>
                                                                    </for>
                                                                </for>
                                                            </block>
                                                        </outcome>
                                                    </switch>
                                                </for>
                                            </block>
                                        </outcome>
                                    </switch>
                                </block>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
            </get-resource>
        </block>
    </method>
</service-logic>