X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fadmin%2FPolicyRestController.java;h=4f0710b3e0450d571954d8e7242a6e77c8d19152;hb=refs%2Fchanges%2F45%2F4445%2F4;hp=75e3d0b8a0f48aa1de5363883d428fd5852e4e82;hpb=7e547eaa55920dfbc9691eab33bb728395b50cf2;p=policy%2Fengine.git 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 data = new ArrayList(); + List 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 data = new ArrayList(); + List data = new ArrayList<>(); data.add("Elastic Search Server is down"); resultList = data; }