Skip to content

Commit 4e5e2be

Browse files
authoredNov 18, 2020
Merge pull request #5 from WSO2Telco/dev
Dev to master sprint 24A
2 parents abdac6c + c266ff2 commit 4e5e2be

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed
 

‎mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public class SendSMSHandler extends AbstractHandler{
110110
public SendSMSHandler(SMSExecutor executor) throws InstantiationException, IllegalAccessException, ClassNotFoundException, ValidatorException{
111111
super();
112112
this.executor = executor;
113-
occi = new OriginatingCountryCalculatorIDD();
113+
occi = new OriginatingCountryCalculatorIDD(true);
114114
responseHandler = new ResponseHandler();
115115
smsMessagingService = new SMSMessagingService();
116116
}
@@ -290,6 +290,8 @@ private OperatorEndpoint getEndpoint (String address, MessageContext messageCont
290290
*/
291291
@Override
292292
public boolean validate(String httpMethod, String requestPath, JSONObject jsonBody, MessageContext context) throws Exception {
293+
// Setting this property in order to handle errors ESB commonFault seq.
294+
HandlerUtils.setHandlerProperty(context, this.getClass().getSimpleName());
293295
if (!httpMethod.equalsIgnoreCase("POST")) {
294296
((Axis2MessageContext) context).getAxis2MessageContext().setProperty("HTTP_SC", 405);
295297
throw new Exception("Method not allowed");

‎mediation-old/src/main/java/com/wso2telco/dep/mediator/mediationrule/OriginatingCountryCalculatorIDD.java

+41-24
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ public class OriginatingCountryCalculatorIDD extends OriginatingCountryCalculato
8181
public static String oparatorOnHeaderRegEx = null;
8282
public static String oparatorOnHeaderMCC = null;
8383

84+
private boolean ignoreMSISDNFormatValidation;
85+
86+
public OriginatingCountryCalculatorIDD () {
87+
88+
}
89+
90+
public OriginatingCountryCalculatorIDD (boolean ignoreMSISDNFormatValidation) {
91+
this.ignoreMSISDNFormatValidation = ignoreMSISDNFormatValidation;
92+
}
8493

8594
/*
8695
* (non-Javadoc)
@@ -249,35 +258,43 @@ public OperatorEndpoint getOperatorEndpoint(
249258
//MSISDN could be in ARC/PCR format
250259
//if (phoneUtil.resourceInMsisdnFormat(searchDTO.getMSISDN())) {
251260

252-
MSISDN numberProto = null;
253-
int countryCode = 0;
254-
//Check MSIDN in typical format
255-
try {
256-
numberProto = phoneUtil.parse(searchDTO.getMSISDN());
257-
if (numberProto != null) {
261+
if (!ignoreMSISDNFormatValidation) {
262+
MSISDN numberProto = null;
263+
int countryCode = 0;
264+
//Check MSIDN in typical format
265+
try {
266+
numberProto = phoneUtil.parse(searchDTO.getMSISDN());
267+
if (numberProto != null) {
268+
/**
269+
* obtain the country code form the phone number object
270+
*/
271+
countryCode = numberProto.getCountryCode();
272+
}
273+
258274
/**
259-
* obtain the country code form the phone number object
275+
* if the country code within the header look up context , the
276+
* operator taken from the header object
277+
*/
278+
if (countryLookUpOnHeader.contains(String.valueOf(countryCode))) {
279+
operator = operatorCode;
280+
}
281+
/**
282+
* build the MSISDN
260283
*/
261-
countryCode = numberProto.getCountryCode();
262-
}
263-
264-
/**
265-
* if the country code within the header look up context , the
266-
* operator taken from the header object
267-
*/
268-
if (countryLookUpOnHeader.contains(String.valueOf(countryCode))) {
269-
operator = operatorCode;
270-
}
271-
/**
272-
* build the MSISDN
273-
*/
274284

275-
if (numberProto != null) {
285+
if (numberProto != null) {
276286

277-
msisdn.append("+").append(numberProto.getCountryCode())
278-
.append(numberProto.getNationalNumber());
287+
msisdn.append("+").append(numberProto.getCountryCode())
288+
.append(numberProto.getNationalNumber());
289+
}
290+
} catch (InvalidMSISDNException e) {
291+
//number in either ARC/PCR format. number already validated from oneapi validation
292+
//operator fetched from header
293+
if (operatorCode != null) {
294+
operator = operatorCode;
295+
}
279296
}
280-
} catch (InvalidMSISDNException e) {
297+
} else {
281298
//number in either ARC/PCR format. number already validated from oneapi validation
282299
//operator fetched from header
283300
if (operatorCode != null) {

0 commit comments

Comments
 (0)
Please sign in to comment.