Blocker and critical sonar fix 21/12121/1
authorAvinashS <avinash.s@huawei.com>
Wed, 13 Sep 2017 08:49:07 +0000 (14:19 +0530)
committerAvinashS <avinash.s@huawei.com>
Wed, 13 Sep 2017 08:49:07 +0000 (14:19 +0530)
Few Blocker and critical sonar fixes
to help proceed with code reorganization
and milestone requirement.

Change-Id: Id8c8570d538a40fa910f4cceeca9d04c7d244d2f
IssueId: VNFSDK-80
Signed-off-by: AvinashS <avinash.s@huawei.com>
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/HttpFileManagerImpl.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/rest/RestfulClient.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapperUtil.java

index 815acb7..564e7d7 100644 (file)
@@ -156,7 +156,7 @@ public final class FileUtil {
                 inputStream.close();
             }
         } catch (Exception e1) {
-            logger.info("close InputStream error!");
+            logger.info("error while closing InputStream!", e1);
         }
     }
 
@@ -171,7 +171,7 @@ public final class FileUtil {
                 outputStream.close();
             }
         } catch (Exception e1) {
-            logger.info("close OutputStream error!");
+            logger.info("error while closing OutputStream!", e1);
         }
     }
     
@@ -181,7 +181,7 @@ public final class FileUtil {
                 ifs.close();
             }
         } catch (Exception e1) {
-            logger.info("close OutputStream error!");
+            logger.info("error while closing OutputStream", e1);
         }
     }
 
@@ -197,7 +197,7 @@ public final class FileUtil {
                 zipFile = null;
             }
         } catch (IOException e1) {
-            logger.info("close ZipFile error!");
+            logger.info("close ZipFile error!", e1);
         }
     }
 
@@ -231,15 +231,15 @@ public final class FileUtil {
         } 
         catch (JsonGenerationException e) 
         {
-            logger.info("JsonGenerationException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("JsonGenerationException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
         } 
         catch (JsonMappingException e) 
         {
-            logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
         } 
         catch (IOException e) 
         {
-            logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e);
         } 
         return bResult;
     }
@@ -263,15 +263,15 @@ public final class FileUtil {
         } 
         catch (JsonParseException e1) 
         {
-            logger.info("JsonParseException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("JsonParseException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
         } 
         catch (JsonMappingException e1) 
         {
-            logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("JsonMappingException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
         } 
         catch (IOException e1) 
         {
-            logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath);
+            logger.info("IOException Exception: writeJsonDatatoFile-->"+fileAbsPath, e1);
         }
         return obj;
     }
index d45e175..2409093 100644 (file)
@@ -41,7 +41,7 @@ public class HttpFileManagerImpl implements FileManager {
       ToolUtil.copyDirectory(srcPath, targetDir, true);
     } catch (IOException e1) {
       flag = false;
-      LOGGER.error("copy file failed.errorMsg:" + e1.getMessage());
+      LOGGER.error("ErrorMsg: failed to copy file:", e1);
     }
     LOGGER.info("upload file success!");
     return flag;
index 69f4675..38ca579 100644 (file)
@@ -145,12 +145,15 @@ public class LifecycleTestExceutor
         {
             dataMap = (Map<String, String>)mapper.readValue(strJsonData, Map.class);
         } catch(JsonParseException e) {
-            logger.error("JsonParseException:Failed to upload package to catalouge:");
+            logger.error("JsonParseException:Failed to upload package to catalouge:", e);
         } catch(JsonMappingException e) {
-            logger.error("JsonMappingException:Failed to upload package to catalouge:");
+            logger.error("JsonMappingException:Failed to upload package to catalouge:", e);
         } catch(IOException e) {
-            logger.error("IOException:Failed to upload package to catalouge:");
+            logger.error("IOException:Failed to upload package to catalouge:", e);
         }
+        if(dataMap.get("csarId") != null){
         return dataMap.get("csarId");
+        }
+        return "";
     }
 }
index ecc79a1..093afce 100644 (file)
@@ -75,15 +75,13 @@ public class RestfulClient {
                 result.setResult(EntityUtils.toString(entity));
             }
         } catch (Exception e1) {
-            logger.error("send get rest request error:", e1.getMessage());
+            logger.error("send get rest request error:", e1);
         } finally {
-            if (httpclient != null) {
                 try {
                     httpclient.close();
                 } catch (IOException e2) {
-                    logger.error("close httpclient error:", e2.getMessage());
+                    logger.error("close httpclient error:", e2);
                 }
-            }
         }
         return result;
     }
@@ -150,7 +148,7 @@ public class RestfulClient {
         } 
         catch (Exception ex) 
         {
-            logger.error("Send Post request error:", ex.getMessage());
+            logger.error("Send Post request error:", ex);
         } 
         finally 
         {
@@ -160,7 +158,7 @@ public class RestfulClient {
                 }
             } 
             catch(IOException e){
-                logger.error("IOException :Send Post request error:", e.getMessage());
+                logger.error("IOException :Send Post request error:", e);
             }
         }
         return result;
index 3bb383f..8545aa6 100644 (file)
@@ -145,7 +145,7 @@ public class PackageWrapper {
             result = PackageWrapperUtil.packageDataList2PackageMetaList(dbresult);
             return Response.ok(ToolUtil.objectToString(result)).build();
         } catch (MarketplaceResourceException e1) {
-            LOG.error("query package by csarId from db error ! " + e1.getMessage());
+            LOG.error("query package by csarId from db error ! ", e1);
             return RestUtil.getRestException(e1.getMessage());
         }
     }
@@ -594,7 +594,7 @@ public class PackageWrapper {
             } 
             catch (InterruptedException e) 
             {
-                LOG.info("handleDelayExex response : " + e.getMessage());
+                LOG.info("handleDelayExex response : ", e);
             }
         }
     }
index a133490..707f5e6 100644 (file)
@@ -114,7 +114,7 @@ public class PackageWrapperUtil {
         result = PackageManager.getInstance().queryPackageByCsarId(csarId).get(0);
       }
     } catch (MarketplaceResourceException e1) {
-      LOG.error("query package by csarId from db error ! " + e1.getMessage());
+      LOG.error("query package by csarId from db error ! ", e1);
     }
     return result;
   }
@@ -171,7 +171,7 @@ public class PackageWrapperUtil {
       packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
       downloadUri = packageList.get(0).getDownloadUri();
     } catch (MarketplaceResourceException e1) {
-      LOG.error("Query CSAR package by ID failed ! csarId = " + csarId);
+      LOG.error("Query CSAR package by ID failed ! csarId = " + csarId, e1);
     }
     return downloadUri;
   }
@@ -289,7 +289,7 @@ public class PackageWrapperUtil {
         }
       }
     } catch (IOException e1) {
-      LOG.error("judge package type error ! " + e1.getMessage());
+      LOG.error("judge package type error ! ", e1);
     }
     if (isXmlCsar) {
       basicInfo.setFormat(CommonConstant.PACKAGE_XML_FORMAT);
@@ -332,7 +332,7 @@ public class PackageWrapperUtil {
         try {
           reader.close();
         } catch (IOException e1) {
-          LOG.error("close reader failed ! " + e1.getMessage());
+          LOG.error("close reader failed ! ", e1);
         }
       }
     }