From e13d8ef522c0d88db2ad11407b1e2e1ee38e3743 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Sat, 23 Sep 2017 17:43:59 +0800 Subject: catch IOException inside function major: L172 L415 Change-Id: Idf61115ba45477f66323af0423f29c6eb5b5028b Signed-off-by: Harry Huang Issue-Id: VNFSDK-85 --- .../vnfsdk/marketplace/wrapper/PackageWrapper.java | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/main/java/org') diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java index 97b96b88..b3773c5f 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java @@ -170,12 +170,16 @@ public class PackageWrapper { * @throws Exception e */ public Response uploadPackage(InputStream uploadedInputStream, - FormDataContentDisposition fileDetail, String details, HttpHeaders head) throws IOException, MarketplaceResourceException + FormDataContentDisposition fileDetail, String details, HttpHeaders head) throws MarketplaceResourceException { LOG.info("Upload/Reupload request Received !!!!"); - - String packageId = MarketplaceDbUtil.generateId(); - return handlePackageUpload(packageId,uploadedInputStream, fileDetail, details, head); + try { + String packageId = MarketplaceDbUtil.generateId(); + return handlePackageUpload(packageId,uploadedInputStream, fileDetail, details, head); + } catch (IOException e) { + LOG.error("can't get package id", e); + } + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } /** @@ -416,12 +420,12 @@ public class PackageWrapper { InputStream uploadedInputStream, FormDataContentDisposition fileDetail, String details, - HttpHeaders head) throws IOException, MarketplaceResourceException + HttpHeaders head) throws MarketplaceResourceException { LOG.info("Reupload request Received !!!!"); - //STEP 1: Validate Input Data - //---------------------------- + //STEP 1: Validate Input Data + //---------------------------- boolean bResult = handleDataValidate(csarId,uploadedInputStream,fileDetail); if(!bResult) { @@ -429,13 +433,18 @@ public class PackageWrapper { return Response.status(Status.EXPECTATION_FAILED).build(); } - //STEP 2: Delete All Package Data based on package id - //---------------------------------------------------- - deletePackageDataById(csarId); + try { + //STEP 2: Delete All Package Data based on package id + //---------------------------------------------------- + deletePackageDataById(csarId); - //STEP 3: upload package with same package id - //------------------------------------------- - return handlePackageUpload(csarId,uploadedInputStream, fileDetail, details, head); + //STEP 3: upload package with same package id + //------------------------------------------- + return handlePackageUpload(csarId,uploadedInputStream, fileDetail, details, head); + } catch (IOException e) { + LOG.error("delete package failed", e); + } + return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } /** -- cgit 1.2.3-korg