diff options
author | ITSERVICES\rb7147 <rb7147@att.com> | 2017-04-25 11:46:00 -0400 |
---|---|---|
committer | ITSERVICES\rb7147 <rb7147@att.com> | 2017-05-03 09:58:17 -0400 |
commit | e0addf5b588a1244f9679becd90999dfcb4c3a94 (patch) | |
tree | 1212772d6366730266ff0e093c874b07aa716c29 /ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java | |
parent | 39fb0f30472777e4b60d6a7ac8aa4eb9773961ff (diff) |
Policy 1707 commit to LF
Change-Id: Ibe6f01d92f9a434c040abb05d5386e89d675ae65
Signed-off-by: ITSERVICES\rb7147 <rb7147@att.com>
Diffstat (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java')
-rw-r--r-- | ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java | 882 |
1 files changed, 402 insertions, 480 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java index 3ed8f5d1c..95172ac74 100644 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java +++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java @@ -33,31 +33,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.compress.utils.IOUtils; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.openecomp.policy.rest.dao.ActionListDao; -import org.openecomp.policy.rest.dao.ActionPolicyDictDao; -import org.openecomp.policy.rest.dao.AddressGroupDao; -import org.openecomp.policy.rest.dao.AttributeDao; -import org.openecomp.policy.rest.dao.BRMSParamTemplateDao; -import org.openecomp.policy.rest.dao.DecisionPolicyDao; -import org.openecomp.policy.rest.dao.DescriptiveScopeDao; -import org.openecomp.policy.rest.dao.EcompNameDao; -import org.openecomp.policy.rest.dao.PEPOptionsDao; -import org.openecomp.policy.rest.dao.PortListDao; -import org.openecomp.policy.rest.dao.PrefixListDao; -import org.openecomp.policy.rest.dao.ProtocolListDao; -import org.openecomp.policy.rest.dao.SecurityZoneDao; -import org.openecomp.policy.rest.dao.ServiceDictionaryDao; -import org.openecomp.policy.rest.dao.ServiceGroupDao; -import org.openecomp.policy.rest.dao.ServiceListDao; -import org.openecomp.policy.rest.dao.SiteDictionaryDao; -import org.openecomp.policy.rest.dao.TermListDao; -import org.openecomp.policy.rest.dao.VNFTypeDao; -import org.openecomp.policy.rest.dao.VSCLActionDao; -import org.openecomp.policy.rest.dao.VarbindDictionaryDao; -import org.openecomp.policy.rest.dao.ZoneDao; +import org.openecomp.policy.rest.dao.CommonClassDao; import org.openecomp.policy.rest.jpa.ActionList; import org.openecomp.policy.rest.jpa.ActionPolicyDict; import org.openecomp.policy.rest.jpa.AddressGroup; @@ -70,7 +46,7 @@ import org.openecomp.policy.rest.jpa.DescriptiveScope; import org.openecomp.policy.rest.jpa.EcompName; import org.openecomp.policy.rest.jpa.GroupServiceList; import org.openecomp.policy.rest.jpa.PEPOptions; -import org.openecomp.policy.rest.jpa.PREFIXLIST; +import org.openecomp.policy.rest.jpa.PrefixList; import org.openecomp.policy.rest.jpa.ProtocolList; import org.openecomp.policy.rest.jpa.SecurityZone; import org.openecomp.policy.rest.jpa.ServiceList; @@ -94,524 +70,470 @@ import au.com.bytecode.opencsv.CSVReader; public class DictionaryImportController { private String newFile; + private static CommonClassDao commonClassDao; + @Autowired - AttributeDao attributeDao; - - @Autowired - ActionPolicyDictDao actionPolicyDictDao; - - @Autowired - EcompNameDao ecompNameDao; - - @Autowired - VNFTypeDao vnfTypeDao; - - @Autowired - VSCLActionDao vsclActionDao; - - @Autowired - PEPOptionsDao pepOptionsDao; - - @Autowired - VarbindDictionaryDao varbindDao; - - @Autowired - ServiceDictionaryDao closedLoopServiceDao; - - @Autowired - SiteDictionaryDao closedLoopSiteDao; - - @Autowired - DescriptiveScopeDao descriptiveScopeDao; - - @Autowired - PrefixListDao prefixListDao; - - @Autowired - PortListDao portListDao; - - @Autowired - ProtocolListDao protocolListDao; - - @Autowired - AddressGroupDao addressGroupDao; - - @Autowired - ActionListDao actionListDao; - - @Autowired - SecurityZoneDao securityZoneDao; - - @Autowired - ServiceGroupDao serviceGroupDao; - - @Autowired - ServiceListDao serviceListDao; - - @Autowired - TermListDao termListDao; - - @Autowired - ZoneDao zoneDao; - - @Autowired - DecisionPolicyDao decisionSettingsDao; + public DictionaryImportController(CommonClassDao commonClassDao){ + DictionaryImportController.commonClassDao = commonClassDao; + } + + public DictionaryImportController(){} - @Autowired - BRMSParamTemplateDao brmsParamTemplateDao; - @RequestMapping(value={"/dictionary/import_dictionary.htm/*"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) + @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public void ImportDictionaryData(HttpServletRequest request, HttpServletResponse response) throws Exception{ ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //JsonNode root = mapper.readTree(request.getReader()); - String userId = request.getPathInfo().substring(request.getPathInfo().lastIndexOf("/")+1); - List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); - for (FileItem item : items) { - File file = new File(item.getName()); - OutputStream outputStream = new FileOutputStream(file); - IOUtils.copy(item.getInputStream(), outputStream); - outputStream.close(); - this.newFile = file.toString(); - CSVReader csvReader = new CSVReader(new FileReader(this.newFile)); - List<String[]> dictSheet = csvReader.readAll(); - if(item.getName().startsWith("Attribute")){ - for(int i = 1; i< dictSheet.size(); i++){ - Attribute attribute = new Attribute("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute ID")){ - attribute.setXacmlId(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){ - attribute.setPriority(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){ - Datatype dataType = new Datatype(); - if(rows[j].equalsIgnoreCase("string")){ - dataType.setId(26); - }else if(rows[j].equalsIgnoreCase("integer")){ - dataType.setId(12); - }else if(rows[j].equalsIgnoreCase("double")){ - dataType.setId(25); - }else if(rows[j].equalsIgnoreCase("boolean")){ - dataType.setId(18); - }else if(rows[j].equalsIgnoreCase("user")){ - dataType.setId(29); - } - attribute.setDatatypeBean(dataType); - Category category = new Category(); - category.setId(5); - attribute.setCategoryBean(category); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_value") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Value")){ - attribute.setAttributeValue(rows[j]); - } + String userId = request.getParameter("userId"); + String dictionaryName = request.getParameter("dictionaryName"); + + File file = new File(dictionaryName); + OutputStream outputStream = new FileOutputStream(file); + IOUtils.copy(request.getInputStream(), outputStream); + outputStream.close(); + this.newFile = file.toString(); + CSVReader csvReader = new CSVReader(new FileReader(this.newFile)); + List<String[]> dictSheet = csvReader.readAll(); + if(dictionaryName.startsWith("Attribute")){ + for(int i = 1; i< dictSheet.size(); i++){ + Attribute attribute = new Attribute("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute ID")){ + attribute.setXacmlId(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){ + attribute.setPriority(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){ + Datatype dataType = new Datatype(); + if(rows[j].equalsIgnoreCase("string")){ + dataType.setId(26); + }else if(rows[j].equalsIgnoreCase("integer")){ + dataType.setId(12); + }else if(rows[j].equalsIgnoreCase("double")){ + dataType.setId(25); + }else if(rows[j].equalsIgnoreCase("boolean")){ + dataType.setId(18); + }else if(rows[j].equalsIgnoreCase("user")){ + dataType.setId(29); + } + attribute.setDatatypeBean(dataType); + Category category = new Category(); + category.setId(5); + attribute.setCategoryBean(category); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_value") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Value")){ + attribute.setAttributeValue(rows[j]); } - attributeDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("ActionPolicyDictionary")){ - for(int i = 1; i< dictSheet.size(); i++){ - ActionPolicyDict attribute = new ActionPolicyDict("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_name") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Name")){ - attribute.setAttributeName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("body")){ - attribute.setBody(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("headers")){ - attribute.setHeader(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("method")){ - attribute.setMethod(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("type")){ - attribute.setMethod(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("url")){ - attribute.setMethod(rows[j]); - } + } + if(dictionaryName.startsWith("ActionPolicyDictionary")){ + for(int i = 1; i< dictSheet.size(); i++){ + ActionPolicyDict attribute = new ActionPolicyDict("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("attribute_name") || dictSheet.get(0)[j].equalsIgnoreCase("Attribute Name")){ + attribute.setAttributeName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("body")){ + attribute.setBody(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("headers")){ + attribute.setHeader(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("method")){ + attribute.setMethod(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("type")){ + attribute.setMethod(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("url")){ + attribute.setMethod(rows[j]); } - actionPolicyDictDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("EcompName")){ - for(int i = 1; i< dictSheet.size(); i++){ - EcompName attribute = new EcompName("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("ecomp_name") || dictSheet.get(0)[j].equalsIgnoreCase("Ecomp Name")){ - attribute.setEcompName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("EcompName")){ + for(int i = 1; i< dictSheet.size(); i++){ + EcompName attribute = new EcompName("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("ecomp_name") || dictSheet.get(0)[j].equalsIgnoreCase("Ecomp Name")){ + attribute.setEcompName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - ecompNameDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("VNFType")){ - for(int i = 1; i< dictSheet.size(); i++){ - VNFType attribute = new VNFType("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("vnf_type") || dictSheet.get(0)[j].equalsIgnoreCase("VNF Type")){ - attribute.setVnftype(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("VNFType")){ + for(int i = 1; i< dictSheet.size(); i++){ + VNFType attribute = new VNFType("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("vnf_type") || dictSheet.get(0)[j].equalsIgnoreCase("VNF Type")){ + attribute.setVnftype(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - vnfTypeDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("VSCLAction")){ - for(int i = 1; i< dictSheet.size(); i++){ - VSCLAction attribute = new VSCLAction("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("vscl_action") || dictSheet.get(0)[j].equalsIgnoreCase("VSCL Action")){ - attribute.setVsclaction(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("VSCLAction")){ + for(int i = 1; i< dictSheet.size(); i++){ + VSCLAction attribute = new VSCLAction("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("vscl_action") || dictSheet.get(0)[j].equalsIgnoreCase("VSCL Action")){ + attribute.setVsclaction(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - vsclActionDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("PEPOptions")){ - for(int i = 1; i< dictSheet.size(); i++){ - PEPOptions attribute = new PEPOptions("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("PEP_NAME") || dictSheet.get(0)[j].equalsIgnoreCase("PEP Name")){ - attribute.setPepName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("Actions")){ - attribute.setActions(rows[j]); - } + } + if(dictionaryName.startsWith("PEPOptions")){ + for(int i = 1; i< dictSheet.size(); i++){ + PEPOptions attribute = new PEPOptions("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("PEP_NAME") || dictSheet.get(0)[j].equalsIgnoreCase("PEP Name")){ + attribute.setPepName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("Actions")){ + attribute.setActions(rows[j]); } - pepOptionsDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("VarbindDictionary")){ - for(int i = 1; i< dictSheet.size(); i++){ - VarbindDictionary attribute = new VarbindDictionary("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Name") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Name")){ - attribute.setVarbindName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Description") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Description")){ - attribute.setVarbindDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_oid") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind OID")){ - attribute.setVarbindOID(rows[j]); - } + } + if(dictionaryName.startsWith("VarbindDictionary")){ + for(int i = 1; i< dictSheet.size(); i++){ + VarbindDictionary attribute = new VarbindDictionary("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Name") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Name")){ + attribute.setVarbindName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_Description") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind Description")){ + attribute.setVarbindDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("varbind_oid") || dictSheet.get(0)[j].equalsIgnoreCase("Varbind OID")){ + attribute.setVarbindOID(rows[j]); } - varbindDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("BRMSParamDictionary")){ - for(int i = 1; i< dictSheet.size(); i++){ - BRMSParamTemplate attribute = new BRMSParamTemplate(); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("param_template_name") || dictSheet.get(0)[j].equalsIgnoreCase("Rule Name")){ - attribute.setRuleName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("DESCRIPTION") || dictSheet.get(0)[j].equalsIgnoreCase("Description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("rule")){ - attribute.setRule(rows[j]); - } + } + if(dictionaryName.startsWith("BRMSParamDictionary")){ + for(int i = 1; i< dictSheet.size(); i++){ + BRMSParamTemplate attribute = new BRMSParamTemplate(); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("param_template_name") || dictSheet.get(0)[j].equalsIgnoreCase("Rule Name")){ + attribute.setRuleName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("DESCRIPTION") || dictSheet.get(0)[j].equalsIgnoreCase("Description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("rule")){ + attribute.setRule(rows[j]); } - brmsParamTemplateDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("Settings")){ - for(int i = 1; i< dictSheet.size(); i++){ - DecisionSettings attribute = new DecisionSettings("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Settings ID")){ - attribute.setXacmlId(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){ - attribute.setPriority(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){ - Datatype dataType = new Datatype(); - if(rows[j].equalsIgnoreCase("string")){ - dataType.setId(26); - }else if(rows[j].equalsIgnoreCase("integer")){ - dataType.setId(12); - }else if(rows[j].equalsIgnoreCase("double")){ - dataType.setId(25); - }else if(rows[j].equalsIgnoreCase("boolean")){ - dataType.setId(18); - }else if(rows[j].equalsIgnoreCase("user")){ - dataType.setId(29); - } - attribute.setDatatypeBean(dataType); - } + } + if(dictionaryName.startsWith("Settings")){ + for(int i = 1; i< dictSheet.size(); i++){ + DecisionSettings attribute = new DecisionSettings("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("xacml_id") || dictSheet.get(0)[j].equalsIgnoreCase("Settings ID")){ + attribute.setXacmlId(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("priority")){ + attribute.setPriority(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("datatype") || dictSheet.get(0)[j].equalsIgnoreCase("Data Type")){ + Datatype dataType = new Datatype(); + if(rows[j].equalsIgnoreCase("string")){ + dataType.setId(26); + }else if(rows[j].equalsIgnoreCase("integer")){ + dataType.setId(12); + }else if(rows[j].equalsIgnoreCase("double")){ + dataType.setId(25); + }else if(rows[j].equalsIgnoreCase("boolean")){ + dataType.setId(18); + }else if(rows[j].equalsIgnoreCase("user")){ + dataType.setId(29); + } + attribute.setDatatypeBean(dataType); } - decisionSettingsDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("PrefixList")){ - for(int i = 1; i< dictSheet.size(); i++){ - PREFIXLIST attribute = new PREFIXLIST("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListName") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Name")){ - attribute.setPrefixListName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setPrefixListValue(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListValue") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Value")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("PrefixList")){ + for(int i = 1; i< dictSheet.size(); i++){ + PrefixList attribute = new PrefixList("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListName") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Name")){ + attribute.setPrefixListName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setPrefixListValue(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("prefixListValue") || dictSheet.get(0)[j].equalsIgnoreCase("PrefixList Value")){ + attribute.setDescription(rows[j]); } - prefixListDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("SecurityZone")){ - for(int i = 1; i< dictSheet.size(); i++){ - SecurityZone attribute = new SecurityZone("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){ - attribute.setZoneName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){ - attribute.setZoneValue(rows[j]); - } + } + if(dictionaryName.startsWith("SecurityZone")){ + for(int i = 1; i< dictSheet.size(); i++){ + SecurityZone attribute = new SecurityZone("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){ + attribute.setZoneName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){ + attribute.setZoneValue(rows[j]); } - securityZoneDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("Zone")){ - for(int i = 1; i< dictSheet.size(); i++){ - Zone attribute = new Zone("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){ - attribute.setZoneName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){ - attribute.setZoneValue(rows[j]); - } + } + if(dictionaryName.startsWith("Zone")){ + for(int i = 1; i< dictSheet.size(); i++){ + Zone attribute = new Zone("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("zoneName") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Name")){ + attribute.setZoneName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("zoneValue") || dictSheet.get(0)[j].equalsIgnoreCase("Zone Value")){ + attribute.setZoneValue(rows[j]); } - zoneDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("ServiceList")){ - for(int i = 1; i< dictSheet.size(); i++){ - ServiceList attribute = new ServiceList("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceName") || dictSheet.get(0)[j].equalsIgnoreCase("Service Name")){ - attribute.setServiceName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceDesc") || dictSheet.get(0)[j].equalsIgnoreCase("Description")){ - attribute.setServiceDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceType") || dictSheet.get(0)[j].equalsIgnoreCase("Service Type")){ - attribute.setServiceType(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceTrasProtocol") || dictSheet.get(0)[j].equalsIgnoreCase("Transport Protocol")){ - attribute.setServiceTransProtocol(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceAppProtocol") || dictSheet.get(0)[j].equalsIgnoreCase("APP Protocol")){ - attribute.setServiceAppProtocol(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("servicePorts") || dictSheet.get(0)[j].equalsIgnoreCase("Ports")){ - attribute.setServicePorts(rows[j]); - } + } + if(dictionaryName.startsWith("ServiceList")){ + for(int i = 1; i< dictSheet.size(); i++){ + ServiceList attribute = new ServiceList("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceName") || dictSheet.get(0)[j].equalsIgnoreCase("Service Name")){ + attribute.setServiceName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceDesc") || dictSheet.get(0)[j].equalsIgnoreCase("Description")){ + attribute.setServiceDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceType") || dictSheet.get(0)[j].equalsIgnoreCase("Service Type")){ + attribute.setServiceType(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceTrasProtocol") || dictSheet.get(0)[j].equalsIgnoreCase("Transport Protocol")){ + attribute.setServiceTransProtocol(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceAppProtocol") || dictSheet.get(0)[j].equalsIgnoreCase("APP Protocol")){ + attribute.setServiceAppProtocol(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("servicePorts") || dictSheet.get(0)[j].equalsIgnoreCase("Ports")){ + attribute.setServicePorts(rows[j]); } - serviceListDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("ServiceGroup")){ - for(int i = 1; i< dictSheet.size(); i++){ - GroupServiceList attribute = new GroupServiceList("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){ - attribute.setGroupName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList") || dictSheet.get(0)[j].equalsIgnoreCase("Service List")){ - attribute.setServiceList(rows[j]); - } + } + if(dictionaryName.startsWith("ServiceGroup")){ + for(int i = 1; i< dictSheet.size(); i++){ + GroupServiceList attribute = new GroupServiceList("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){ + attribute.setGroupName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList") || dictSheet.get(0)[j].equalsIgnoreCase("Service List")){ + attribute.setServiceList(rows[j]); } - serviceGroupDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("AddressGroup")){ - for(int i = 1; i< dictSheet.size(); i++){ - AddressGroup attribute = new AddressGroup("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){ - attribute.setGroupName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList") || dictSheet.get(0)[j].equalsIgnoreCase("Prefix List")){ - attribute.setServiceList(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("AddressGroup")){ + for(int i = 1; i< dictSheet.size(); i++){ + AddressGroup attribute = new AddressGroup("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("name") || dictSheet.get(0)[j].equalsIgnoreCase("Group Name")){ + attribute.setGroupName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("serviceList") || dictSheet.get(0)[j].equalsIgnoreCase("Prefix List")){ + attribute.setServiceList(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - addressGroupDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("ProtocolList")){ - for(int i = 1; i< dictSheet.size(); i++){ - ProtocolList attribute = new ProtocolList("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("protocolName") || dictSheet.get(0)[j].equalsIgnoreCase("Protocol Name")){ - attribute.setProtocolName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("ProtocolList")){ + for(int i = 1; i< dictSheet.size(); i++){ + ProtocolList attribute = new ProtocolList("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("protocolName") || dictSheet.get(0)[j].equalsIgnoreCase("Protocol Name")){ + attribute.setProtocolName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - protocolListDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("ActionList")){ - for(int i = 1; i< dictSheet.size(); i++){ - ActionList attribute = new ActionList("", userId); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("actionName") || dictSheet.get(0)[j].equalsIgnoreCase("Action Name")){ - attribute.setActionName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } + } + if(dictionaryName.startsWith("ActionList")){ + for(int i = 1; i< dictSheet.size(); i++){ + ActionList attribute = new ActionList("", userId); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("actionName") || dictSheet.get(0)[j].equalsIgnoreCase("Action Name")){ + attribute.setActionName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); } - actionListDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("TermList")){ - for(int i = 1; i< dictSheet.size(); i++){ - TermList attribute = new TermList("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("termName") || dictSheet.get(0)[j].equalsIgnoreCase("Term-Name")){ - attribute.setTermName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("Term-Description") || dictSheet.get(0)[j].equalsIgnoreCase("termDescription")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("fromZone") || dictSheet.get(0)[j].equalsIgnoreCase("From Zone")){ - attribute.setFromZones(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("toZone") || dictSheet.get(0)[j].equalsIgnoreCase("To Zone")){ - attribute.setToZones(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("srcIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-IP-List")){ - attribute.setSrcIPList(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("destIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-IP-List")){ - attribute.setDestIPList(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("srcPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-Port-List")){ - attribute.setSrcPortList(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("destPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-Port-List")){ - attribute.setDestPortList(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("action") || dictSheet.get(0)[j].equalsIgnoreCase("Action List")){ - attribute.setAction(rows[j]); - } + } + if(dictionaryName.startsWith("TermList")){ + for(int i = 1; i< dictSheet.size(); i++){ + TermList attribute = new TermList("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("termName") || dictSheet.get(0)[j].equalsIgnoreCase("Term-Name")){ + attribute.setTermName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("Term-Description") || dictSheet.get(0)[j].equalsIgnoreCase("termDescription")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("fromZone") || dictSheet.get(0)[j].equalsIgnoreCase("From Zone")){ + attribute.setFromZones(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("toZone") || dictSheet.get(0)[j].equalsIgnoreCase("To Zone")){ + attribute.setToZones(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("srcIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-IP-List")){ + attribute.setSrcIPList(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("destIPList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-IP-List")){ + attribute.setDestIPList(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("srcPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Source-Port-List")){ + attribute.setSrcPortList(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("destPortList") || dictSheet.get(0)[j].equalsIgnoreCase("Destination-Port-List")){ + attribute.setDestPortList(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("action") || dictSheet.get(0)[j].equalsIgnoreCase("Action List")){ + attribute.setAction(rows[j]); } - termListDao.Save(attribute); } + commonClassDao.save(attribute); } - if(item.getName().startsWith("SearchCriteria")){ - for(int i = 1; i< dictSheet.size(); i++){ - DescriptiveScope attribute = new DescriptiveScope("", userId); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j<rows.length; j++ ){ - if(dictSheet.get(0)[j].equalsIgnoreCase("descriptiveScopeName") || dictSheet.get(0)[j].equalsIgnoreCase("Descriptive ScopeName")){ - attribute.setScopeName(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ - attribute.setDescription(rows[j]); - } - if(dictSheet.get(0)[j].equalsIgnoreCase("search") || dictSheet.get(0)[j].equalsIgnoreCase("Search Criteria")){ - attribute.setSearch(rows[j]); - } + } + if(dictionaryName.startsWith("SearchCriteria")){ + for(int i = 1; i< dictSheet.size(); i++){ + DescriptiveScope attribute = new DescriptiveScope("", userId); + UserInfo userinfo = new UserInfo(); + userinfo.setUserLoginId(userId); + attribute.setUserCreatedBy(userinfo); + attribute.setUserModifiedBy(userinfo); + String[] rows = dictSheet.get(i); + for (int j=0 ; j<rows.length; j++ ){ + if(dictSheet.get(0)[j].equalsIgnoreCase("descriptiveScopeName") || dictSheet.get(0)[j].equalsIgnoreCase("Descriptive ScopeName")){ + attribute.setScopeName(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("description")){ + attribute.setDescription(rows[j]); + } + if(dictSheet.get(0)[j].equalsIgnoreCase("search") || dictSheet.get(0)[j].equalsIgnoreCase("Search Criteria")){ + attribute.setSearch(rows[j]); } - descriptiveScopeDao.Save(attribute); } + commonClassDao.save(attribute); } - csvReader.close(); + } + csvReader.close(); + if(file.exists()){ + file.delete(); } } } |