X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcontroller%2FDictionaryImportController.java;fp=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcontroller%2FDictionaryImportController.java;h=7093cd5149c7ec9f4b002ce25ea54edbb119ca10;hb=f0fec2a861ea0a92b27b40882ea38f9422cde0c6;hp=9423017c31b0e604b01298692ecc2cfaa3a877d2;hpb=7a6c4f9214a71101db3354ed06ccd3cfd3cea65b;p=policy%2Fengine.git 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 9423017c3..7093cd514 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 @@ -75,704 +75,704 @@ import au.com.bytecode.opencsv.CSVReader; @Controller public class DictionaryImportController { - private static final Logger LOGGER = FlexLogger.getLogger(DictionaryImportController.class); - - private static CommonClassDao commonClassDao; - private static final String DESCRIPTION= "description"; - private static final String ERROR= "Error"; - private static final String DEPENDENCY= "dependency"; - - @Autowired - public DictionaryImportController(CommonClassDao commonClassDao){ - setCommonClassDao(commonClassDao); - } - - public static void setCommonClassDao(CommonClassDao commonClassDao) { - DictionaryImportController.commonClassDao = commonClassDao; - } - - public DictionaryImportController(){ - super(); - } + private static final Logger LOGGER = FlexLogger.getLogger(DictionaryImportController.class); - @RequestMapping(value={"/dictionary/import_dictionary"}, method={RequestMethod.POST}) - public void importDictionaryData(HttpServletRequest request, HttpServletResponse response) throws IOException{ - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - String userId = request.getParameter("userId"); - String dictionaryName = request.getParameter("dictionaryName"); - - if(dictionaryName == null || dictionaryName.isEmpty()){ - LOGGER.error("dictionaryName is null/empty"); - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.getWriter().write(ERROR); - return; - } - - // fix Fortify Path Manipulation issue - if(!isValidDictionaryName(dictionaryName)){ - LOGGER.error("dictionaryName is invalid"); - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.getWriter().write(ERROR); - return; - } - File file = new File(dictionaryName); - try(OutputStream outputStream = new FileOutputStream(file); FileReader fileReader = new FileReader(file.toString())){ - IOUtils.copy(request.getInputStream(), outputStream); - CSVReader csvReader = new CSVReader(fileReader); - List dictSheet = csvReader.readAll(); - if(dictionaryName.startsWith("Attribute")){ - for(int i = 1; i< dictSheet.size(); i++){ - Attribute attribute = new Attribute(""); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j dictSheet = csvReader.readAll(); + if(dictionaryName.startsWith("Attribute")){ + for(int i = 1; i< dictSheet.size(); i++){ + Attribute attribute = new Attribute(""); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j