sonar fix:blocker issues in MsbMgmrImpl 35/35735/1
authorajay priyadarshi <ajay.priyadarshi@ril.com>
Wed, 14 Mar 2018 10:24:24 +0000 (15:54 +0530)
committerajay priyadarshi <ajay.priyadarshi@ril.com>
Wed, 14 Mar 2018 10:24:24 +0000 (15:54 +0530)
msb/impl/MsbMgmrImpl.java
file name: MsbMgmrImpl.java

Change-Id: Id4b9bc227819e0a3d657546c87d1182c86801bee
Issue-ID: VFC-817
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java

index 74fb439..cd4c7e3 100644 (file)
@@ -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"));
-//     }
-
 }