Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,7 +56,7 @@ public Callback executeGet(String authenticationCredential, List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<com.esotericsoftware.yamlbeans.version>1.11</com.esotericsoftware.yamlbeans.version>
<org.apache.commons.version>2.0</org.apache.commons.version>
<org.wso2.carbon.version>4.4.8</org.wso2.carbon.version>
<com.wso2telco.core.version>2.4.5</com.wso2telco.core.version>
<com.wso2telco.core.version>2.4.6-SNAPSHOT</com.wso2telco.core.version>
<carbon.p2.plugin.version>1.5.8</carbon.p2.plugin.version>
</properties>
</project>