X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fcontroller%2FPolicyExportAndImportController.java;h=8fe2d492f976a893725a6fda6ae5badd3719e82e;hb=4ca818fdfb9b807562166800a086b413593d6894;hp=b6899e0419a164975b9c472b94458560383a2995;hpb=e0addf5b588a1244f9679becd90999dfcb4c3a94;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java index b6899e041..8fe2d492f 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java @@ -89,6 +89,23 @@ public class PolicyExportAndImportController extends RestrictedBaseController { private Workbook workbook; private HSSFWorkbook workBook2; + + private PolicyController policyController; + public PolicyController getPolicyController() { + return policyController; + } + + public void setPolicyController(PolicyController policyController) { + this.policyController = policyController; + } + + public static CommonClassDao getCommonClassDao() { + return commonClassDao; + } + + public static void setCommonClassDao(CommonClassDao commonClassDao) { + PolicyExportAndImportController.commonClassDao = commonClassDao; + } @Autowired private PolicyExportAndImportController(CommonClassDao commonClassDao){ @@ -98,10 +115,10 @@ public class PolicyExportAndImportController extends RestrictedBaseController { public PolicyExportAndImportController(){} @RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) - public void ExportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{ + public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{ try{ String file = null; - selectedPolicy = new ArrayList(); + selectedPolicy = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); @@ -190,14 +207,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController { String configName = null; String scope = null; boolean finalColumn = false; - PolicyController controller = new PolicyController(); + PolicyController controller = policyController != null ? getPolicyController() : new PolicyController(); String userId = UserUtils.getUserSession(request).getOrgUserId(); UserInfo userInfo = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", userId); //Check if the Role and Scope Size are Null get the values from db. - List userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + List userRoles = controller.getRoles(userId); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole());