diff options
author | Hailong Zhang <zhanghailong22@huawei.com> | 2019-09-06 09:39:46 +0800 |
---|---|---|
committer | Weitao Gao <victor.gao@huawei.com> | 2019-10-14 06:52:48 +0000 |
commit | a671d6f99e5533e729015f3bba74b36d03a890f4 (patch) | |
tree | 9b43ab2ec3bdf440f4e4d7022ccc31be636b8584 /vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution | |
parent | 51041bd80a870aad7bc3ad135e28221d5445b25d (diff) |
modify Sonar Issue
Issue-ID: VNFSDK-462
Signed-off-by: Hailong Zhang <zhanghailong22@huawei.com>
Change-Id: I1bd7cbff0d3d444613991ae0dd2c8146107ea891
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution')
-rw-r--r-- | vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java index 83db8e8b..9eb2a7b7 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java @@ -86,8 +86,7 @@ public class VTPExecutionResource extends VTPResource{ private static final String ERROR = "error"; private static final String FILE = "file://"; - - public VTPTestExecutionList executeHandler(VTPTestExecutionList executions, String requestId) throws Exception { + public VTPTestExecutionList executeHandler(VTPTestExecutionList executions, String requestId) throws VTPException { if (requestId == null) { requestId = UUID.randomUUID().toString(); } @@ -121,10 +120,18 @@ public class VTPExecutionResource extends VTPResource{ ObjectMapper mapper = new ObjectMapper(); Map<String,String> m = output.getAttrsMap(); if ((m.containsKey(ERROR)) && (!StringUtils.equals(m.get(ERROR), "{}"))) { - execution.setResults(mapper.readTree(m.get(ERROR))); + try { + execution.setResults(mapper.readTree(m.get(ERROR))); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } } else if (m.containsKey("results")) { - execution.setResults(mapper.readTree(m.get("results"))); + try { + execution.setResults(mapper.readTree(m.get("results"))); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } } } @@ -174,10 +181,15 @@ public class VTPExecutionResource extends VTPResource{ public Response executeTestcases( @ApiParam(value = "Request Id") @QueryParam("requestId") String requestId, @ApiParam(value = "Testcase File arguments", required = false) @FormDataParam("file") List<FormDataBodyPart> bodyParts, - @FormDataParam("executions") String executionsJson) throws Exception { + @FormDataParam("executions") String executionsJson) throws VTPException { VTPTestExecutionList executions = new VTPTestExecution.VTPTestExecutionList(); - Map<String, String> map = this.storeTestCaseInputFiles(bodyParts); + Map<String, String> map = null; + try { + map = this.storeTestCaseInputFiles(bodyParts); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } for (Map.Entry<String, String> entry: map.entrySet()) { if (executionsJson.contains(FILE + entry.getKey())) { @@ -193,13 +205,21 @@ public class VTPExecutionResource extends VTPResource{ } - executions.setExecutions( - new ObjectMapper().readValue(executionsJson, new TypeReference<List<VTPTestExecution>>(){})); + try { + executions.setExecutions( + new ObjectMapper().readValue(executionsJson, new TypeReference<List<VTPTestExecution>>(){})); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } executions = this.executeHandler(executions, requestId); for (Map.Entry<String, String> entry: map.entrySet()) { - FileUtils.forceDelete(new File(entry.getValue())); + try { + FileUtils.forceDelete(new File(entry.getValue())); + } catch (IOException e) { + LOG.error("IOException occurs",e); + } } return Response.ok(executions.getExecutions().toString(), MediaType.APPLICATION_JSON).build(); @@ -366,7 +386,7 @@ public class VTPExecutionResource extends VTPResource{ resultJson = mapper.readTree(result.get(OUTPUT).toString()); } } catch (Exception e) { - LOG.error("Exception occirs", e); + LOG.error("Exception occurs", e); ObjectNode node = JsonNodeFactory.instance.objectNode(); node.put(ERROR, result.get(OUTPUT).asText()); resultJson = node; |