diff options
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java')
-rw-r--r-- | POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java index 75e3d0b8a..4f0710b3e 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java @@ -246,7 +246,7 @@ public class PolicyRestController extends RestrictedBaseController{ String newFile = file.toString(); uri = uri +"&dictionaryName="+newFile; } catch (Exception e2) { - e2.printStackTrace(); + LOGGER.error("Exception Occured while calling PAP with import dictionary request"+e2); } } @@ -270,7 +270,7 @@ public class PolicyRestController extends RestrictedBaseController{ try { root = mapper.readTree(request.getReader()); }catch (Exception e1) { - e1.printStackTrace(); + LOGGER.error("Exception Occured while calling PAP"+e1); } ObjectMapper mapper1 = new ObjectMapper(); @@ -281,7 +281,7 @@ public class PolicyRestController extends RestrictedBaseController{ Object content = new ByteArrayInputStream(json.getBytes()); - if (content != null && (content instanceof InputStream)) { + if (content instanceof InputStream) { // send current configuration try (OutputStream os = connection.getOutputStream()) { int count = IOUtils.copy((InputStream) content, os); @@ -300,7 +300,9 @@ public class PolicyRestController extends RestrictedBaseController{ boundary = "===" + System.currentTimeMillis() + "==="; connection.setRequestProperty("Content-Type","multipart/form-data; boundary=" + boundary); try (OutputStream os = connection.getOutputStream()) { - IOUtils.copy((InputStream) item.getInputStream(), os); + if(item != null){ + IOUtils.copy((InputStream) item.getInputStream(), os); + } } } } @@ -385,7 +387,7 @@ public class PolicyRestController extends RestrictedBaseController{ String uri = request.getRequestURI(); String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim()); if(body.contains("CouldNotConnectException")){ - List<String> data = new ArrayList<String>(); + List<String> data = new ArrayList<>(); data.add("Elastic Search Server is down"); resultList = data; }else{ @@ -411,7 +413,7 @@ public class PolicyRestController extends RestrictedBaseController{ try{ resultList = json.get("policyresult"); }catch(Exception e){ - List<String> data = new ArrayList<String>(); + List<String> data = new ArrayList<>(); data.add("Elastic Search Server is down"); resultList = data; } |