1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.samples.voipservice.service; |
12 | |
|
13 | |
import org.mule.impl.MuleMessage; |
14 | |
import org.mule.impl.RequestContext; |
15 | |
import org.mule.samples.voipservice.interfaces.AddressValidation; |
16 | |
import org.mule.samples.voipservice.to.CreditProfileTO; |
17 | |
import org.mule.samples.voipservice.to.ServiceParamTO; |
18 | |
import org.mule.umo.UMOEventContext; |
19 | |
import org.mule.umo.UMOMessage; |
20 | |
|
21 | |
import java.util.HashMap; |
22 | |
import java.util.List; |
23 | |
import java.util.Map; |
24 | |
|
25 | |
import org.apache.commons.logging.Log; |
26 | |
import org.apache.commons.logging.LogFactory; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public class SyncVoipBroker |
32 | |
{ |
33 | |
|
34 | 0 | protected static transient Log logger = LogFactory.getLog(SyncVoipBroker.class); |
35 | |
|
36 | |
public UMOMessage validate(ServiceParamTO serviceParamTO) throws Exception |
37 | |
{ |
38 | |
|
39 | 0 | logger.info("Inside Method : " + serviceParamTO); |
40 | |
|
41 | 0 | UMOMessage msg = null; |
42 | 0 | List endPoints = null; |
43 | 0 | UMOEventContext umoEventContext = RequestContext.getEventContext(); |
44 | 0 | UMOMessage umoMessage = umoEventContext.sendEvent(serviceParamTO.getCustomer().getAddress()); |
45 | 0 | Integer isValidAddress = (Integer)umoMessage.getPayload(); |
46 | 0 | if (isValidAddress.intValue() == AddressValidation.SUCCESS) |
47 | |
{ |
48 | 0 | umoMessage = umoEventContext.sendEvent(serviceParamTO.getCreditCard().getCardType()); |
49 | 0 | endPoints = (List)umoMessage.getPayload(); |
50 | 0 | logger.info("Inside Method : isValidAddress = " + isValidAddress + "; endPoints = " + endPoints); |
51 | 0 | Map props = new HashMap(); |
52 | 0 | props.put("recipients", endPoints); |
53 | 0 | msg = new MuleMessage(new CreditProfileTO(serviceParamTO.getCustomer()), props); |
54 | 0 | umoEventContext.dispatchEvent(msg); |
55 | 0 | umoEventContext.setStopFurtherProcessing(true); |
56 | |
} |
57 | 0 | return msg; |
58 | |
} |
59 | |
} |