From: AvinashS Date: Tue, 5 Sep 2017 10:28:22 +0000 (+0530) Subject: Sonar fixes for Policy engine X-Git-Tag: v1.1.0~90 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=commitdiff_plain;h=1628052b1b8a6fd4d784b82c8266367d2c203ace Sonar fixes for Policy engine Remaining critical and few major issues fix. Change-Id: I5e602e377bd52877b1c791d4e00f79feceec391f IssueId: POLICY-174 Signed-off-by: AvinashS --- diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java index eaa0bb409..75b02ab58 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java @@ -212,7 +212,7 @@ public class ActionPolicyDictionaryController { } } catch (Exception e){ - LOGGER.error(e.getMessage()); + LOGGER.error(e); response.setCharacterEncoding(utf8); request.setCharacterEncoding(utf8); PrintWriter out = response.getWriter(); @@ -242,7 +242,7 @@ public class ActionPolicyDictionaryController { return null; } catch (Exception e){ - LOGGER.error(e.getMessage()); + LOGGER.error(e); response.setCharacterEncoding(utf8); request.setCharacterEncoding(utf8); PrintWriter out = response.getWriter(); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java index beee437e4..e09c9ce50 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java @@ -130,7 +130,7 @@ public class BRMSDictionaryController{ } @RequestMapping(value={"/brms_dictionary/set_BRMSParamData"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) - public void SetRuleData(HttpServletRequest request) throws IOException{ + public static void setRuleData(HttpServletRequest request) throws IOException{ StringWriter writer = new StringWriter(); IOUtils.copy(request.getInputStream() , writer, StandardCharsets.UTF_8); String cleanStreamBoundary = writer.toString().replaceFirst("------(.*)(?s).*octet-stream", ""); @@ -306,9 +306,8 @@ public class BRMSDictionaryController{ //check if update operation or create, get id for data to be updated if ((update).equals(request.getParameter(operation))) { List duplicateData = commonClassDao.checkDuplicateEntry(brmsDependency.getDependencyName(), dependencyName, BRMSDependency.class); - int id = 0; BRMSDependency data = (BRMSDependency) duplicateData.get(0); - id = data.getId(); + int id = data.getId(); brmsDependency.setId(id); brmsDependency.setUserCreatedBy(this.getUserInfo(userId)); } @@ -461,9 +460,8 @@ public class BRMSDictionaryController{ //check if update operation or create, get id for data to be updated if ((update).equals(request.getParameter(operation))) { List duplicateData = commonClassDao.checkDuplicateEntry(brmsController.getControllerName(), controllerName, BRMSController.class); - int id = 0; BRMSController data = (BRMSController) duplicateData.get(0); - id = data.getId(); + int id = data.getId(); brmsController.setId(id); brmsController.setUserCreatedBy(this.getUserInfo(userId)); } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java index 719d8dafa..62b830d6d 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java @@ -83,10 +83,9 @@ public class DictionaryImportController { @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) - public void ImportDictionaryData(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{ + public void ImportDictionaryData(HttpServletRequest request) throws IOException{ ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //JsonNode root = mapper.readTree(request.getReader()); String userId = request.getParameter("userId"); String dictionaryName = request.getParameter("dictionaryName"); @@ -106,26 +105,26 @@ public class DictionaryImportController { attribute.setUserModifiedBy(userinfo); String[] rows = dictSheet.get(i); for (int j=0 ; j