diff options
author | Yan Yang <yangyanyj@chinamobile.com> | 2018-03-15 01:01:05 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-15 01:01:05 +0000 |
commit | 8b8ce2eae2f81941d78b33c9441ba77155aae30e (patch) | |
tree | b38d6b82feceab718b9757f4a6a45829e6943704 /nokia/vnfmdriver | |
parent | 7be67ce15344a4693eeace4127ca6b155dbbc333 (diff) | |
parent | e9a2ffe8e5e947ca5c408bd7f1f5a45cdc977ff9 (diff) |
Merge "sonar fix:blocker issues in MsbMgmrImpl"
Diffstat (limited to 'nokia/vnfmdriver')
-rw-r--r-- | nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java index 74fb4395..cd4c7e31 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java @@ -115,42 +115,43 @@ public class MsbMgmrImpl implements IMsbMgmr { } - public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws ClientProtocolException, IOException { - String url = adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_QUERY_SERVICE_PATH, serviceName, version); - - HttpResult httpResult = httpClientProcessor.process(url, RequestMethod.GET, null, null); - - String responseStr = httpResult.getContent(); - logger.info("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion, responseStr is " + responseStr); - String serviceUrl = ""; - if(httpResult.getStatusCode() == 200) - { - MsbServiceInfo serviceInfo = gson.fromJson(responseStr, MsbServiceInfo.class); - if (null == serviceInfo) { - logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version); + public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws IOException { + try{ + String url = adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_QUERY_SERVICE_PATH, serviceName, version); + + HttpResult httpResult = httpClientProcessor.process(url, RequestMethod.GET, null, null); + + String responseStr = httpResult.getContent(); + logger.info("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion, responseStr is " + responseStr); + String serviceUrl = ""; + if(httpResult.getStatusCode() == 200) + { + MsbServiceInfo serviceInfo = gson.fromJson(responseStr, MsbServiceInfo.class); + if (null == serviceInfo) { + logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version); + } + else{ + serviceUrl = serviceInfo.getUrl(); + logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl); + } } - - serviceUrl = serviceInfo.getUrl(); - logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl); - } - else - { - logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error, statusCode = " + httpResult.getStatusCode()); - } + else + { + logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error, statusCode = " + httpResult.getStatusCode()); + } + + return serviceUrl; + }catch(Exception e){ + logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error", e); + throw new IOException("getServiceUrlInMsbBySeriveNameAndVersion", e); - return serviceUrl; + } + } public void setAdaptorEnv(AdaptorEnv env) { this.adaptorEnv = env; } -// public static final void main(String[] args) { -//// MsbMgmrImpl impl = new MsbMgmrImpl(); -//// impl.register(); -// System.setProperty("catalina.base", "D:\\Install\\apache-tomcat-9.0.0.M26"); -// System.out.println(System.getProperty("catalina.base")); -// } - } |