diff --git a/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/service/validation/MsisdnValidationService.java b/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/service/validation/MsisdnValidationService.java index d0979c3f..087e27f2 100644 --- a/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/service/validation/MsisdnValidationService.java +++ b/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/service/validation/MsisdnValidationService.java @@ -21,7 +21,7 @@ import com.wso2telco.dep.manageservice.resource.resource.RequestTransferable; import com.wso2telco.dep.manageservice.resource.service.AbstractService; import com.wso2telco.dep.manageservice.resource.util.Messages; -import com.wso2telco.dep.manageservice.resource.util.ServiceUrl; +import com.wso2telco.dep.manageservice.resource.util.ApplicationConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -56,7 +56,7 @@ public Callback executeGet(String authenticationCredential, List pathPar @Override public Callback executePost(RequestTransferable request, String authenticationCredential) { - HttpPost httpPost = new HttpPost(new StringBuilder(super.getUrl(ServiceUrl.MSISDN_VALIDATION_SERVICE)).toString()); + HttpPost httpPost = new HttpPost(ApplicationConfiguration.getMsisdnValidationServiceUrl()); httpPost.setHeader("Content-Type", "application/json"); httpPost.setHeader("Authorization", authenticationCredential); diff --git a/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/util/ApplicationConfiguration.java b/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/util/ApplicationConfiguration.java index 954fd8c5..9f8c1938 100644 --- a/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/util/ApplicationConfiguration.java +++ b/component/manage-service/src/main/java/com/wso2telco/dep/manageservice/resource/util/ApplicationConfiguration.java @@ -17,12 +17,27 @@ import com.wso2telco.core.dbutils.fileutils.PropertyFileReader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.File; import java.util.Properties; public class ApplicationConfiguration { private static final String MANAGE_APP_CONFIG_FILE = "manage.properties"; + private static final String MSISDN_VALIDATION_SERVICE = "MsisdnValidationService"; + private static final Log log = LogFactory.getLog(ApplicationConfiguration.class); + private static String serviceEndpoint = ""; private ApplicationConfiguration() { } @@ -34,4 +49,27 @@ public static Properties readAppConfig() { return properties; } + + public static String getMsisdnValidationServiceUrl() { + if (serviceEndpoint.equals("")) { + String carbonHome = System.getProperty("carbon.home"); + String apiManagerFile = carbonHome + "/repository/conf/api-manager.xml"; + + try { + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + + Document document = builder.parse(new File(apiManagerFile)); + Element rootElement = document.getDocumentElement(); + + NodeList nodeList = rootElement.getElementsByTagName(MSISDN_VALIDATION_SERVICE); + Node node = nodeList.item(0); + + serviceEndpoint = ((Element)node).getTextContent(); + } catch (Exception e) { + String errorMessage = "Error in ApplicationConfiguration.getMsisdnValidationServiceUrl"; + log.error(errorMessage, e); + } + } + return serviceEndpoint; + } } diff --git a/pom.xml b/pom.xml index 07efe426..44e7eced 100644 --- a/pom.xml +++ b/pom.xml @@ -173,7 +173,7 @@ 1.11 2.0 4.4.8 - 2.4.5 + 2.4.6-SNAPSHOT 1.5.8