- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
- FileInputStream excelFile = new FileInputStream(new File(file));
- workbook = new HSSFWorkbook(excelFile);
- Sheet datatypeSheet = workbook.getSheetAt(0);
- Iterator<Row> rowIterator = datatypeSheet.iterator();
-
- while (rowIterator.hasNext()) {
- finalColumn = false;
- policyEntity = new PolicyEntity();
- configurationDataEntity = new ConfigurationDataEntity();
- actionBodyEntity = new ActionBodyEntity();
- policyVersion = new PolicyVersion();
- Row currentRow = rowIterator.next();
- if (currentRow.getRowNum() == 0) {
- continue;
- }
- Iterator<Cell> cellIterator = currentRow.cellIterator();
- while (cellIterator.hasNext()) {
- Cell cell = cellIterator.next();
- if (getCellHeaderName(cell).equalsIgnoreCase("policyName")) {
- policyEntity.setPolicyName(cell.getStringCellValue());
- }
- if (getCellHeaderName(cell).equalsIgnoreCase("scope")) {
- policyEntity.setScope(cell.getStringCellValue());
- }
- if (getCellHeaderName(cell).equalsIgnoreCase("policyData")) {
- policyEntity.setPolicyData(cell.getStringCellValue());
- }
- if (getCellHeaderName(cell).equalsIgnoreCase("description")) {
- policyEntity.setDescription(cell.getStringCellValue());
- }
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationbody")) {
- if(policyEntity.getPolicyName().contains("Config_")){
- configExists = true;
- configurationDataEntity.setConfigBody(cell.getStringCellValue());
- }else if(policyEntity.getPolicyName().contains("Action_")){
- actionExists = true;
- actionBodyEntity.setActionBody(cell.getStringCellValue());
- }
- }
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationName")) {
- finalColumn = true;
- configName = cell.getStringCellValue();
- if(policyEntity.getPolicyName().contains("Config_")){
- configurationDataEntity.setConfigurationName(cell.getStringCellValue());
- }else if(policyEntity.getPolicyName().contains("Action_")){
- actionBodyEntity.setActionBodyName(cell.getStringCellValue());
- }
- }