@startuml
title ** __DSPA Selfcare PCF: getCustomerProfileWithServicePartnerId__ **\n

actor Client #Magenta

participant SelfCareServiceWSController
participant SelfCareService as "<b><color:white>SelfCareService" #Magenta
participant SelfCareUtil
participant IAMManager
participant IAMDao
participant LDAPService
participant IAM_LDAP #DarkSeaGreen
participant TIBCO_EMS

skinparam sequenceGroupBorderColor blue 
group#Magenta <b><color:white> getCustomerProfile_v2

Client -> SelfCareServiceWSController: <font color=blue><b> getCustomerProfile [[https://servicecatalog.internal.t-mobile.com/servicecat/dspa/2016-10-14/wsdl_api/wsdl/SelfCareService.wsdl WSDL]]\n (JAX-RPC XML Request over Http)

note left
URI: /webservice/SelfCareService
Clients : EBILL, STREAMLINE
endnote

SelfCareServiceWSController->SelfCareService: getProfile(msisdn, servicePartnerId, customerType)
SelfCareService-> SelfCareUtil : validateRequest(msisdn, customerType)
alt msisdn doesnot match msisdnPattern or customerType validation failed or servicePartnerd validation failed
	SelfCareUtil->SelfCareService: throws InvalidRequestException
	SelfCareService -> SelfCareServiceWSController : throws InvalidRequestException
	SelfCareServiceWSController -> Client : throws InvalidRequestException
end
alt customerType is not PREPAID
	SelfCareService-> IAMManager : getProfile(msisdn)
	IAMManager-> IAMDao : getProfile(msisdn)
	IAMDao-> LDAPService : ldapSearch(searchCriteria, filterAttributes, searchControls)
	note left : with msisdn in searchCriteria
	LDAPService -> IAM_LDAP : search(rootSuffix, searchCriteria, searchControls, handler)
	IAM_LDAP -> LDAPService : SearchResult List
	LDAPService-> IAMDao : SearchResult
	alt Search Result is empty or doesnot return any attributes
		IAMDao-> IAMManager : throws CustomerNotFoundException, NoSuchMsisdnException
		IAMManager-> SelfCareService : throws CustomerNotFoundException, NoSuchMsisdnException
		SelfCareService -> SelfCareServiceWSController : throws NoSuchMsisdnException
		SelfCareServiceWSController -> Client : throws NoSuchMsisdnException
	end
	IAMDao-> IAMManager : CustomerProfile
	IAMManager-> SelfCareService : CustomerProfile
	alt customerType is PREPAID and multiLineCustomer type is null
		SelfCareService -> SelfCareUtil: getMLCustomerTypeForBlank(profile)

                group#DarkSeaGreen <b>Topic: TMOBILE.<env>.DSPA.TOPIC.PUBLISH, event: 'setMLType', MsgType: 'Publish' 
		  SelfCareService[#blue]-->TIBCO_EMS : [[../../provisioningems/ce.dsg.dice.prov.ems.pcf.publishtopic.setmltype.svg Provisioning_AsncFlow_setMLType]]	
                end
	end
	alt servicePartnerId is not NULL
		SelfCareService -> SelfCareUtil: validate ServicePartnerId with the accountType and accountSubType
		alt validation fails 
			SelfCareUtil-> SelfCareService : throws NoSuchMsisdnException
			SelfCareService -> SelfCareServiceWSController : throws NoSuchMsisdnException
			SelfCareServiceWSController -> Client : throws NoSuchMsisdnException
			SelfCareServiceWSController -> STREAMLINE : throws NoSuchMsisdnException
			SelfCareServiceWSController -> WFM : throws NoSuchMsisdnException
		end
	else 
		SelfCareService -> SelfCareUtil: validate default TMOSERVICEPARTNERID with the accountType and accountSubType
		alt validation fails 
			SelfCareUtil-> SelfCareService : throws NoSuchMsisdnException
			SelfCareService -> SelfCareServiceWSController : throws NoSuchMsisdnException
			SelfCareServiceWSController -> Client : throws NoSuchMsisdnException
		end
	SelfCareService-> SelfCareServiceWSController : CustomerProfile
	SelfCareServiceWSController-[#green]> Client : CustomerProfile
else 
	SelfCareServiceWSController -> Client : throws InvalidRequestException
end
end
@enduml
