From 37f41576d21e394cde66dc2ccea2b28916eba340 Mon Sep 17 00:00:00 2001 From: Damith Sulochana Date: Thu, 5 Nov 2020 15:27:54 +0530 Subject: [PATCH 1/2] Bug fix around MTN EP discovery --- .../impl/smsmessaging/SendSMSHandler.java | 2 +- .../OriginatingCountryCalculatorIDD.java | 65 ++++++++++++------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java index f897be2..1407173 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java @@ -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(); } diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/mediationrule/OriginatingCountryCalculatorIDD.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/mediationrule/OriginatingCountryCalculatorIDD.java index 6a91fd2..ead9e1d 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/mediationrule/OriginatingCountryCalculatorIDD.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/mediationrule/OriginatingCountryCalculatorIDD.java @@ -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) @@ -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) { From 6bd4a5f435b1f52ef1816325ee50bb94624f4033 Mon Sep 17 00:00:00 2001 From: Damith Sulochana Date: Wed, 11 Nov 2020 12:42:43 +0530 Subject: [PATCH 2/2] Setting this HANDLER property in before validaition in order to handle errors ESB commonFault seq --- .../dep/mediator/impl/smsmessaging/SendSMSHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java index 1407173..7efd91b 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/smsmessaging/SendSMSHandler.java @@ -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");