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;h=ef475039d782ebbe1f8cc60619c4a02355cda982;hb=b536883546b9fa87bce50c7a6d030f6de3aafdce;hp=b42731d61cad4c069afdf4e426922e2f72a38eae;hpb=26b2f0b9eb6fa60a8e161181768e20fdf3b4c7f7;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 b42731d61..ef475039d 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 @@ -21,16 +21,20 @@ package org.onap.policy.pap.xacml.rest.controller; import au.com.bytecode.opencsv.CSVReader; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.apache.commons.compress.utils.IOUtils; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; @@ -40,9 +44,9 @@ import org.onap.policy.rest.jpa.ActionList; import org.onap.policy.rest.jpa.ActionPolicyDict; import org.onap.policy.rest.jpa.AddressGroup; import org.onap.policy.rest.jpa.Attribute; -import org.onap.policy.rest.jpa.BRMSController; -import org.onap.policy.rest.jpa.BRMSDependency; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsController; +import org.onap.policy.rest.jpa.BrmsDependency; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.Category; import org.onap.policy.rest.jpa.ClosedLoopD2Services; import org.onap.policy.rest.jpa.ClosedLoopSite; @@ -52,7 +56,7 @@ import org.onap.policy.rest.jpa.DescriptiveScope; import org.onap.policy.rest.jpa.GroupServiceList; import org.onap.policy.rest.jpa.MicroServiceModels; import org.onap.policy.rest.jpa.OnapName; -import org.onap.policy.rest.jpa.PEPOptions; +import org.onap.policy.rest.jpa.PepOptions; import org.onap.policy.rest.jpa.PrefixList; import org.onap.policy.rest.jpa.ProtocolList; import org.onap.policy.rest.jpa.SecurityZone; @@ -68,7 +72,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; - @Controller public class DictionaryImportController { private static final Logger LOGGER = FlexLogger.getLogger(DictionaryImportController.class); @@ -92,8 +95,7 @@ public class DictionaryImportController { } @RequestMapping(value = {"/dictionary/import_dictionary"}, method = {RequestMethod.POST}) - public void importDictionaryData(HttpServletRequest request, HttpServletResponse response) - throws IOException { + 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"); @@ -211,7 +213,7 @@ public class DictionaryImportController { for (int j = 0; j < rows.length; j++) { if ("onap_name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Onap Name".equalsIgnoreCase(dictSheet.get(0)[j])) { - attribute.setOnapName(rows[j]); + attribute.setName(rows[j]); } if (DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])) { attribute.setDescription(rows[j]); @@ -250,10 +252,10 @@ public class DictionaryImportController { attribute.setEnumValues(rows[j]); } if ("Ref Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) { - attribute.setRef_attributes(rows[j]); + attribute.setRefAttributes(rows[j]); } if ("Sub Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) { - attribute.setSub_attributes(rows[j]); + attribute.setSubAttributes(rows[j]); } if ("annotations".equalsIgnoreCase(dictSheet.get(0)[j])) { attribute.setAnnotation(rows[j]); @@ -273,8 +275,7 @@ public class DictionaryImportController { String[] rows = dictSheet.get(i); for (int j = 0; j < rows.length; j++) { if ("modelName".equalsIgnoreCase(dictSheet.get(0)[j]) - || "Optimization Service Model" - .equalsIgnoreCase(dictSheet.get(0)[j])) { + || "Optimization Service Model".equalsIgnoreCase(dictSheet.get(0)[j])) { attribute.setModelName(rows[j]); } if ("version".equalsIgnoreCase(dictSheet.get(0)[j]) @@ -294,10 +295,10 @@ public class DictionaryImportController { attribute.setEnumValues(rows[j]); } if ("Ref Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) { - attribute.setRef_attributes(rows[j]); + attribute.setRefAttributes(rows[j]); } if ("Sub Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) { - attribute.setSub_attributes(rows[j]); + attribute.setSubAttributes(rows[j]); } if ("annotations".equalsIgnoreCase(dictSheet.get(0)[j])) { attribute.setAnnotation(rows[j]); @@ -388,9 +389,9 @@ public class DictionaryImportController { commonClassDao.save(attribute); } } - if (dictionaryName.startsWith("PEPOptions")) { + if (dictionaryName.startsWith("PepOptions")) { for (int i = 1; i < dictSheet.size(); i++) { - PEPOptions attribute = new PEPOptions(); + PepOptions attribute = new PepOptions(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -438,7 +439,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSParamDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSParamTemplate attribute = new BRMSParamTemplate(); + BrmsParamTemplate attribute = new BrmsParamTemplate(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -460,7 +461,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSControllerDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSController attribute = new BRMSController(); + BrmsController attribute = new BrmsController(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -482,7 +483,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSDependencyDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSDependency attribute = new BRMSDependency(); + BrmsDependency attribute = new BrmsDependency(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -800,7 +801,7 @@ public class DictionaryImportController { case VSCLAction: case ClosedLoopService: case ClosedLoopSite: - case PEPOptions: + case PepOptions: case VarbindDictionary: case BRMSParamDictionary: case BRMSControllerDictionary: