summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2018-02-28 16:46:59 +0000
committerGerrit Code Review <gerrit@onap.org>2018-02-28 16:46:59 +0000
commitdedde625a1c81bae8b4b750710e3d514b120a86f (patch)
tree646b52b45a5f7d83093b62d40dd11cf9e5cb9cb2
parentf39febaa77ab395b8e755c19ef85cc984b8da072 (diff)
parent9ffce7748d288fde9e55d92367a858020e5a32fc (diff)
Merge "Added Junits for Policy PAP-REST"
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DictionaryNames.java (renamed from ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DisctionaryNames.java)2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java369
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java327
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java197
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java101
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java14
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionList.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionPolicyDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/AddressGroup.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/Attribute.csv6
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSControllerDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSDependencyDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSParamDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopService.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopSite.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/MSPolicyDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/OnapName.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/PEPOptions.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/PrefixList.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ProtocolList.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/SearchCriteria.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/SecurityZone.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceGroup.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceList.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/Settings.csv6
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/TermList.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/VNFType.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/VSCLAction.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/VarbindDictionary.csv2
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/Zone.csv2
30 files changed, 583 insertions, 483 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DisctionaryNames.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DictionaryNames.java
index f0dfa0ad2..3735316c4 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DisctionaryNames.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/DictionaryNames.java
@@ -26,7 +26,7 @@ package org.onap.policy.pap.xacml.rest;
* MessageCodes contains all the valid Dictionary names
*
*/
-public enum DisctionaryNames {
+public enum DictionaryNames {
Attribute,
ActionPolicyDictionary,
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 142f72b97..f3c78ffb9 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
@@ -19,10 +19,7 @@
*/
package org.onap.policy.pap.xacml.rest.controller;
- /*
- *
- *
- * */
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@@ -36,7 +33,7 @@ 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;
-import org.onap.policy.pap.xacml.rest.DisctionaryNames;
+import org.onap.policy.pap.xacml.rest.DictionaryNames;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionList;
import org.onap.policy.rest.jpa.ActionPolicyDict;
@@ -68,6 +65,7 @@ import org.onap.policy.rest.jpa.Zone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -79,8 +77,6 @@ import au.com.bytecode.opencsv.CSVReader;
public class DictionaryImportController {
private static final Logger LOGGER = FlexLogger.getLogger(DictionaryImportController.class);
- private String newFile;
-
private static CommonClassDao commonClassDao;
private static final String DESCRIPTION= "description";
@@ -89,11 +85,13 @@ public class DictionaryImportController {
DictionaryImportController.commonClassDao = commonClassDao;
}
- public DictionaryImportController(){}
+ public DictionaryImportController(){
+ super();
+ }
- @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public void ImportDictionaryData(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ @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");
@@ -109,22 +107,16 @@ public class DictionaryImportController {
// fix Fortify Path Manipulation issue
if(!isValidDictionaryName(dictionaryName)){
LOGGER.error("dictionaryName is invalid");
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.getWriter().write("Error");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().write("Dictionary Import failed. Hence the following dictionary doen't support import function : "+ dictionaryName);
return;
}
-
- boolean dictionaryImportExists = false;
- try{
- File file = new File(dictionaryName);
- OutputStream outputStream = new FileOutputStream(file);
+ File file = new File(dictionaryName);
+ try(OutputStream outputStream = new FileOutputStream(file); FileReader fileReader = new FileReader(file.toString())){
IOUtils.copy(request.getInputStream(), outputStream);
- outputStream.close();
- this.newFile = file.toString();
- CSVReader csvReader = new CSVReader(new FileReader(this.newFile));
+ CSVReader csvReader = new CSVReader(fileReader);
List<String[]> dictSheet = csvReader.readAll();
if(dictionaryName.startsWith("Attribute")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
Attribute attribute = new Attribute("");
UserInfo userinfo = new UserInfo();
@@ -133,26 +125,26 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("xacml_id").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute ID").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("xacml_id".equalsIgnoreCase(dictSheet.get(0)[j]) || "Attribute ID".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setXacmlId(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("priority").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("priority".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setPriority(rows[j]);
}
- if(("datatype").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Data Type").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("datatype".equalsIgnoreCase(dictSheet.get(0)[j]) || "Data Type".equalsIgnoreCase(dictSheet.get(0)[j])){
Datatype dataType = new Datatype();
- if(("string").equalsIgnoreCase(rows[j])){
+ if("string".equalsIgnoreCase(rows[j])){
dataType.setId(26);
- }else if(("integer").equalsIgnoreCase(rows[j])){
+ }else if("integer".equalsIgnoreCase(rows[j])){
dataType.setId(12);
- }else if(("double").equalsIgnoreCase(rows[j])){
+ }else if("double".equalsIgnoreCase(rows[j])){
dataType.setId(25);
- }else if(("boolean").equalsIgnoreCase(rows[j])){
+ }else if("boolean".equalsIgnoreCase(rows[j])){
dataType.setId(18);
- }else if(("user").equalsIgnoreCase(rows[j])){
+ }else if("user".equalsIgnoreCase(rows[j])){
dataType.setId(29);
}
attribute.setDatatypeBean(dataType);
@@ -160,7 +152,7 @@ public class DictionaryImportController {
category.setId(5);
attribute.setCategoryBean(category);
}
- if(("attribute_value").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute Value").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("attribute_value".equalsIgnoreCase(dictSheet.get(0)[j]) || "Attribute Value".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setAttributeValue(rows[j]);
}
}
@@ -168,7 +160,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ActionPolicyDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ActionPolicyDict attribute = new ActionPolicyDict();
UserInfo userinfo = new UserInfo();
@@ -177,25 +168,25 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("attribute_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("attribute_name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Attribute Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setAttributeName(rows[j]);
}
- if(("body").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("body".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setBody(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("headers").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("headers".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setHeader(rows[j]);
}
- if(("method").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("method".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setMethod(rows[j]);
}
- if(("type").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("type".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setType(rows[j]);
}
- if(("url").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("url".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setUrl(rows[j]);
}
}
@@ -203,7 +194,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("OnapName")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
OnapName attribute = new OnapName();
UserInfo userinfo = new UserInfo();
@@ -212,10 +202,10 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("onap_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Onap Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("onap_name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Onap Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setOnapName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -224,7 +214,6 @@ public class DictionaryImportController {
}
if(dictionaryName.startsWith("MSPolicyDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
MicroServiceModels attribute = new MicroServiceModels();
UserInfo userinfo = new UserInfo();
@@ -232,28 +221,28 @@ public class DictionaryImportController {
attribute.setUserCreatedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("modelName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Micro Service Model").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("modelName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Micro Service Model".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setModelName(rows[j]);
}
- if(("version").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Model Version").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("version".equalsIgnoreCase(dictSheet.get(0)[j]) || "Model Version".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVersion(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("dependency").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("dependency".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDependency(rows[j]);
}
- if(("attributes").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("attributes".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setAttributes(rows[j]);
}
- if(("enumValues").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("enumValues".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setEnumValues(rows[j]);
}
- if(("Ref Attributes").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("Ref Attributes".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setRef_attributes(rows[j]);
}
- if(("Sub Attributes").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("Sub Attributes".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setSub_attributes(rows[j]);
}
}
@@ -263,7 +252,6 @@ public class DictionaryImportController {
}
if(dictionaryName.startsWith("VNFType")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
VNFType attribute = new VNFType();
UserInfo userinfo = new UserInfo();
@@ -272,10 +260,10 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("vnf_type").equalsIgnoreCase(dictSheet.get(0)[j]) || ("VNF Type").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("vnf_type".equalsIgnoreCase(dictSheet.get(0)[j]) || "VNF Type".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVnftype(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -283,7 +271,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("VSCLAction")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
VSCLAction attribute = new VSCLAction();
UserInfo userinfo = new UserInfo();
@@ -292,10 +279,10 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("vscl_action").equalsIgnoreCase(dictSheet.get(0)[j]) || ("VSCL Action").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("vscl_action".equalsIgnoreCase(dictSheet.get(0)[j]) || "VSCL Action".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVsclaction(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -303,7 +290,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ClosedLoopService")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ClosedLoopD2Services attribute = new ClosedLoopD2Services();
UserInfo userinfo = new UserInfo();
@@ -312,10 +298,10 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("serviceName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Service Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Service Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -323,7 +309,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ClosedLoopSite")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ClosedLoopSite attribute = new ClosedLoopSite();
UserInfo userinfo = new UserInfo();
@@ -332,10 +317,10 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("siteName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Site Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("siteName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Site Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setSiteName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -343,7 +328,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("PEPOptions")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
PEPOptions attribute = new PEPOptions();
UserInfo userinfo = new UserInfo();
@@ -352,13 +336,13 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("PEP_NAME").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PEP Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("PEP_NAME".equalsIgnoreCase(dictSheet.get(0)[j]) || "PEP Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setPepName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("Actions").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("Actions".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setActions(rows[j]);
}
}
@@ -366,7 +350,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("VarbindDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
VarbindDictionary attribute = new VarbindDictionary();
UserInfo userinfo = new UserInfo();
@@ -375,13 +358,13 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("varbind_Name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("varbind_Name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Varbind Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVarbindName(rows[j]);
}
- if(("varbind_Description").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind Description").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("varbind_Description".equalsIgnoreCase(dictSheet.get(0)[j]) || "Varbind Description".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVarbindDescription(rows[j]);
}
- if(("varbind_oid").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind OID").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("varbind_oid".equalsIgnoreCase(dictSheet.get(0)[j]) || "Varbind OID".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setVarbindOID(rows[j]);
}
}
@@ -389,7 +372,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("BRMSParamDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
BRMSParamTemplate attribute = new BRMSParamTemplate();
UserInfo userinfo = new UserInfo();
@@ -397,13 +379,13 @@ public class DictionaryImportController {
attribute.setUserCreatedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("param_template_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Rule Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("param_template_name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Rule Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setRuleName(rows[j]);
}
- if(("Description").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("rule").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("rule".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setRule(rows[j]);
}
}
@@ -411,7 +393,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("BRMSControllerDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
BRMSController attribute = new BRMSController();
UserInfo userinfo = new UserInfo();
@@ -419,13 +400,13 @@ public class DictionaryImportController {
attribute.setUserCreatedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("controllerName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Controller Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("controllerName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Controller Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setControllerName(rows[j]);
}
- if(("DESCRIPTION").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("controller").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("controller".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setController(rows[j]);
}
}
@@ -433,7 +414,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("BRMSDependencyDictionary")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
BRMSDependency attribute = new BRMSDependency();
UserInfo userinfo = new UserInfo();
@@ -441,13 +421,13 @@ public class DictionaryImportController {
attribute.setUserCreatedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("dependencyName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Dependency Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("dependencyName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Dependency Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDependencyName(rows[j]);
}
- if(("DESCRIPTION").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("dependency").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("dependency".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDependency(rows[j]);
}
}
@@ -455,7 +435,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("Settings")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
DecisionSettings attribute = new DecisionSettings();
UserInfo userinfo = new UserInfo();
@@ -464,26 +443,26 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("xacml_id").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Settings ID").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("xacml_id".equalsIgnoreCase(dictSheet.get(0)[j]) || "Settings ID".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setXacmlId(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("priority").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("priority".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setPriority(rows[j]);
}
- if(("datatype").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Data Type").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("datatype".equalsIgnoreCase(dictSheet.get(0)[j]) || "Data Type".equalsIgnoreCase(dictSheet.get(0)[j])){
Datatype dataType = new Datatype();
- if(("string").equalsIgnoreCase(rows[j])){
+ if("string".equalsIgnoreCase(rows[j])){
dataType.setId(26);
- }else if(("integer").equalsIgnoreCase(rows[j])){
+ }else if("integer".equalsIgnoreCase(rows[j])){
dataType.setId(12);
- }else if(("double").equalsIgnoreCase(rows[j])){
+ }else if("double".equalsIgnoreCase(rows[j])){
dataType.setId(25);
- }else if(("boolean").equalsIgnoreCase(rows[j])){
+ }else if("boolean".equalsIgnoreCase(rows[j])){
dataType.setId(18);
- }else if(("user").equalsIgnoreCase(rows[j])){
+ }else if("user".equalsIgnoreCase(rows[j])){
dataType.setId(29);
}
attribute.setDatatypeBean(dataType);
@@ -493,18 +472,17 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("PrefixList")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
PrefixList attribute = new PrefixList();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("prefixListName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PrefixList Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("prefixListName".equalsIgnoreCase(dictSheet.get(0)[j]) || "PrefixList Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setPrefixListName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setPrefixListValue(rows[j]);
}
- if(("prefixListValue").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PrefixList Value").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("prefixListValue".equalsIgnoreCase(dictSheet.get(0)[j]) || "PrefixList Value".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -512,15 +490,14 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("SecurityZone")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
SecurityZone attribute = new SecurityZone();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("zoneName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("zoneName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Zone Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setZoneName(rows[j]);
}
- if(("zoneValue").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Value").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("zoneValue".equalsIgnoreCase(dictSheet.get(0)[j]) || "Zone Value".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setZoneValue(rows[j]);
}
}
@@ -528,15 +505,14 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("Zone")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
Zone attribute = new Zone();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("zoneName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("zoneName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Zone Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setZoneName(rows[j]);
}
- if(("zoneValue").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Value").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("zoneValue".equalsIgnoreCase(dictSheet.get(0)[j]) || "Zone Value".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setZoneValue(rows[j]);
}
}
@@ -544,27 +520,26 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ServiceList")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ServiceList attribute = new ServiceList();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("serviceName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Service Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Service Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceName(rows[j]);
}
- if(("serviceDesc").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Description").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceDesc".equalsIgnoreCase(dictSheet.get(0)[j]) || DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceDescription(rows[j]);
}
- if(("serviceType").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Service Type").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceType".equalsIgnoreCase(dictSheet.get(0)[j]) || "Service Type".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceType(rows[j]);
}
- if(("serviceTrasProtocol").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Transport Protocol").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceTrasProtocol".equalsIgnoreCase(dictSheet.get(0)[j]) || "Transport Protocol".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceTransProtocol(rows[j]);
}
- if(("serviceAppProtocol").equalsIgnoreCase(dictSheet.get(0)[j]) || ("APP Protocol").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceAppProtocol".equalsIgnoreCase(dictSheet.get(0)[j]) || "APP Protocol".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceAppProtocol(rows[j]);
}
- if(("servicePorts").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Ports").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("servicePorts".equalsIgnoreCase(dictSheet.get(0)[j]) || "Ports".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServicePorts(rows[j]);
}
}
@@ -572,15 +547,14 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ServiceGroup")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
GroupServiceList attribute = new GroupServiceList();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Group Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Group Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setGroupName(rows[j]);
}
- if(("serviceList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Service List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Service List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceList(rows[j]);
}
}
@@ -588,18 +562,17 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("AddressGroup")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
AddressGroup attribute = new AddressGroup();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Group Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("name".equalsIgnoreCase(dictSheet.get(0)[j]) || "Group Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setGroupName(rows[j]);
}
- if(("serviceList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Prefix List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("serviceList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Prefix List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setServiceList(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -607,15 +580,14 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ProtocolList")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ProtocolList attribute = new ProtocolList();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("protocolName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Protocol Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("protocolName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Protocol Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setProtocolName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -623,15 +595,14 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("ActionList")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
ActionList attribute = new ActionList();
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("actionName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Action Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("actionName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Action Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setActionName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
}
@@ -639,7 +610,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("TermList")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
TermList attribute = new TermList();
UserInfo userinfo = new UserInfo();
@@ -648,31 +618,31 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("termName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Term-Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("termName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Term-Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setTermName(rows[j]);
}
- if(("Term-Description").equalsIgnoreCase(dictSheet.get(0)[j]) || ("termDescription").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("Term-Description".equalsIgnoreCase(dictSheet.get(0)[j]) || "termDescription".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("fromZone").equalsIgnoreCase(dictSheet.get(0)[j]) || ("From Zone").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("fromZone".equalsIgnoreCase(dictSheet.get(0)[j]) || "From Zone".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setFromZones(rows[j]);
}
- if(("toZone").equalsIgnoreCase(dictSheet.get(0)[j]) || ("To Zone").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("toZone".equalsIgnoreCase(dictSheet.get(0)[j]) || "To Zone".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setToZones(rows[j]);
}
- if(("srcIPList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Source-IP-List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("srcIPList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Source-IP-List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setSrcIPList(rows[j]);
}
- if(("destIPList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Destination-IP-List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("destIPList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Destination-IP-List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDestIPList(rows[j]);
}
- if(("srcPortList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Source-Port-List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("srcPortList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Source-Port-List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setSrcPortList(rows[j]);
}
- if(("destPortList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Destination-Port-List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("destPortList".equalsIgnoreCase(dictSheet.get(0)[j]) || "Destination-Port-List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDestPortList(rows[j]);
}
- if(("action").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Action List").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("action".equalsIgnoreCase(dictSheet.get(0)[j]) || "Action List".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setAction(rows[j]);
}
}
@@ -680,7 +650,6 @@ public class DictionaryImportController {
}
}
if(dictionaryName.startsWith("SearchCriteria")){
- dictionaryImportExists = true;
for(int i = 1; i< dictSheet.size(); i++){
DescriptiveScope attribute = new DescriptiveScope();
UserInfo userinfo = new UserInfo();
@@ -689,13 +658,13 @@ public class DictionaryImportController {
attribute.setUserModifiedBy(userinfo);
String[] rows = dictSheet.get(i);
for (int j=0 ; j<rows.length; j++ ){
- if(("descriptiveScopeName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Descriptive Scope Name").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("descriptiveScopeName".equalsIgnoreCase(dictSheet.get(0)[j]) || "Descriptive Scope Name".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setScopeName(rows[j]);
}
- if((DESCRIPTION).equalsIgnoreCase(dictSheet.get(0)[j])){
+ if(DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setDescription(rows[j]);
}
- if(("search").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Search Criteria").equalsIgnoreCase(dictSheet.get(0)[j])){
+ if("search".equalsIgnoreCase(dictSheet.get(0)[j]) || "Search Criteria".equalsIgnoreCase(dictSheet.get(0)[j])){
attribute.setSearch(rows[j]);
}
}
@@ -703,97 +672,57 @@ public class DictionaryImportController {
}
}
csvReader.close();
- if(file.exists()){
- file.delete();
- }
- if(!dictionaryImportExists){
- response.setStatus(HttpServletResponse.SC_OK);
- response.getWriter().write("Dictionary Import failed. Hence the following dictionary doen't support import function : "+ dictionaryName);
- }else{
- response.setStatus(HttpServletResponse.SC_OK);
- response.getWriter().write("Success");
- }
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().write("Success");
}catch(Exception e){
LOGGER.error("Exception Occured while importing dictionary"+e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.getWriter().write("Error");
+ }finally{
+ if(file != null && file.exists()){
+ boolean deleted = file.delete();
+ LOGGER.error("Imported File has been deleted: "+deleted);
+ }
}
}
public boolean isValidDictionaryName(String dictionaryName){
- if(dictionaryName.startsWith(DisctionaryNames.Attribute.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ActionPolicyDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.OnapName.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.MSPolicyDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.VNFType.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.VSCLAction.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ClosedLoopService.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ClosedLoopSite.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.PEPOptions.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.VarbindDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.BRMSParamDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.BRMSControllerDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.BRMSDependencyDictionary.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.Settings.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.PrefixList.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.SecurityZone.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.Zone.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ServiceList.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ServiceGroup.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.AddressGroup.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ProtocolList.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.ActionList.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.TermList.toString())){
- return true;
- }
- if(dictionaryName.startsWith(DisctionaryNames.SearchCriteria.toString())){
- return true;
- }
- return false;
+ String nameCheck = dictionaryName.replace(".csv", "");
+ try{
+ DictionaryNames mode = DictionaryNames.valueOf(nameCheck);
+ switch (mode){
+ case Attribute:
+ case ActionPolicyDictionary:
+ case OnapName:
+ case MSPolicyDictionary:
+ case VNFType:
+ case VSCLAction:
+ case ClosedLoopService:
+ case ClosedLoopSite:
+ case PEPOptions:
+ case VarbindDictionary:
+ case BRMSParamDictionary:
+ case BRMSControllerDictionary:
+ case BRMSDependencyDictionary:
+ case Settings:
+ case PrefixList:
+ case SecurityZone:
+ case Zone:
+ case ServiceList:
+ case ServiceGroup:
+ case AddressGroup:
+ case ProtocolList:
+ case ActionList:
+ case TermList:
+ case SearchCriteria:
+ return true;
+ default:
+ return false;
+ }
+ }catch(Exception e){
+ LOGGER.error("Dictionary not exits: " +dictionaryName +e);
+ return false;
+ }
}
} \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
index 561dea864..23450cbbe 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
@@ -21,24 +21,17 @@
package org.onap.policy.pap.xacml.rest.controller;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.json.JSONObject;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.pap.xacml.rest.util.JsonMessage;
+import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.RiskType;
import org.onap.policy.rest.jpa.SafePolicyWarning;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.utils.PolicyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@@ -53,14 +46,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
public class SafePolicyController {
- private static final Logger LOGGER = FlexLogger.getLogger(SafePolicyController.class);
-
private static CommonClassDao commonClassDao;
private static String duplicateResponseString = "Duplicate";
private static String operation = "operation";
- private static String apiflag = "apiflag";
- private static String utf8 = "UTF-8";
- private static String applicationJsonContentType = "application / json";
+ private static String riskTypeDatas = "riskTypeDictionaryDatas";
+ private static String safePolicyWarningDatas = "safePolicyWarningDatas";
@Autowired
public SafePolicyController(CommonClassDao commonClassDao){
@@ -72,310 +62,149 @@ public class SafePolicyController {
}
public SafePolicyController(){
- //Empty Constructor
+ super();
}
- public UserInfo getUserInfo(String loginId){
- return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
+ private DictionaryUtils getDictionaryUtilsInstance(){
+ return DictionaryUtils.dictionaryUtils != null ? DictionaryUtils.getDictionaryUtils() : new DictionaryUtils();
}
@RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getRiskTypeDictionaryByNameEntityData(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("riskTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(RiskType.class, "name")));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- }
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getDataByEntity(response, riskTypeDatas, "name", RiskType.class);
}
@RequestMapping(value = { "/get_RiskTypeData" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getRiskTypeDictionaryEntityData(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("riskTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(RiskType.class)));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.addHeader("successMapKey", "success");
- response.addHeader(operation, "getDictionary");
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error(e);
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", "dictionaryDBQuery");
- }
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getData(response, riskTypeDatas, RiskType.class);
}
@RequestMapping(value = { "/sp_dictionary/save_riskType" }, method = {RequestMethod.POST })
public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ DictionaryUtils utils = getDictionaryUtilsInstance();
try {
- boolean duplicateflag = false;
- boolean isFakeUpdate = false;
- boolean fromAPI = false;
- if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
- fromAPI = true;
- }
+ boolean fromAPI = utils.isRequestFromAPI(request);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
RiskType riskTypeData;
String userId = null;
if (fromAPI) {
- riskTypeData = mapper.readValue(root.get("dictionaryFields").toString(),
- RiskType.class);
+ riskTypeData = mapper.readValue(root.get("dictionaryFields").toString(), RiskType.class);
userId = "API";
-
- //check if update operation or create, get id for data to be updated and update attributeData
- if ("update".equalsIgnoreCase(request.getParameter(operation))){
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(riskTypeData.getRiskName(), "name", RiskType.class);
- RiskType data = (RiskType) duplicateData.get(0);
- int id = data.getId();
-
- if(id==0){
- isFakeUpdate=true;
- riskTypeData.setId(1);
- } else {
- riskTypeData.setId(id);
- }
-
- riskTypeData.setUserCreatedBy(this.getUserInfo(userId));
- }
} else {
riskTypeData = mapper.readValue(root.get("riskTypeDictionaryData").toString(), RiskType.class);
userId = root.get("userid").textValue();
}
-
- if (riskTypeData.getId() == 0) {
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(riskTypeData.getRiskName(), "name", RiskType.class);
- if(!duplicateData.isEmpty()){
+ UserInfo userInfo = utils.getUserInfo(userId);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(riskTypeData.getRiskName(), "name", RiskType.class);
+ boolean duplicateflag = false;
+ if(!duplicateData.isEmpty()){
+ RiskType data = (RiskType) duplicateData.get(0);
+ if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
+ riskTypeData.setId(data.getId());
+ }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) ||
+ (request.getParameter(operation) == null && (data.getId() != riskTypeData.getId()))){
duplicateflag = true;
- }else{
- riskTypeData.setUserCreatedBy(getUserInfo(userId));
- riskTypeData.setUserModifiedBy(getUserInfo(userId));
- commonClassDao.save(riskTypeData);
}
- } else {
- if (!isFakeUpdate) {
- riskTypeData.setUserModifiedBy(this.getUserInfo(userId));
+ }
+ String responseString = null;
+ if(!duplicateflag){
+ riskTypeData.setUserModifiedBy(userInfo);
+ if(riskTypeData.getId() == 0){
+ riskTypeData.setUserCreatedBy(userInfo);
+ commonClassDao.save(riskTypeData);
+ }else{
riskTypeData.setModifiedDate(new Date());
- commonClassDao.update(riskTypeData);
- }
+ commonClassDao.update(riskTypeData);
+ }
+ responseString = mapper.writeValueAsString(commonClassDao.getData(RiskType.class));
+ }else{
+ responseString = duplicateResponseString;
+ }
+ if(fromAPI){
+ return utils.getResultForApi(responseString);
+ }else{
+ utils.setResponseData(response, riskTypeDatas, responseString);
}
- String responseString = "";
- if(duplicateflag){
- responseString = duplicateResponseString;
- }else{
- responseString = mapper.writeValueAsString(commonClassDao.getData(RiskType.class));
- }
-
- if (fromAPI) {
- if (responseString!=null && !responseString.equals(duplicateResponseString)) {
- if(isFakeUpdate){
- responseString = "Exists";
- } else {
- responseString = "Success";
- }
- }
- ModelAndView result = new ModelAndView();
- result.setViewName(responseString);
- return result;
- } else {
- response.setCharacterEncoding(utf8);
- response.setContentType(applicationJsonContentType);
- request.setCharacterEncoding(utf8);
-
- PrintWriter out = response.getWriter();
- JSONObject j = new JSONObject("{riskTypeDictionaryDatas: " + responseString + "}");
- out.write(j.toString());
- return null;
- }
}catch (Exception e) {
- LOGGER.error(e);
- response.setCharacterEncoding(utf8);
- request.setCharacterEncoding(utf8);
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
+ utils.setErrorResponseData(response, e);
}
return null;
}
@RequestMapping(value = { "/sp_dictionary/remove_riskType" }, method = {RequestMethod.POST })
- public ModelAndView removeRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- RiskType onapData = mapper.readValue(root.get("data").toString(), RiskType.class);
- commonClassDao.delete(onapData);
- response.setCharacterEncoding(utf8);
- response.setContentType(applicationJsonContentType);
- request.setCharacterEncoding(utf8);
-
- PrintWriter out = response.getWriter();
-
- String responseString = mapper.writeValueAsString(commonClassDao.getData(RiskType.class));
- JSONObject j = new JSONObject("{riskTypeDictionaryDatas: " + responseString + "}");
- out.write(j.toString());
-
- return null;
- } catch (Exception e) {
- LOGGER.error(e);
- response.setCharacterEncoding(utf8);
- request.setCharacterEncoding(utf8);
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
- }
- return null;
+ public void removeRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.removeData(request, response, riskTypeDatas, RiskType.class);
}
-
+
@RequestMapping(value = { "/get_SafePolicyWarningDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningEntityDataByName(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("safePolicyWarningDatas",
- mapper.writeValueAsString(commonClassDao.getDataByColumn(SafePolicyWarning.class, "name")));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- }
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getDataByEntity(response, safePolicyWarningDatas, "name", SafePolicyWarning.class);
}
@RequestMapping(value = { "/get_SafePolicyWarningData" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningeEntityData(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("safePolicyWarningDatas",
- mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class)));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.addHeader("successMapKey", "success");
- response.addHeader(operation, "getDictionary");
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error(e);
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", "dictionaryDBQuery");
- }
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getData(response, safePolicyWarningDatas, SafePolicyWarning.class);
}
@RequestMapping(value = { "/sp_dictionary/save_safePolicyWarning" }, method = {RequestMethod.POST })
public ModelAndView saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ DictionaryUtils utils = getDictionaryUtilsInstance();
try {
- boolean duplicateflag = false;
- boolean isFakeUpdate = false;
- boolean fromAPI = false;
- if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
- fromAPI = true;
- }
+ boolean fromAPI = utils.isRequestFromAPI(request);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
SafePolicyWarning safePolicyWarning;
if (fromAPI) {
safePolicyWarning = mapper.readValue(root.get("dictionaryFields").toString(), SafePolicyWarning.class);
-
- //check if update operation or create, get id for data to be updated and update attributeData
- if (("update").equals(request.getParameter(operation))) {
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(safePolicyWarning.getName(), "name", SafePolicyWarning.class);
- SafePolicyWarning data = (SafePolicyWarning) duplicateData.get(0);
- int id = data.getId();
-
- if(id==0){
- isFakeUpdate=true;
- safePolicyWarning.setId(1);
- } else {
- safePolicyWarning.setId(id);
- }
- }
} else {
safePolicyWarning = mapper.readValue(root.get("safePolicyWarningData").toString(), SafePolicyWarning.class);
}
- if (safePolicyWarning.getId() == 0) {
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(safePolicyWarning.getName(), "name", SafePolicyWarning.class);
- if(!duplicateData.isEmpty()){
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(safePolicyWarning.getName(), "name", SafePolicyWarning.class);
+ boolean duplicateflag = false;
+ if(!duplicateData.isEmpty()){
+ SafePolicyWarning data = (SafePolicyWarning) duplicateData.get(0);
+ if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
+ safePolicyWarning.setId(data.getId());
+ }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) ||
+ (request.getParameter(operation) == null && (data.getId() != safePolicyWarning.getId()))){
duplicateflag = true;
- }else{
- commonClassDao.save(safePolicyWarning);
- }
- } else {
- if(!isFakeUpdate) {
- commonClassDao.update(safePolicyWarning);
}
}
- String responseString = "";
- if(duplicateflag){
- responseString = duplicateResponseString;
- }else{
- responseString = mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
- }
-
- if (fromAPI) {
- if (responseString!=null && !responseString.equals(duplicateResponseString)) {
- if(isFakeUpdate){
- responseString = "Exists";
- } else {
- responseString = "Success";
- }
- }
- ModelAndView result = new ModelAndView();
- result.setViewName(responseString);
- return result;
- } else {
- response.setCharacterEncoding(utf8);
- response.setContentType(applicationJsonContentType);
- request.setCharacterEncoding(utf8);
-
- PrintWriter out = response.getWriter();
- JSONObject j = new JSONObject("{safePolicyWarningDatas: " + responseString + "}");
- out.write(j.toString());
- return null;
- }
-
+ String responseString = null;
+ if(!duplicateflag){
+ if(safePolicyWarning.getId() == 0){
+ commonClassDao.save(safePolicyWarning);
+ }else{
+ commonClassDao.update(safePolicyWarning);
+ }
+ responseString = mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
+ }else{
+ responseString = duplicateResponseString;
+ }
+ if(fromAPI){
+ return utils.getResultForApi(responseString);
+ }else{
+ utils.setResponseData(response, safePolicyWarningDatas, responseString);
+ }
}catch (Exception e) {
- LOGGER.error(e);
- response.setCharacterEncoding(utf8);
- request.setCharacterEncoding(utf8);
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
+ utils.setErrorResponseData(response, e);
}
return null;
}
@RequestMapping(value = { "/sp_dictionary/remove_SafePolicyWarning" }, method = {RequestMethod.POST })
public void removeSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- SafePolicyWarning safePolicyWarningData = mapper.readValue(root.get("data").toString(),
- SafePolicyWarning.class);
- commonClassDao.delete(safePolicyWarningData);
- response.setCharacterEncoding(utf8);
- response.setContentType(applicationJsonContentType);
- request.setCharacterEncoding(utf8);
-
- PrintWriter out = response.getWriter();
-
- String responseString = mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
- JSONObject j = new JSONObject("{safePolicyWarningDatas: " + responseString + "}");
- out.write(j.toString());
- } catch (Exception e) {
- LOGGER.error(e);
- response.setCharacterEncoding(utf8);
- request.setCharacterEncoding(utf8);
- PrintWriter out = response.getWriter();
- out.write(PolicyUtils.CATCH_EXCEPTION);
- }
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.removeData(request, response, safePolicyWarningDatas, SafePolicyWarning.class);
}
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
index 53616aa7f..c44459690 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.pap.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
import java.io.BufferedReader;
import java.io.IOException;
@@ -47,13 +48,21 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.DecisionPolicyDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.DescriptiveDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.DictionaryController;
import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.MicroServiceDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.PolicyScopeDictionaryController;
+import org.onap.policy.pap.xacml.rest.controller.SafePolicyController;
import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation;
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.BRMSParamTemplate;
+import org.onap.policy.rest.jpa.Category;
import org.onap.policy.rest.jpa.PolicyEditorScopes;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
@@ -75,6 +84,7 @@ public class XACMLPAPTest {
private ServletConfig servletConfig;
private XACMLPapServlet pap;
private SessionFactory sessionFactory;
+ private CommonClassDao commonClassDao;
@Before
public void setUp() throws ServletException {
@@ -90,7 +100,7 @@ public class XACMLPAPTest {
.thenReturn("src/test/resources/xacml.pap.properties");
pap = new XACMLPapServlet();
pap.init(servletConfig);
- CommonClassDao commonClassDao = Mockito.mock(CommonClassDao.class);
+ commonClassDao = Mockito.mock(CommonClassDao.class);
new DictionaryUtils(commonClassDao);
DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
Mockito.mock(DictionaryUtils.class);
@@ -523,6 +533,170 @@ public class XACMLPAPTest {
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
}
+ @Test
+ public void testCommonCreateDictionary() throws IOException, SQLException, ServletException {
+ new DictionaryController(commonClassDao);
+ new ActionPolicyDictionaryController(commonClassDao);
+ new SafePolicyController(commonClassDao);
+ new DescriptiveDictionaryController(commonClassDao);
+ List<Object> object = new ArrayList<>();
+ object.add(new Category());
+ when(commonClassDao.getDataById(Category.class, "shortName", "resource")).thenReturn(object);
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ String json = "{\"dictionaryFields\": {\"onapName\": \"testMMRestAPI1\",\"description\": \"testing update response message\"}}";
+ dictionaryTestSetup(false, "OnapName", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\": {\"xacmlId\": \"testMMRestAPI1\",\"datatypeBean\": {\"shortName\": \"string\"}, \"description\": \"testing update\",\"priority\": \"High\",\"userDataTypeValues\": [{\"attributeValues\": \"testAttr\"}, {\"attributeValues\": \"testAttr2\"}, {\"attributeValues\": \"testAttr3\"}]}}";
+ dictionaryTestSetup(false, "Attribute", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"attributeName\":\"TestMMrestAPI1\",\"type\":\"REST\",\"url\":\"testsomeurl.com\",\"method\":\"GET\",\"description\":\"test create\",\"body\":\"Testing Create\",\"headers\":[{\"option\":\"test1\",\"number\":\"test\"},{\"option\":\"test2\",\"number\":\"test\"}]}}";
+ dictionaryTestSetup(false, "Action", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"scopeName\":\"testMMRestAPI1\",\"description\":\"test\",\"attributes\":[{\"option\":\"test1\",\"number\":\"test\"},{\"option\":\"test2\",\"number\":\"test\"}]}}";
+ dictionaryTestSetup(false, "DescriptiveScope", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"riskName\":\"testMMrestAPI1\",\"description\":\"test\"}}";
+ dictionaryTestSetup(false, "RiskType", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testMMrestAPI1\",\"message\":\"test\",\"riskType\":\"testMMrestAPI1\"}}";
+ dictionaryTestSetup(false, "SafePolicyWarning", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ }
+
+ @Test
+ public void testDecisionCreateDictionary() throws IOException, SQLException, ServletException {
+ new DecisionPolicyDictionaryController(commonClassDao);
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ String json = "{\"dictionaryFields\":{\"xacmlId\":\"testMMRestAPI1\",\"datatypeBean\":{\"shortName\":\"string\"},\"description\":\"test\",\"priority\":\"High\"}}";
+ dictionaryTestSetup(false, "Settings", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"bbid\":\"BB1\",\"workstep\":\"1\",\"treatments\":\"Manual Handling,Abort,Retry\"}}";
+ dictionaryTestSetup(false, "RainyDayTreatments", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ }
+
+ @Test
+ public void testMSCreateDictionary() throws IOException, SQLException, ServletException {
+ new MicroServiceDictionaryController(commonClassDao);
+ new PolicyScopeDictionaryController(commonClassDao);
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ String json = "{\"dictionaryFields\":{\"name\":\"testMMrestAPI1\",\"descriptionValue\":\"test\"}}";
+ dictionaryTestSetup(false, "MicroServiceLocation", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testMMrestAPI1\",\"descriptionValue\":\"test\"}}";
+ dictionaryTestSetup(false, "MicroServiceConfigName", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testMMrestAPI1\",\"description\":\"test\"}}";
+ dictionaryTestSetup(false, "DCAEUUID", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testApiANY\",\"descriptionValue\":\"default test\"}}";
+ dictionaryTestSetup(false, "PolicyScopeService", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testApiANY\",\"descriptionValue\":\"default test\"}}";
+ dictionaryTestSetup(false, "PolicyScopeResource", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testApiANY\",\"descriptionValue\":\"default test\"}}";
+ dictionaryTestSetup(false, "PolicyScopeType", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"name\":\"testApiANY\",\"descriptionValue\":\"default test\"}}";
+ dictionaryTestSetup(false, "PolicyScopeClosedLoop", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+ json = "{\"dictionaryFields\":{\"groupName\":\"testMMrestAPI1\",\"description\":\"testing\"},\"groupPolicyScopeListData1\":{\"resource\":\"ANY\",\"type\":\"ANY\",\"service\":\"ANY\",\"closedloop\":\"ANY\"}}";
+ dictionaryTestSetup(false, "GroupPolicyScopeList", json);
+ // send Request to PAP
+ pap.service(httpServletRequest, httpServletResponse);
+ // Verify
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ }
+
private void dictionaryTestSetup(Boolean updateFlag, String dictionaryType, String json) throws IOException, SQLException {
Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
Mockito.when(httpServletRequest.getHeader("ClientScope")).thenReturn("dictionaryItem");
@@ -566,6 +740,27 @@ public class XACMLPAPTest {
}
@Test
+ public void getDictionary() throws ServletException, IOException{
+ String[] dictionarys = new String[]{"Attribute", "OnapName", "Action", "BRMSParamTemplate","VSCLAction"
+ ,"VNFType","PEPOptions","Varbind","Service","Site", "Settings", "RainyDayTreatments",
+ "DescriptiveScope", "ActionList", "ProtocolList", "Zone", "SecurityZone",
+ "PrefixList", "AddressGroup", "ServiceGroup", "ServiceList", "TermList",
+ "MicroServiceLocation", "MicroServiceConfigName", "DCAEUUID", "MicroServiceModels",
+ "PolicyScopeService", "PolicyScopeResource", "PolicyScopeType", "PolicyScopeClosedLoop",
+ "GroupPolicyScopeList", "RiskType", "SafePolicyWarning", "MicroServiceDictionary"};
+ for(String dictionary : dictionarys){
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ httpServletResponse = new MockHttpServletResponse();
+ Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("GET");
+ Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api");
+ Mockito.when(httpServletRequest.getParameter("dictionaryType")).thenReturn(dictionary);
+ pap.service(httpServletRequest, httpServletResponse);
+ assertTrue(HttpServletResponse.SC_OK == httpServletResponse.getStatus());
+ }
+ }
+
+ @Test
public void testDummy() throws ServletException, IOException {
Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
index e8d602ce5..7c1c507c2 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
@@ -20,20 +20,46 @@
package org.onap.policy.pap.xacml.rest.controller;
import static org.junit.Assert.assertTrue;
-import org.onap.policy.pap.xacml.rest.controller.DictionaryImportController;
-import org.junit.After;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.springframework.mock.web.MockHttpServletResponse;
-public class DictionaryImportControllerTest {
+public class DictionaryImportControllerTest extends Mockito{
private static Logger logger = FlexLogger.getLogger(DictionaryImportController.class);
+ private static CommonClassDao commonClassDao;
+ private HttpServletRequest request = null;
+ private HttpServletResponse response = null;
+ private DictionaryImportController controller = null;
+
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+ doNothing().when(commonClassDao).save(new Object());
+ controller = new DictionaryImportController();
+ new DictionaryImportController(commonClassDao);
+ request = Mockito.mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
}
@Test
@@ -45,8 +71,69 @@ public class DictionaryImportControllerTest {
assertTrue(cotroller.isValidDictionaryName("ActionList"));
}
- @After
- public void destroy(){
-
- }
+ @Test
+ public void testImportDictionaryData() throws ServletException, IOException{
+ List<String> fileNames = new ArrayList<>();
+ fileNames.add("Attribute.csv");
+ fileNames.add("ActionPolicyDictionary.csv");
+ fileNames.add("OnapName.csv");
+ fileNames.add("MSPolicyDictionary.csv");
+ fileNames.add("ClosedLoopService.csv");
+ fileNames.add("ClosedLoopSite.csv");
+ fileNames.add("VarbindDictionary.csv");
+ fileNames.add("BRMSParamDictionary.csv");
+ fileNames.add("BRMSControllerDictionary.csv");
+ fileNames.add("BRMSDependencyDictionary.csv");
+ fileNames.add("PrefixList.csv");
+ fileNames.add("SecurityZone.csv");
+ fileNames.add("ServiceList.csv");
+ fileNames.add("ServiceGroup.csv");
+ fileNames.add("AddressGroup.csv");
+ fileNames.add("ProtocolList.csv");
+ fileNames.add("TermList.csv");
+ fileNames.add("SearchCriteria.csv");
+ fileNames.add("VNFType.csv");
+ fileNames.add("VSCLAction.csv");
+ fileNames.add("PEPOptions.csv");
+ fileNames.add("Settings.csv");
+ fileNames.add("Zone.csv");
+ fileNames.add("ActionList.csv");
+ for(int i =0; i < fileNames.size(); i++){
+ File file = new File("src/test/resources/dictionaryImport/"+fileNames.get(i));
+ try(FileInputStream targetStream = new FileInputStream(file)){
+ PushPolicyControllerTest pushController = new PushPolicyControllerTest();
+ when(request.getInputStream()).thenReturn(pushController.getInputStream(getBytes(targetStream)));
+ when(request.getParameter("userId")).thenReturn("demo");
+ when(request.getParameter("dictionaryName")).thenReturn(fileNames.get(i));
+ controller.importDictionaryData(request, response);
+ assertTrue(HttpServletResponse.SC_OK == response.getStatus());
+ } catch (IOException e) {
+ fail();
+ }
+ }
+ when(request.getParameter("dictionaryName")).thenReturn("WrongName");
+ controller.importDictionaryData(request, response);
+ assertTrue(HttpServletResponse.SC_OK == response.getStatus());
+
+ when(request.getParameter("dictionaryName")).thenReturn("");
+ controller.importDictionaryData(request, response);
+ assertTrue(HttpServletResponse.SC_BAD_REQUEST == response.getStatus());
+
+ when(request.getInputStream()).thenReturn(null);
+ when(request.getParameter("dictionaryName")).thenReturn("Attribute.csv");
+ controller.importDictionaryData(request, response);
+ assertTrue(HttpServletResponse.SC_INTERNAL_SERVER_ERROR == response.getStatus());
+ }
+
+ public static byte[] getBytes(InputStream is) throws IOException {
+ int len;
+ int size = 1024;
+ byte[] buf;
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ buf = new byte[size];
+ while ((len = is.read(buf, 0, size)) != -1)
+ bos.write(buf, 0, len);
+ buf = bos.toByteArray();
+ return buf;
+ }
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java
index 48af2442c..7d23475a1 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyControllerTest.java
@@ -22,6 +22,7 @@ package org.onap.policy.pap.xacml.rest.controller;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.BufferedReader;
@@ -36,6 +37,7 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.RiskType;
import org.onap.policy.rest.jpa.SafePolicyWarning;
@@ -57,20 +59,22 @@ public class SafePolicyControllerTest {
public void setUp() throws Exception {
logger.info("setUp: Entering");
commonClassDao = Mockito.mock(CommonClassDao.class);
-
+
data = new ArrayList<>();
data.add("Test");
-
+
userInfo = new UserInfo();
userInfo.setUserLoginId("Test");
userInfo.setUserName("Test");
-
+
doNothing().when(commonClassDao).delete(new RiskType());
doNothing().when(commonClassDao).save(new RiskType());
-
+
controller = new SafePolicyController();
controller.setCommonClassDao(commonClassDao);
-
+ new DictionaryUtils(commonClassDao);
+ DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
+ mock(DictionaryUtils.class);
request = Mockito.mock(HttpServletRequest.class);
response = new MockHttpServletResponse();
logger.info("setUp: exit");
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionList.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionList.csv
new file mode 100644
index 000000000..4e1760532
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionList.csv
@@ -0,0 +1,2 @@
+"Id","Action Name","Description"
+104443,"1234","43234" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionPolicyDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionPolicyDictionary.csv
new file mode 100644
index 000000000..4c447d63f
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ActionPolicyDictionary.csv
@@ -0,0 +1,2 @@
+Id,Attribute Name,Type,Url,Method,Headers,Description,Created By,Modified By,Created Date,Modified Date,,body
+10051,AttribName5,REST,www.testitc.com,PUT,TestHeader=TestHeaderVal,Action policy attribute for GET method ,demo,demo ,Mon Jun 20 2016 11:10:05 GMT-0400 (Eastern Daylight Time),Mon Jun 20 2016 11:10:05 GMT-0400 (Eastern Daylight Time),,"{""a"":""b""}"
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/AddressGroup.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/AddressGroup.csv
new file mode 100644
index 000000000..9225592be
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/AddressGroup.csv
@@ -0,0 +1,2 @@
+"Id","Group Name","Prefix List","Description"
+66782,"Group_1702_Address0Group_37_new","testMMRestAPI1,testMMRestAPI2","testing" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/Attribute.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Attribute.csv
new file mode 100644
index 000000000..e51e4d2d2
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Attribute.csv
@@ -0,0 +1,6 @@
+Id,Attribute ID,Data Type,Attribute Value,Description,Priority,Created By,Modified By,Created Date,Modified Date
+7,Test,string,"test,test",test,High,Demo,Demo,Mon Feb 26 2018 23:26:24 GMT-0500 (Eastern Standard Time),Mon Feb 26 2018 23:26:37 GMT-0500 (Eastern Standard Time)
+1,Test,integer,,,,,,,
+2,Test,double,,,,,,,
+3,Test,boolean,,,,,,,
+4,Test,user,,,,,,,
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSControllerDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSControllerDictionary.csv
new file mode 100644
index 000000000..81e6da1b2
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSControllerDictionary.csv
@@ -0,0 +1,2 @@
+Id,Controller Name,Description,Created By,Created Date,Modified By,Modified Date,controller
+2833,BRMSController_GA_21_New_2018_02_23_20_13_15,BRMSTest,demo,Fri Feb 23 2018 09:43:23 GMT-0500 (Eastern Standard Time),demo,Fri Feb 23 2018 09:43:23 GMT-0500 (Eastern Standard Time),test
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSDependencyDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSDependencyDictionary.csv
new file mode 100644
index 000000000..dfd5b2fa0
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSDependencyDictionary.csv
@@ -0,0 +1,2 @@
+Id,Dependency Name,Description,Created By,Created Date,Modified By,Modified Date,dependency
+391,BRMSDependency_GA_02,BRMSDependenctTest01,demo,Thu Sep 07 2017 14:36:36 GMT-0400 (Eastern Daylight Time),demo,Thu Sep 07 2017 14:36:36 GMT-0400 (Eastern Daylight Time),test
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSParamDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSParamDictionary.csv
new file mode 100644
index 000000000..c3e3c3dd8
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/BRMSParamDictionary.csv
@@ -0,0 +1,2 @@
+Id,Rule Name,Description,Created By,Created Date,rule
+58537,CLeNodeB,BRMS template for eNodeB guard 1802.48.3-1,demo,Fri Feb 02 2018 12:47:54 GMT-0500 (Eastern Standard Time),test
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopService.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopService.csv
new file mode 100644
index 000000000..42394254b
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopService.csv
@@ -0,0 +1,2 @@
+Id,Service Name,Description,Created By,Modified By,Created Date,Modified Date
+10952,vSCP,,demo,demo,Tue Jun 28 2016 14:42:17 GMT-0400 (Eastern Daylight Time),Tue Jun 28 2016 14:42:17 GMT-0400 (Eastern Daylight Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopSite.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopSite.csv
new file mode 100644
index 000000000..c3bda5607
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ClosedLoopSite.csv
@@ -0,0 +1,2 @@
+Id,Site Name,Description,Created By,Modified By,Created Date,Modified Date
+5651,Default,,demo,demo,Thu Mar 17 2016 17:45:20 GMT-0400 (Eastern Daylight Time),Thu Mar 17 2016 17:45:20 GMT-0400 (Eastern Daylight Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/MSPolicyDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/MSPolicyDictionary.csv
new file mode 100644
index 000000000..cce394237
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/MSPolicyDictionary.csv
@@ -0,0 +1,2 @@
+Id,Micro Service Model,Description,Model Version,Imported By,dependency,attributes,enumValues,Ref Attributes,Sub Attributes
+16857,PolicyBody,PolicyBody,0.1.0-SNAPSHOT,demo,test,test,test,test,test
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/OnapName.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/OnapName.csv
new file mode 100644
index 000000000..52600442a
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/OnapName.csv
@@ -0,0 +1,2 @@
+Id,Onap Name,Description,Created By,Modified By,Created Date,Modified Date
+19369,PDPD,for PDPD,demo,demo,Wed Aug 30 2017 10:50:18 GMT-0400 (Eastern Daylight Time),Wed Aug 30 2017 10:50:18 GMT-0400 (Eastern Daylight Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/PEPOptions.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/PEPOptions.csv
new file mode 100644
index 000000000..61adca140
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/PEPOptions.csv
@@ -0,0 +1,2 @@
+"Id","PEP Name","Actions","Description","Created By","Modified By","Created Date","Modified Date"
+108274,"PEPoptions_110920172059","test1=#@test:#@test2=#@test","testing create","API","API","Mon Sep 11 2017 11:29:48 GMT-0400 (Eastern Daylight Time)","Mon Sep 11 2017 11:29:48 GMT-0400 (Eastern Daylight Time)" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/PrefixList.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/PrefixList.csv
new file mode 100644
index 000000000..bacfe85a4
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/PrefixList.csv
@@ -0,0 +1,2 @@
+"Id","PrefixList Name","Description","PrefixList Value"
+122155,"221120170105","testing","12.81.230.32/27" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ProtocolList.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ProtocolList.csv
new file mode 100644
index 000000000..8ef655515
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ProtocolList.csv
@@ -0,0 +1,2 @@
+"Id","Protocol Name","Description"
+5497,"221120170105","test" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/SearchCriteria.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/SearchCriteria.csv
new file mode 100644
index 000000000..b8bf7af68
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/SearchCriteria.csv
@@ -0,0 +1,2 @@
+Id,Descriptive Scope Name,Search Criteria,Description,Created By,Modified By,Created Date,Modified Date
+108925,check_8901,12:test,,demo,demo,Wed Oct 25 2017 17:39:01 GMT-0400 (Eastern Daylight Time),Wed Oct 25 2017 17:39:01 GMT-0400 (Eastern Daylight Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/SecurityZone.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/SecurityZone.csv
new file mode 100644
index 000000000..edb09a02d
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/SecurityZone.csv
@@ -0,0 +1,2 @@
+"Id","Zone Name","Zone Value"
+105205,"check_new","Description" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceGroup.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceGroup.csv
new file mode 100644
index 000000000..2fe18d95f
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceGroup.csv
@@ -0,0 +1,2 @@
+"Id","Group Name","Service List"
+66589,"Group_Group2017","telnet" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceList.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceList.csv
new file mode 100644
index 000000000..e4fd75f7b
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/ServiceList.csv
@@ -0,0 +1,2 @@
+"Id","Service Name","Description","Service Type","Transport Protocol","APP Protocol","Ports"
+100024,"BillTesting1","BillTesting","SERVICE","IP2","","80" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/Settings.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Settings.csv
new file mode 100644
index 000000000..b73db2df1
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Settings.csv
@@ -0,0 +1,6 @@
+Id,Settings ID,Data Type,Description,Created By,Modified By,Created Date,Modified Date,priority
+7681,2.2112E+11,string,test,API,API,Tue Nov 21 2017 14:33:28 GMT-0500 (Eastern Standard Time),Tue Nov 21 2017 14:33:28 GMT-0500 (Eastern Standard Time),high
+1,test,integer,,,,,,
+2,test,double,,,,,,
+3,test,boolean,,,,,,
+4,test,user,,,,,,
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/TermList.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/TermList.csv
new file mode 100644
index 000000000..06338a26f
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/TermList.csv
@@ -0,0 +1,2 @@
+Id,Term-Name,Term-Description,From Zone,To Zone,Source-IP-List,Destination-IP-List,Source-Port-List,Destination-Port-List,Action List,Created By,Modified By,Created Date,Modified Date
+118837,basicRule,BasicRule,Trusted,UnTrusted,PL_Astra,PL_CCE,,snmp,deny,demo,demo,Fri Dec 01 2017 10:30:45 GMT-0500 (Eastern Standard Time),Fri Dec 01 2017 10:30:45 GMT-0500 (Eastern Standard Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/VNFType.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VNFType.csv
new file mode 100644
index 000000000..8dca6b7ff
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VNFType.csv
@@ -0,0 +1,2 @@
+"Id","VNF Type","Description","Created By","Modified By","Created Date","Modified Date"
+108043,"221120170101","testing create","API","API","Tue Nov 21 2017 14:31:24 GMT-0500 (Eastern Standard Time)","Tue Nov 21 2017 14:31:24 GMT-0500 (Eastern Standard Time)" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/VSCLAction.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VSCLAction.csv
new file mode 100644
index 000000000..b0d7d86c2
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VSCLAction.csv
@@ -0,0 +1,2 @@
+"Id","VSCL Action","Description","Created By","Modified By","Created Date","Modified Date"
+56419,"221120170102","default test","API","API","Tue Nov 21 2017 14:32:14 GMT-0500 (Eastern Standard Time)","Tue Nov 21 2017 14:32:33 GMT-0500 (Eastern Standard Time)" \ No newline at end of file
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/VarbindDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VarbindDictionary.csv
new file mode 100644
index 000000000..61166a07d
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/VarbindDictionary.csv
@@ -0,0 +1,2 @@
+Id,Varbind Name,Varbind Description,Varbind OID,Created By,Modified By,Created Date,Modified Date
+15760,A1,test,test,demo,demo,Mon Sep 26 2016 12:37:25 GMT-0400 (Eastern Daylight Time),Mon Sep 26 2016 12:37:25 GMT-0400 (Eastern Daylight Time)
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/Zone.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Zone.csv
new file mode 100644
index 000000000..d563a6be6
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/Zone.csv
@@ -0,0 +1,2 @@
+"Id","Zone Name","Zone Value"
+57889,"2017","2017" \ No newline at end of file