X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FPolicyExportAndImportController.java;fp=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FPolicyExportAndImportController.java;h=7618989ef34ca14dd2b1c8482d17f0fb9940fb5b;hb=b65e96826d7339ce29ddb73e3ed6775bd4f54753;hp=5978f145ecb0b9b961d58a42e488714fe143266e;hpb=38261bb20e49c39f710aef47b5415dcdf14a1729;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java index 5978f145e..7618989ef 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java @@ -116,12 +116,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController { PolicyExportAndImportController.commonClassDao = commonClassDao; } - public PolicyExportAndImportController(){} + public PolicyExportAndImportController(){ + // Empty constructor + } @RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{ try{ - String file = null; + String file; selectedPolicy = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -209,8 +211,8 @@ public class PolicyExportAndImportController extends RestrictedBaseController { boolean configExists = false; boolean actionExists = false; String configName = null; - String scope = null; - boolean finalColumn = false; + String scope; + boolean finalColumn; PolicyController controller = policyController != null ? getPolicyController() : new PolicyController(); String userId = UserUtils.getUserSession(request).getOrgUserId(); UserInfo userInfo = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", userId); @@ -251,19 +253,19 @@ public class PolicyExportAndImportController extends RestrictedBaseController { Iterator cellIterator = currentRow.cellIterator(); while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); - if (getCellHeaderName(cell).equalsIgnoreCase("policyName")) { + if ("policyName".equalsIgnoreCase(getCellHeaderName(cell))) { policyEntity.setPolicyName(cell.getStringCellValue()); } - if (getCellHeaderName(cell).equalsIgnoreCase("scope")) { + if ("scope".equalsIgnoreCase(getCellHeaderName(cell))) { policyEntity.setScope(cell.getStringCellValue()); } - if (getCellHeaderName(cell).equalsIgnoreCase("policyData")) { + if ("policyData".equalsIgnoreCase(getCellHeaderName(cell))) { policyEntity.setPolicyData(cell.getStringCellValue()); } - if (getCellHeaderName(cell).equalsIgnoreCase("description")) { + if ("description".equalsIgnoreCase(getCellHeaderName(cell))) { policyEntity.setDescription(cell.getStringCellValue()); } - if (getCellHeaderName(cell).equalsIgnoreCase("configurationbody")) { + if ("configurationbody".equalsIgnoreCase(getCellHeaderName(cell))) { if(policyEntity.getPolicyName().contains("Config_")){ configExists = true; configurationDataEntity.setConfigBody(cell.getStringCellValue()); @@ -272,7 +274,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { actionBodyEntity.setActionBody(cell.getStringCellValue()); } } - if (getCellHeaderName(cell).equalsIgnoreCase("configurationName")) { + if ("configurationName".equalsIgnoreCase(getCellHeaderName(cell))) { finalColumn = true; configName = cell.getStringCellValue(); if(policyEntity.getPolicyName().contains("Config_")){ @@ -312,7 +314,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { } if (roles.contains(ADMIN) || roles.contains(EDITOR)) { if(scopes.isEmpty()){ - //return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin"); + logger.error("No Scopes has been Assigned to the User. Please, Contact Super-Admin"); }else{ //1. if Role contains admin, then check if parent scope has role admin, if not don't create a scope and add to list. if(roles.contains(ADMIN)){