[POLICY-122] Policy GUI Fixes
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / openecomp / policy / controller / PolicyExportAndImportController.java
index b6899e0..8fe2d49 100644 (file)
@@ -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<String>();
+                       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<Object> userRoles = PolicyController.getRoles(userId);
-               roles = new ArrayList<String>();
-               scopes = new HashSet<String>();
+               List<Object> userRoles = controller.getRoles(userId);
+               roles = new ArrayList<>();
+               scopes = new HashSet<>();
                for(Object role: userRoles){
                        Roles userRole = (Roles) role;
                        roles.add(userRole.getRole());