Skip to content

Commit

Permalink
Merge pull request #5 from WSO2Telco/dev
Browse files Browse the repository at this point in the history
Dev to master sprint 24A
  • Loading branch information
dsulochana authored Nov 18, 2020
2 parents abdac6c + c266ff2 commit 4e5e2be
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class SendSMSHandler extends AbstractHandler{
public SendSMSHandler(SMSExecutor executor) throws InstantiationException, IllegalAccessException, ClassNotFoundException, ValidatorException{
super();
this.executor = executor;
occi = new OriginatingCountryCalculatorIDD();
occi = new OriginatingCountryCalculatorIDD(true);
responseHandler = new ResponseHandler();
smsMessagingService = new SMSMessagingService();
}
Expand Down Expand Up @@ -290,6 +290,8 @@ private OperatorEndpoint getEndpoint (String address, MessageContext messageCont
*/
@Override
public boolean validate(String httpMethod, String requestPath, JSONObject jsonBody, MessageContext context) throws Exception {
// Setting this property in order to handle errors ESB commonFault seq.
HandlerUtils.setHandlerProperty(context, this.getClass().getSimpleName());
if (!httpMethod.equalsIgnoreCase("POST")) {
((Axis2MessageContext) context).getAxis2MessageContext().setProperty("HTTP_SC", 405);
throw new Exception("Method not allowed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public class OriginatingCountryCalculatorIDD extends OriginatingCountryCalculato
public static String oparatorOnHeaderRegEx = null;
public static String oparatorOnHeaderMCC = null;

private boolean ignoreMSISDNFormatValidation;

public OriginatingCountryCalculatorIDD () {

}

public OriginatingCountryCalculatorIDD (boolean ignoreMSISDNFormatValidation) {
this.ignoreMSISDNFormatValidation = ignoreMSISDNFormatValidation;
}

/*
* (non-Javadoc)
Expand Down Expand Up @@ -249,35 +258,43 @@ public OperatorEndpoint getOperatorEndpoint(
//MSISDN could be in ARC/PCR format
//if (phoneUtil.resourceInMsisdnFormat(searchDTO.getMSISDN())) {

MSISDN numberProto = null;
int countryCode = 0;
//Check MSIDN in typical format
try {
numberProto = phoneUtil.parse(searchDTO.getMSISDN());
if (numberProto != null) {
if (!ignoreMSISDNFormatValidation) {
MSISDN numberProto = null;
int countryCode = 0;
//Check MSIDN in typical format
try {
numberProto = phoneUtil.parse(searchDTO.getMSISDN());
if (numberProto != null) {
/**
* obtain the country code form the phone number object
*/
countryCode = numberProto.getCountryCode();
}

/**
* obtain the country code form the phone number object
* if the country code within the header look up context , the
* operator taken from the header object
*/
if (countryLookUpOnHeader.contains(String.valueOf(countryCode))) {
operator = operatorCode;
}
/**
* build the MSISDN
*/
countryCode = numberProto.getCountryCode();
}

/**
* if the country code within the header look up context , the
* operator taken from the header object
*/
if (countryLookUpOnHeader.contains(String.valueOf(countryCode))) {
operator = operatorCode;
}
/**
* build the MSISDN
*/

if (numberProto != null) {
if (numberProto != null) {

msisdn.append("+").append(numberProto.getCountryCode())
.append(numberProto.getNationalNumber());
msisdn.append("+").append(numberProto.getCountryCode())
.append(numberProto.getNationalNumber());
}
} catch (InvalidMSISDNException e) {
//number in either ARC/PCR format. number already validated from oneapi validation
//operator fetched from header
if (operatorCode != null) {
operator = operatorCode;
}
}
} catch (InvalidMSISDNException e) {
} else {
//number in either ARC/PCR format. number already validated from oneapi validation
//operator fetched from header
if (operatorCode != null) {
Expand Down

0 comments on commit 4e5e2be

Please sign in to comment.