diff options
Diffstat (limited to 'ONAP-PAP-REST/src/main/java')
7 files changed, 1252 insertions, 686 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java index 0cd263800..d6b09086a 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modified Copyright (C) 2019 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,26 +97,33 @@ public class ConfigPolicy extends Policy { // Here we are adding the extension for the configurations file based on the // config type selection for saving. private String getConfigFile(String filename) { + filename = removeExtentsion(filename); + String id = policyAdapter.getConfigType(); + + if (id == null) { + return filename; + } + switch (id.toUpperCase()) + { + case JSON_CONFIG: + return filename + ".json"; + case XML_CONFIG: + return filename + ".xml"; + case PROPERTIES_CONFIG: + return filename + ".properties"; + case OTHER_CONFIG: + return filename + ".txt"; + default: + return filename; + + } + } + + private String removeExtentsion(String filename) { filename = FilenameUtils.removeExtension(filename); if (filename.endsWith(".xml")) { filename = filename.substring(0, filename.length() - 4); } - String id = policyAdapter.getConfigType(); - - if (id != null) { - if (id.equalsIgnoreCase(JSON_CONFIG)) { - filename = filename + ".json"; - } - if (id.equalsIgnoreCase(XML_CONFIG)) { - filename = filename + ".xml"; - } - if (id.equalsIgnoreCase(PROPERTIES_CONFIG)) { - filename = filename + ".properties"; - } - if (id.equalsIgnoreCase(OTHER_CONFIG)) { - filename = filename + ".txt"; - } - } return filename; } @@ -134,24 +142,30 @@ public class ConfigPolicy extends Policy { */ configBodyData = policyAdapter.getConfigBodyData(); String id = policyAdapter.getConfigType(); - if (id != null) { - if (id.equals(JSON_CONFIG)) { + if (id == null) { + return isValidForm; + } + switch (id) { + case JSON_CONFIG: if (!PolicyUtils.isJSONValid(configBodyData)) { isValidForm = false; } - } else if (id.equals(XML_CONFIG)) { + break; + case XML_CONFIG: if (!PolicyUtils.isXMLValid(configBodyData)) { isValidForm = false; } - } else if (id.equals(PROPERTIES_CONFIG)) { + break; + case PROPERTIES_CONFIG: if (!PolicyUtils.isPropValid(configBodyData) || configBodyData.equals("")) { isValidForm = false; } - } else if (id.equals(OTHER_CONFIG)) { + break; + case OTHER_CONFIG: if (configBodyData.equals("")) { isValidForm = false; } - } + break; } return isValidForm; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java index 86455aa30..103928cbc 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.onap.policy.pap.xacml.rest.components; +import com.google.gson.Gson; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; @@ -35,7 +36,6 @@ import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; - import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.onap.policy.common.logging.eelf.MessageCodes; @@ -50,12 +50,10 @@ import org.onap.policy.rest.util.MSAttributeObject; import org.onap.policy.rest.util.MSModelUtils; import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE; -import com.google.gson.Gson; - public class CreateNewMicroServiceModel { private static final Logger logger = FlexLogger.getLogger(CreateNewMicroServiceModel.class); private MicroServiceModels newModel = null; - private HashMap<String,MSAttributeObject > classMap = new HashMap<>(); + private HashMap<String, MSAttributeObject> classMap = new HashMap<>(); private MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName()); @@ -64,7 +62,17 @@ public class CreateNewMicroServiceModel { super(); } - public CreateNewMicroServiceModel(String importFile, String modelName, String description, String version, String randomID) { + /** + * Instantiates a new creates the new micro service model. + * + * @param importFile the import file + * @param modelName the model name + * @param description the description + * @param version the version + * @param randomID the random ID + */ + public CreateNewMicroServiceModel(String importFile, String modelName, String description, String version, + String randomID) { this.newModel = new MicroServiceModels(); this.newModel.setVersion(version); @@ -75,24 +83,24 @@ public class CreateNewMicroServiceModel { String cleanUpFile = null; Map<String, MSAttributeObject> tempMap = new HashMap<>(); - //Need to delete the file - if (importFile.contains(".zip")){ + // Need to delete the file + if (importFile.contains(".zip")) { extractFolder(randomID + ".zip"); File directory = new File("ExtractDir" + File.separator + randomID); List<File> fileList = listModelFiles(directory.toString()); - //get all the files from a director + // get all the files from a director processFiles(modelName, fileList); doCleanUpFiles(randomID); - }else { - if(importFile.contains(".yml")){ + } else { + if (importFile.contains(".yml")) { - processYmlModel("ExtractDir" + File.separator + randomID+".yml", modelName); - cleanUpFile = "ExtractDir" + File.separator + randomID+".yml"; + processYmlModel("ExtractDir" + File.separator + randomID + ".yml", modelName); + cleanUpFile = "ExtractDir" + File.separator + randomID + ".yml"; - }else{ - tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID+".xmi", MODEL_TYPE.XMI); + } else { + tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID + ".xmi", MODEL_TYPE.XMI); classMap.putAll(tempMap); - cleanUpFile = "ExtractDir" + File.separator + randomID+".xmi"; + cleanUpFile = "ExtractDir" + File.separator + randomID + ".xmi"; } File deleteFile = new File(cleanUpFile); @@ -102,16 +110,16 @@ public class CreateNewMicroServiceModel { private void processFiles(String modelName, List<File> fileList) { Map<String, MSAttributeObject> tempMap; - for (File file : fileList){ - if (file.isFile()){ - int i = file.getName().lastIndexOf('.'); - String type = file.getName().substring(i+1); + for (File file : fileList) { + if (file.isFile()) { + int indx = file.getName().lastIndexOf('.'); + String type = file.getName().substring(indx + 1); - if("yml".equalsIgnoreCase(type)){ + if ("yml".equalsIgnoreCase(type)) { processYmlModel(file.toString(), modelName); - }else{ + } else { tempMap = utils.processEpackage(file.getAbsolutePath(), MODEL_TYPE.XMI); classMap.putAll(tempMap); @@ -133,17 +141,17 @@ public class CreateNewMicroServiceModel { } } - private void processYmlModel(String fileName, String modelName){ + private void processYmlModel(String fileName, String modelName) { try { utils.parseTosca(fileName); - MSAttributeObject msAttributes= new MSAttributeObject(); + MSAttributeObject msAttributes = new MSAttributeObject(); msAttributes.setClassName(modelName); - LinkedHashMap<String, String> returnAttributeList =new LinkedHashMap<>(); + LinkedHashMap<String, String> returnAttributeList = new LinkedHashMap<>(); returnAttributeList.put(modelName, utils.getAttributeString()); msAttributes.setAttribute(returnAttributeList); @@ -151,24 +159,31 @@ public class CreateNewMicroServiceModel { msAttributes.setMatchingSet(utils.getMatchableValues()); - LinkedHashMap<String, String> returnReferenceList =new LinkedHashMap<>(); + LinkedHashMap<String, String> returnReferenceList = new LinkedHashMap<>(); returnReferenceList.put(modelName, utils.getReferenceAttributes()); msAttributes.setRefAttribute(returnReferenceList); - if(!PolicyDBDao.isNullOrEmpty(utils.getListConstraints())){ - LinkedHashMap<String, String> enumList =new LinkedHashMap<>(); - String[] listArray=utils.getListConstraints().split("#"); - for(String str:listArray){ - String[] strArr= str.split("="); - if(strArr.length>1){ + if (!PolicyDBDao.isNullOrEmpty(utils.getListConstraints())) { + LinkedHashMap<String, String> enumList = new LinkedHashMap<>(); + String[] listArray = utils.getListConstraints().split("#"); + for (String str : listArray) { + String[] strArr = str.split("="); + if (strArr.length > 1) { enumList.put(strArr[0], strArr[1]); } } msAttributes.setEnumType(enumList); } + if (utils.getJsonRuleFormation() != null) { + msAttributes.setRuleFormation(utils.getJsonRuleFormation()); + } - classMap=new LinkedHashMap<>(); + if (utils.getDataOrderInfo() != null) { + msAttributes.setDataOrderInfo(utils.getDataOrderInfo()); + } + + classMap = new LinkedHashMap<>(); classMap.put(modelName, msAttributes); } catch (Exception e) { @@ -196,14 +211,14 @@ public class CreateNewMicroServiceModel { int BUFFER = 2048; File file = new File(zipFile); - try(ZipFile zip = new ZipFile("ExtractDir" + File.separator +file)) { + try (ZipFile zip = new ZipFile("ExtractDir" + File.separator + file)) { - String newPath = zipFile.substring(0, zipFile.length() - 4); + String newPath = zipFile.substring(0, zipFile.length() - 4); new File(newPath).mkdir(); Enumeration zipFileEntries = zip.entries(); // Process each entry - while (zipFileEntries.hasMoreElements()){ + while (zipFileEntries.hasMoreElements()) { // grab a zip file entry ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); String currentEntry = entry.getName(); @@ -212,14 +227,13 @@ public class CreateNewMicroServiceModel { destinationParent.mkdirs(); - if (!entry.isDirectory()){ - BufferedInputStream is = new BufferedInputStream(zip - .getInputStream(entry)); + if (!entry.isDirectory()) { + BufferedInputStream is = new BufferedInputStream(zip.getInputStream(entry)); int currentByte; byte data[] = new byte[BUFFER]; - try(FileOutputStream fos = new FileOutputStream(destFile); - BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) { + try (FileOutputStream fos = new FileOutputStream(destFile); + BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) { while ((currentByte = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, currentByte); @@ -229,7 +243,7 @@ public class CreateNewMicroServiceModel { is.close(); } - if (currentEntry.endsWith(".zip")){ + if (currentEntry.endsWith(".zip")) { extractFolder(destFile.getAbsolutePath()); } } @@ -241,60 +255,70 @@ public class CreateNewMicroServiceModel { public Map<String, String> addValuesToNewModel(String type) { Map<String, String> successMap = new HashMap<>(); - MSAttributeObject mainClass = null; + MSAttributeObject mainClass = null; List<String> dependency = null; String subAttribute = null; - if (!classMap.containsKey(this.newModel.getModelName())){ - logger.error("Model Provided does not contain the service name provided in request. Unable to import new model"); - PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", "Unable to pull out required values, file missing service name provided in request"); + if (!classMap.containsKey(this.newModel.getModelName())) { + logger.error( + "Model Provided does not contain the service name provided in request. Unable to import new model"); + PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "AddValuesToNewModel", + "Unable to pull out required values, file missing service name provided in request"); successMap.put("error", "MISSING"); return successMap; } mainClass = classMap.get(this.newModel.getModelName()); - if(".yml".equalsIgnoreCase(type)){ + if (".yml".equalsIgnoreCase(type)) { newModel.setDependency("[]"); - if(mainClass.getSubClass() != null){ - String value = new Gson().toJson(mainClass.getSubClass()); - newModel.setSub_attributes(value); + if (mainClass.getSubClass() != null) { + String value = new Gson().toJson(mainClass.getSubClass()); + newModel.setSub_attributes(value); } - if(mainClass.getAttribute() != null){ - String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", ""); - int equalsIndexForAttributes= attributes.indexOf("="); - String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1); + if (mainClass.getAttribute() != null) { + String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); + int equalsIndexForAttributes = attributes.indexOf("="); + String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); } - if(mainClass.getRefAttribute() != null){ - String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); - int equalsIndex= refAttributes.indexOf("="); - String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1); + if (mainClass.getRefAttribute() != null) { + String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); + int equalsIndex = refAttributes.indexOf("="); + String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRef_attributes(refAttributesAfterFirstEquals); } - if(mainClass.getEnumType() != null){ + if (mainClass.getEnumType() != null) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } - if(mainClass.getMatchingSet() != null){ + if (mainClass.getMatchingSet() != null) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } + if (mainClass.getRuleFormation() != null) { + this.newModel.setRuleFormation(mainClass.getRuleFormation()); + } + + if (mainClass.getDataOrderInfo() != null) { + this.newModel.setDataOrderInfo(mainClass.getDataOrderInfo()); + } - }else{ + } else { - String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""}); + String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, + new String[] {"", "", ""}); this.newModel.setDependency(dependTemp); - if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()){ + if (this.newModel.getDependency() != null && !this.newModel.getDependency().isEmpty()) { dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(","))); dependency = utils.getFullDependencyList(dependency, classMap); - if (!dependency.isEmpty()){ - for (String element : dependency){ + if (!dependency.isEmpty()) { + for (String element : dependency) { MSAttributeObject temp = new MSAttributeObject(); - if (classMap.containsKey(element)){ + if (classMap.containsKey(element)) { temp = classMap.get(element); mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); @@ -305,19 +329,20 @@ public class CreateNewMicroServiceModel { subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); this.newModel.setSub_attributes(subAttribute); - if(mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()){ + if (mainClass.getAttribute() != null && !mainClass.getAttribute().isEmpty()) { this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); } - if(mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()){ - this.newModel.setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); + if (mainClass.getRefAttribute() != null && !mainClass.getRefAttribute().isEmpty()) { + this.newModel + .setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", "")); } - if(mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()){ + if (mainClass.getEnumType() != null && !mainClass.getEnumType().isEmpty()) { this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); } - if(mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()){ + if (mainClass.getMatchingSet() != null && !mainClass.getMatchingSet().isEmpty()) { this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); } } @@ -326,14 +351,15 @@ public class CreateNewMicroServiceModel { } - public Map<String, String> saveImportService(){ + public Map<String, String> saveImportService() { String modelName = this.newModel.getModelName(); String imported_by = "API"; String version = this.newModel.getVersion(); Map<String, String> successMap = new HashMap<>(); CommonClassDaoImpl dbConnection = new CommonClassDaoImpl(); - List<Object> result = dbConnection.getDataById(MicroServiceModels.class, "modelName:version", modelName+":"+version); - if(result == null || result.isEmpty()){ + List<Object> result = + dbConnection.getDataById(MicroServiceModels.class, "modelName:version", modelName + ":" + version); + if (result == null || result.isEmpty()) { MicroServiceModels model = new MicroServiceModels(); model.setModelName(modelName); model.setVersion(version); @@ -345,13 +371,15 @@ public class CreateNewMicroServiceModel { model.setRef_attributes(this.newModel.getRef_attributes()); model.setSub_attributes(this.newModel.getSub_attributes()); model.setDataOrderInfo(this.newModel.getDataOrderInfo()); + model.setDecisionModel(this.newModel.isDecisionModel()); + model.setRuleFormation(this.newModel.getRuleFormation()); UserInfo userInfo = new UserInfo(); userInfo.setUserLoginId(imported_by); userInfo.setUserName(imported_by); model.setUserCreatedBy(userInfo); dbConnection.save(model); successMap.put("success", "success"); - }else{ + } else { successMap.put("DBError", "EXISTS"); logger.error("Import new service failed. Service already exists"); } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java index e6e843217..5e2bb58ff 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java @@ -455,7 +455,7 @@ public class DecisionPolicy extends Policy { } private DecisionSettings findDecisionSettingsBySettingId(String settingId) { - return (DecisionSettings) commonClassDao.getEntityItem(DecisionSettings.class, "xacmlId", settingId); + return (DecisionSettings) commonClassDao.getEntityItem(DecisionSettings.class, "xacml_id", settingId); } private void createRule(PolicyType decisionPolicy, boolean permitRule) { @@ -824,7 +824,7 @@ public class DecisionPolicy extends Policy { public String getFunctionDefinitionId(String key) { FunctionDefinition object = - (FunctionDefinition) commonClassDao.getEntityItem(FunctionDefinition.class, "shortname", key); + (FunctionDefinition) commonClassDao.getEntityItem(FunctionDefinition.class, "short_name", key); if (object != null) { return object.getXacmlid(); } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicy.java index db7bbd4be..eca473f41 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/FirewallConfigPolicy.java @@ -3,6 +3,7 @@ * ONAP-PAP-REST * ================================================================================ * Copyright (C) 2017,2019 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2019 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -548,16 +549,7 @@ public class FirewallConfigPolicy extends Policy { value = srcListObj.get("value").toString(); } - if (value!=null){ - value = value.replace("\"", ""); - } - - if (srcListString != null) { - srcListString = srcListString.concat(",").concat(value); - - } else { - srcListString = value; - } + srcListString = getLeftOrRight(srcListString, value); } String srcListInsert = "'"+srcListString+"'"; @@ -578,15 +570,7 @@ public class FirewallConfigPolicy extends Policy { value = destListObj.get("value").toString(); } - if (value!=null){ - value = value.replace("\"", ""); - } - - if (destListString != null) { - destListString = destListString.concat(",").concat(value); - } else { - destListString = value; - } + destListString = getLeftOrRight(destListString, value); } String destListInsert = "'"+destListString+"'"; @@ -606,15 +590,7 @@ public class FirewallConfigPolicy extends Policy { value = destServicesObj.get("value").toString(); } - if (value!=null){ - value = value.replace("\"", ""); - } - - if (destPortListString != null) { - destPortListString = destPortListString.concat(",").concat(value); - } else { - destPortListString = value; - } + destPortListString = getLeftOrRight(destPortListString, value); } String destPortListInsert = "'"+destPortListString+"'"; @@ -640,10 +616,7 @@ public class FirewallConfigPolicy extends Policy { termEntry.setUserCreatedBy(userInfo); dbConnection.save(termEntry); - ActionList actionEntry = new ActionList(); - actionEntry.setActionName(action); - actionEntry.setDescription(action); - dbConnection.save(actionEntry); + saveActionListToDb(dbConnection, action); } } @@ -678,36 +651,7 @@ public class FirewallConfigPolicy extends Policy { //Insert values into GROUPSERVICELIST table if name begins with Group if (isServiceGroup) { - String name = null; - for (int membersIndex = 0; membersIndex< membersArray.size(); membersIndex++) { - JsonObject membersObj = membersArray.getJsonObject(membersIndex); - //String value = membersObj.get("name").toString(); - String type = membersObj.get("type").toString().replace("\"", ""); - - String value = null; - if(type.equals("REFERENCE")||type.equals("GROUP")||type.equals("SERVICE")){ - value = membersObj.get("name").toString(); - } else if (type.equalsIgnoreCase("ANY")){ - value = null; - } else { - value = membersObj.get("value").toString(); - } - - if(value != null){ - value = value.replace("\"", ""); - } - - if (name != null) { - name = name.concat(",").concat(value); - } else { - name = value; - } - } - String nameInsert = "'"+name+"'"; - GroupServiceList groupServiceEntry = new GroupServiceList(); - groupServiceEntry.setGroupName(serviceListName); - groupServiceEntry.setServiceList(nameInsert); - dbConnection.save(groupServiceEntry); + saveGroupServiceListTableToDb(dbConnection, serviceListName, membersArray); } else { //Insert JSON data serviceList table, protollist table, and portlist table String type = svcGroupListobj.get("type").toString(); String transportProtocol = svcGroupListobj.get("transportProtocol").toString(); @@ -716,24 +660,11 @@ public class FirewallConfigPolicy extends Policy { /* * Create Queries to INSERT data into database table and execute */ - ServiceList serviceListEntry = new ServiceList(); - serviceListEntry.setServiceName(serviceListName); - serviceListEntry.setServiceDescription(description); - serviceListEntry.setServiceType(type); - serviceListEntry.setServiceTransProtocol(transportProtocol); - serviceListEntry.setServiceAppProtocol("null"); - serviceListEntry.setServicePorts(ports); - dbConnection.save(serviceListEntry); - - ProtocolList protocolEntry = new ProtocolList(); - protocolEntry.setProtocolName(transportProtocol); - protocolEntry.setDescription(transportProtocol); - dbConnection.save(protocolEntry); - - PortList portListEntry = new PortList(); - portListEntry.setPortName(ports); - portListEntry.setDescription(ports); - dbConnection.save(portListEntry); + saveServiceListToDb(dbConnection, serviceListName, description, type, transportProtocol, ports); + + saveProtocolListToDb(dbConnection, transportProtocol); + + savePortListToDb(dbConnection, ports); } } } @@ -766,68 +697,20 @@ public class FirewallConfigPolicy extends Policy { type = membersObj.get("type").toString().replace("\"", ""); String value = null; - if(type.equals("REFERENCE")||type.equals("GROUP")||type.equals("SERVICE")){ - value = membersObj.get("name").toString(); - } else if (type.equalsIgnoreCase("ANY")){ - value = null; - } else { - value = membersObj.get("value").toString(); - } - - if(value != null){ - value = value.replace("\"", ""); - } - - if (prefixIP != null) { - prefixIP = prefixIP.concat(",").concat(value); - } else { - prefixIP = value; - } + prefixIP = getName(prefixIP, membersObj, type); } String prefixList = "'"+prefixIP+"'"; Boolean isAddressGroup = type.contains("REFERENCE"); if (isAddressGroup) { - AddressGroup addressGroupEntry = new AddressGroup(); - addressGroupEntry.setGroupName(addressGroupName); - addressGroupEntry.setDescription(description); - addressGroupEntry.setServiceList(prefixList); - dbConnection.save(addressGroupEntry); + saveAddressGroupToDb(dbConnection, addressGroupName, description, prefixList); } else { - PrefixList prefixListEntry = new PrefixList(); - prefixListEntry.setPrefixListName(addressGroupName); - prefixListEntry.setDescription(description); - prefixListEntry.setPrefixListValue(prefixList); - dbConnection.save(prefixListEntry); + savePrefixListToDb(dbConnection, addressGroupName, description, prefixList); } } } - - /* - * Remove duplicate values from 'lookup' dictionary tables - */ - //ProtocolList Table - String protoDelete = "DELETE FROM protocollist USING protocollist, protocollist p1 " - + "WHERE protocollist.id > p1.id AND protocollist.protocolname = p1.protocolname;"; - dbConnection.updateQuery(protoDelete); - - //PortList Table - String portListDelete = "DELETE FROM portlist USING portlist, portlist p1 " - + "WHERE portlist.id > p1.id AND portlist.portname = p1.portname; "; - dbConnection.updateQuery(portListDelete); - - //PrefixList Table - String prefixListDelete = "DELETE FROM prefixlist USING prefixlist, prefixlist p1 " - + "WHERE prefixlist.id > p1.id AND prefixlist.pl_name = p1.pl_name AND " - + "prefixlist.pl_value = p1.pl_value AND prefixlist.description = p1.description; "; - dbConnection.updateQuery(prefixListDelete); - - //GroupServiceList - String groupServiceDelete = "DELETE FROM groupservicelist USING groupservicelist, groupservicelist g1 " - + "WHERE groupservicelist.id > g1.id AND groupservicelist.name = g1.name AND " - + "groupservicelist.serviceList = g1.serviceList; "; - dbConnection.updateQuery(groupServiceDelete); + removeDuplicateValuesFromLookup(dbConnection); }catch (Exception e) { PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "FirewallConfigPolicy", "Exception getting Json values"); return false; @@ -840,6 +723,74 @@ public class FirewallConfigPolicy extends Policy { } + /* + * Remove duplicate values from 'lookup' dictionary tables + */ + private void removeDuplicateValuesFromLookup(CommonClassDaoImpl dbConnection) { + String protoDelete = "DELETE FROM protocollist USING protocollist, protocollist p1 " + + "WHERE protocollist.id > p1.id AND protocollist.protocolname = p1.protocolname;"; + dbConnection.updateQuery(protoDelete); + + //PortList Table + String portListDelete = "DELETE FROM portlist USING portlist, portlist p1 " + + "WHERE portlist.id > p1.id AND portlist.portname = p1.portname; "; + dbConnection.updateQuery(portListDelete); + + //PrefixList Table + String prefixListDelete = "DELETE FROM prefixlist USING prefixlist, prefixlist p1 " + + "WHERE prefixlist.id > p1.id AND prefixlist.pl_name = p1.pl_name AND " + + "prefixlist.pl_value = p1.pl_value AND prefixlist.description = p1.description; "; + dbConnection.updateQuery(prefixListDelete); + + //GroupServiceList + String groupServiceDelete = "DELETE FROM groupservicelist USING groupservicelist, groupservicelist g1 " + + "WHERE groupservicelist.id > g1.id AND groupservicelist.name = g1.name AND " + + "groupservicelist.serviceList = g1.serviceList; "; + dbConnection.updateQuery(groupServiceDelete); + } + + private void saveGroupServiceListTableToDb(CommonClassDaoImpl dbConnection, String serviceListName, JsonArray membersArray) { + String name = null; + for (int membersIndex = 0; membersIndex< membersArray.size(); membersIndex++) { + JsonObject membersObj = membersArray.getJsonObject(membersIndex); + String type = membersObj.get("type").toString().replace("\"", ""); + + name = getName(name, membersObj, type); + } + String nameInsert = "'"+name+"'"; + GroupServiceList groupServiceEntry = new GroupServiceList(); + groupServiceEntry.setGroupName(serviceListName); + groupServiceEntry.setServiceList(nameInsert); + dbConnection.save(groupServiceEntry); + } + + private String getName(String name, JsonObject membersObj, String type) { + String value; + if(type.equals("REFERENCE")||type.equals("GROUP")||type.equals("SERVICE")){ + value = membersObj.get("name").toString(); + } else if (type.equalsIgnoreCase("ANY")){ + value = null; + } else { + value = membersObj.get("value").toString(); + } + + name = getLeftOrRight(name, value); + return name; + } + + private String getLeftOrRight(String name, String value) { + if (value != null) { + value = value.replace("\"", ""); + } + + if (name != null) { + name = name.concat(",").concat(value); + } else { + name = value.replace("\"", "");; + } + return name; + } + private Boolean updateFirewallDictionaryData(String jsonBody, String prevJsonBody) { CommonClassDaoImpl dbConnection = new CommonClassDaoImpl(); @@ -950,16 +901,7 @@ public class FirewallConfigPolicy extends Policy { value = srcListObj.get("value").toString(); } - if(value != null){ - value = value.replace("\"", ""); - } - - if (srcListString != null) { - srcListString = srcListString.concat(",").concat(value); - - } else { - srcListString = value; - } + srcListString = getLeftOrRight(srcListString, value); } String srcListInsert = "'"+srcListString+"'"; @@ -980,15 +922,7 @@ public class FirewallConfigPolicy extends Policy { value = destListObj.get("value").toString(); } - if(value != null){ - value = value.replace("\"", ""); - } - - if (destListString != null) { - destListString = destListString.concat(",").concat(value); - } else { - destListString = value; - } + destListString = getLeftOrRight(destListString, value); } String destListInsert = "'"+destListString+"'"; @@ -1008,15 +942,7 @@ public class FirewallConfigPolicy extends Policy { value = destServicesObj.get("value").toString(); } - if(value != null){ - value = value.replace("\"", ""); - } - - if (destPortListString != null) { - destPortListString = destPortListString.concat(",").concat(value); - } else { - destPortListString = value; - } + destPortListString = getLeftOrRight(destPortListString, value); } String destPortListInsert = "'"+destPortListString+"'"; @@ -1044,10 +970,7 @@ public class FirewallConfigPolicy extends Policy { List<Object> actionResult = dbConnection.getDataById(ActionList.class, "actionName", action); if(actionResult == null || actionResult.isEmpty()){ - ActionList actionEntry = new ActionList(); - actionEntry.setActionName(action); - actionEntry.setDescription(action); - dbConnection.save(actionEntry); + saveActionListToDb(dbConnection, action); } } } @@ -1088,35 +1011,7 @@ public class FirewallConfigPolicy extends Policy { dbConnection.delete(groupEntry); } - String name = null; - for (int membersIndex = 0; membersIndex < membersArray.size(); membersIndex++) { - JsonObject membersObj = membersArray.getJsonObject(membersIndex); - String type = membersObj.get("type").toString().replace("\"", ""); - - String value = null; - if(type.equals("REFERENCE")||type.equals("GROUP")||type.equals("SERVICE")){ - value = membersObj.get("name").toString(); - } else if (type.equalsIgnoreCase("ANY")){ - value = null; - } else { - value = membersObj.get("value").toString(); - } - - if(value != null){ - value = value.replace("\"", ""); - } - - if (name != null) { - name = name.concat(",").concat(value); - } else { - name = value; - } - } - String nameInsert = "'"+name+"'"; - GroupServiceList groupServiceEntry = new GroupServiceList(); - groupServiceEntry.setGroupName(groupName); - groupServiceEntry.setServiceList(nameInsert); - dbConnection.save(groupServiceEntry); + saveGroupServiceListTableToDb(dbConnection, groupName, membersArray); } else { //Insert JSON data serviceGroup table, protocollist table, and portlist table String type = svcGroupListobj.get("type").toString().replace('"', '\''); String transportProtocol = svcGroupListobj.get("transportProtocol").toString().replace('"', '\''); @@ -1128,29 +1023,16 @@ public class FirewallConfigPolicy extends Policy { dbConnection.delete(serviceEntry); } - ServiceList serviceListEntry = new ServiceList(); - serviceListEntry.setServiceName(groupName); - serviceListEntry.setServiceDescription(description); - serviceListEntry.setServiceType(type); - serviceListEntry.setServiceTransProtocol(transportProtocol); - serviceListEntry.setServiceAppProtocol("null"); - serviceListEntry.setServicePorts(ports); - dbConnection.save(serviceListEntry); + saveServiceListToDb(dbConnection, groupName, description, type, transportProtocol, ports); List<Object> protocolResult = dbConnection.getDataById(ProtocolList.class, "protocolName", transportProtocol); if(protocolResult == null || protocolResult.isEmpty()){ - ProtocolList protocolEntry = new ProtocolList(); - protocolEntry.setProtocolName(transportProtocol); - protocolEntry.setDescription(transportProtocol); - dbConnection.save(protocolEntry); + saveProtocolListToDb(dbConnection, transportProtocol); } List<Object> portResult = dbConnection.getDataById(PortList.class, "portName", ports); if(portResult == null || portResult.isEmpty()){ - PortList portEntry = new PortList(); - portEntry.setPortName(ports); - portEntry.setDescription(ports); - dbConnection.save(portEntry); + savePortListToDb(dbConnection, ports); } } } @@ -1184,23 +1066,7 @@ public class FirewallConfigPolicy extends Policy { type = membersObj.get("type").toString().replace("\"", ""); String value = null; - if(type.equals("REFERENCE")||type.equals("GROUP")||type.equals("SERVICE")){ - value = membersObj.get("name").toString(); - } else if (type.equalsIgnoreCase("ANY")){ - value = null; - } else { - value = membersObj.get("value").toString(); - } - - if(value != null){ - value = value.replace("\"", ""); - } - - if (prefixIP != null) { - prefixIP = prefixIP.concat(",").concat(value); - } else { - prefixIP = value; - } + prefixIP = getName(prefixIP, membersObj, type); } String prefixList = "'"+prefixIP+"'"; @@ -1212,51 +1078,19 @@ public class FirewallConfigPolicy extends Policy { AddressGroup addressGroupEntry = (AddressGroup) result.get(0); dbConnection.delete(addressGroupEntry); } - AddressGroup newAddressGroup = new AddressGroup(); - newAddressGroup.setGroupName(addressGroupName); - newAddressGroup.setDescription(description); - newAddressGroup.setServiceList(prefixList); - dbConnection.save(newAddressGroup); + saveAddressGroupToDb(dbConnection, addressGroupName, description, prefixList); } else { List<Object> result = dbConnection.getDataById(PrefixList.class, "prefixListName", addressGroupName); if(result != null && !result.isEmpty()){ PrefixList prefixListEntry = (PrefixList) result.get(0); dbConnection.delete(prefixListEntry); } - PrefixList newPrefixList = new PrefixList(); - newPrefixList.setPrefixListName(addressGroupName); - newPrefixList.setDescription(description); - newPrefixList.setPrefixListValue(prefixList); - dbConnection.save(newPrefixList); + savePrefixListToDb(dbConnection, addressGroupName, description, prefixList); } } } } - - /* - * Remove duplicate values from 'lookup' dictionary tables - */ - //ProtocolList Table - String protoDelete = "DELETE FROM protocollist USING protocollist, protocollist p1 " - + "WHERE protocollist.id > p1.id AND protocollist.protocolname = p1.protocolname;"; - dbConnection.updateQuery(protoDelete); - - //PortList Table - String portListDelete = "DELETE FROM portlist USING portlist, portlist p1 " - + "WHERE portlist.id > p1.id AND portlist.portname = p1.portname; "; - dbConnection.updateQuery(portListDelete); - - //PrefixList Table - String prefixListDelete = "DELETE FROM prefixlist USING prefixlist, prefixlist p1 " - + "WHERE prefixlist.id > p1.id AND prefixlist.pl_name = p1.pl_name AND " - + "prefixlist.pl_value = p1.pl_value AND prefixlist.description = p1.description; "; - dbConnection.updateQuery(prefixListDelete); - - //GroupServiceList - String groupServiceDelete = "DELETE FROM groupservicelist USING groupservicelist, groupservicelist g1 " - + "WHERE groupservicelist.id > g1.id AND groupservicelist.name = g1.name AND " - + "groupservicelist.serviceList = g1.serviceList; "; - dbConnection.updateQuery(groupServiceDelete); + removeDuplicateValuesFromLookup(dbConnection); }catch (Exception e) { PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "FirewallConfigPolicy", "Exception executing Firewall queries"); return false; @@ -1268,6 +1102,54 @@ public class FirewallConfigPolicy extends Policy { } + private void saveActionListToDb(CommonClassDaoImpl dbConnection, String action) { + ActionList actionEntry = new ActionList(); + actionEntry.setActionName(action); + actionEntry.setDescription(action); + dbConnection.save(actionEntry); + } + + private void savePortListToDb(CommonClassDaoImpl dbConnection, String ports) { + PortList portEntry = new PortList(); + portEntry.setPortName(ports); + portEntry.setDescription(ports); + dbConnection.save(portEntry); + } + + private void saveProtocolListToDb(CommonClassDaoImpl dbConnection, String transportProtocol) { + ProtocolList protocolEntry = new ProtocolList(); + protocolEntry.setProtocolName(transportProtocol); + protocolEntry.setDescription(transportProtocol); + dbConnection.save(protocolEntry); + } + + private void saveServiceListToDb(CommonClassDaoImpl dbConnection, String groupName, String description, String type, String transportProtocol, String ports) { + ServiceList serviceListEntry = new ServiceList(); + serviceListEntry.setServiceName(groupName); + serviceListEntry.setServiceDescription(description); + serviceListEntry.setServiceType(type); + serviceListEntry.setServiceTransProtocol(transportProtocol); + serviceListEntry.setServiceAppProtocol("null"); + serviceListEntry.setServicePorts(ports); + dbConnection.save(serviceListEntry); + } + + private void savePrefixListToDb(CommonClassDaoImpl dbConnection, String addressGroupName, String description, String prefixList) { + PrefixList newPrefixList = new PrefixList(); + newPrefixList.setPrefixListName(addressGroupName); + newPrefixList.setDescription(description); + newPrefixList.setPrefixListValue(prefixList); + dbConnection.save(newPrefixList); + } + + private void saveAddressGroupToDb(CommonClassDaoImpl dbConnection, String addressGroupName, String description, String prefixList) { + AddressGroup newAddressGroup = new AddressGroup(); + newAddressGroup.setGroupName(addressGroupName); + newAddressGroup.setDescription(description); + newAddressGroup.setServiceList(prefixList); + dbConnection.save(newAddressGroup); + } + private JsonObject stringToJson(String jsonString) { //Read jsonBody to JsonObject StringReader in = new StringReader(jsonString); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java index 1f1eca5bd..ee274d2a7 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,10 @@ package org.onap.policy.pap.xacml.rest.controller; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -28,10 +32,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.apache.commons.lang.StringUtils; import org.json.JSONObject; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -41,6 +43,7 @@ import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.pap.xacml.rest.util.JsonMessage; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.DCAEuuid; +import org.onap.policy.rest.jpa.DictionaryData; import org.onap.policy.rest.jpa.MicroServiceAttribute; import org.onap.policy.rest.jpa.MicroServiceConfigName; import org.onap.policy.rest.jpa.MicroServiceLocation; @@ -57,27 +60,22 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; - @Controller public class MicroServiceDictionaryController { - private static final Logger LOGGER = FlexLogger.getLogger(MicroServiceDictionaryController.class); + private static final Logger LOGGER = FlexLogger.getLogger(MicroServiceDictionaryController.class); private static CommonClassDao commonClassDao; - private static String successMapKey= "successMapKey"; + private static String successMapKey = "successMapKey"; private static String successMsg = "success"; private static String operation = "operation"; private static String getDictionary = "getDictionary"; private static String errorMsg = "error"; private static String dictionaryDBQuery = "dictionaryDBQuery"; - private LinkedHashMap<String,MSAttributeObject > classMap; + private LinkedHashMap<String, MSAttributeObject> classMap; private List<String> modelList = new ArrayList<>(); private static String apiflag = "apiflag"; - private static String dictionaryFields ="dictionaryFields"; + private static String dictionaryFields = "dictionaryFields"; private static String update = "update"; private static String duplicateResponseString = "Duplicate"; private static String microServiceModelsDictionaryDatas = "microServiceModelsDictionaryDatas"; @@ -91,19 +89,21 @@ public class MicroServiceDictionaryController { private static String microServiceLocationDatas = "microServiceLocationDictionaryDatas"; private static String microServiceAttributeDatas = "microServiceAttributeDictionaryDatas"; private static String microServiceHeaderDefaultDatas = "microServiceHeaderDefaultDatas"; + private static final String MICROSERVICEDICTNAMEDATAS = "microServiceDictionaryDatas"; - public MicroServiceDictionaryController(){ + public MicroServiceDictionaryController() { super(); - } + } - private DictionaryUtils getDictionaryUtilsInstance(){ + private DictionaryUtils getDictionaryUtilsInstance() { return DictionaryUtils.getDictionaryUtils(); } - + @Autowired - public MicroServiceDictionaryController(CommonClassDao commonClassDao){ + public MicroServiceDictionaryController(CommonClassDao commonClassDao) { MicroServiceDictionaryController.commonClassDao = commonClassDao; } + public static void setCommonClassDao(CommonClassDao commonClassDao) { MicroServiceDictionaryController.commonClassDao = commonClassDao; } @@ -112,20 +112,23 @@ public class MicroServiceDictionaryController { private MicroServiceModels newModel; - @RequestMapping(value={"/get_DCAEUUIDDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getDCAEUUIDDictionaryByNameEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_DCAEUUIDDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getDCAEUUIDDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, dcaeUUIDDatas, "name", DCAEuuid.class); } - @RequestMapping(value={"/get_DCAEUUIDData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getDCAEUUIDDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_DCAEUUIDData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getDCAEUUIDDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, dcaeUUIDDatas, DCAEuuid.class); } - @RequestMapping(value={"/ms_dictionary/save_dcaeUUID"}, method={RequestMethod.POST}) - public ModelAndView saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + @RequestMapping(value = {"/ms_dictionary/save_dcaeUUID"}, method = {RequestMethod.POST}) + public ModelAndView saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); @@ -133,65 +136,143 @@ public class MicroServiceDictionaryController { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); DCAEuuid dCAEuuid; - if(fromAPI){ + if (fromAPI) { dCAEuuid = mapper.readValue(root.get(dictionaryFields).toString(), DCAEuuid.class); - }else{ + } else { dCAEuuid = mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DCAEuuid.class); } - - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class); + + List<Object> duplicateData = commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { DCAEuuid data = (DCAEuuid) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { dCAEuuid.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != dCAEuuid.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null && (data.getId() != dCAEuuid.getId()))) { duplicateflag = true; } } String responseString = null; - if(!duplicateflag){ - if(dCAEuuid.getId() == 0){ + if (!duplicateflag) { + if (dCAEuuid.getId() == 0) { commonClassDao.save(dCAEuuid); - }else{ + } else { commonClassDao.update(dCAEuuid); } responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, dcaeUUIDDatas, responseString); } - }catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - @RequestMapping(value={"/ms_dictionary/remove_dcaeuuid"}, method={RequestMethod.POST}) + @RequestMapping(value = {"/ms_dictionary/remove_dcaeuuid"}, method = {RequestMethod.POST}) public void removeDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, dcaeUUIDDatas, DCAEuuid.class); } - @RequestMapping(value={"/get_MicroServiceConfigNameDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceConfigNameDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, microServiceConfigNameDatas, "name", MicroServiceConfigName.class); } - @RequestMapping(value={"/get_MicroServiceConfigNameData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceConfigNameDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceConfigNameData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceConfigNameDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, microServiceConfigNameDatas, MicroServiceConfigName.class); } - @RequestMapping(value={"/ms_dictionary/save_configName"}, method={RequestMethod.POST}) - public ModelAndView saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + @RequestMapping(value = {"/get_MicroServiceDictData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceDictNameDictionaryEntityData(HttpServletResponse response) { + DictionaryUtils utils = getDictionaryUtilsInstance(); + utils.getData(response, MICROSERVICEDICTNAMEDATAS, DictionaryData.class); + } + + /** + * Save dictionary data. + * + * @param request the request + * @param response the response + * @return the model and view + * @throws IOException Signals that an I/O exception has occurred. + */ + // save_DictionaryData + @RequestMapping(value = {"/ms_dictionary/save_DictionaryData"}, method = {RequestMethod.POST}) + public ModelAndView saveDictionaryData(HttpServletRequest request, HttpServletResponse response) + throws IOException { + DictionaryUtils dictUtil = getDictionaryUtilsInstance(); + try { + boolean fromApi = dictUtil.isRequestFromAPI(request); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + JsonNode root = mapper.readTree(request.getReader()); + DictionaryData dictionaryData; + if (fromApi) { + dictionaryData = mapper.readValue(root.get(dictionaryFields).toString(), DictionaryData.class); + } else { + dictionaryData = mapper.readValue(root.get(MICROSERVICEDICTNAMEDATAS).toString(), DictionaryData.class); + } + List<Object> duplicateData = commonClassDao.checkDuplicateEntry(dictionaryData.getDictionaryName(), + "dictionaryName", DictionaryData.class); + boolean duplicateflag = false; + if (duplicateData != null && !duplicateData.isEmpty()) { + DictionaryData data = (DictionaryData) duplicateData.get(0); + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { + dictionaryData.setId(data.getId()); + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null && (data.getId() != dictionaryData.getId()))) { + duplicateflag = true; + } + } + String responseString = null; + if (!duplicateflag) { + if (dictionaryData.getId() == 0) { + commonClassDao.save(dictionaryData); + } else { + commonClassDao.update(dictionaryData); + } + responseString = mapper.writeValueAsString(commonClassDao.getData(DictionaryData.class)); + } else { + responseString = duplicateResponseString; + } + if (fromApi) { + return dictUtil.getResultForApi(responseString); + } else { + dictUtil.setResponseData(response, MICROSERVICEDICTNAMEDATAS, responseString); + } + } catch (Exception e) { + dictUtil.setErrorResponseData(response, e); + } + return null; + } + + @RequestMapping(value = {"/ms_dictionary/remove_msDictionaryData"}, method = {RequestMethod.POST}) + public void removeMicroServiceDictionaryData(HttpServletRequest request, HttpServletResponse response) + throws IOException { + DictionaryUtils utils = getDictionaryUtilsInstance(); + utils.removeData(request, response, MICROSERVICEDICTNAMEDATAS, DictionaryData.class); + } + + // + @RequestMapping(value = {"/ms_dictionary/save_configName"}, method = {RequestMethod.POST}) + public ModelAndView saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); @@ -199,64 +280,73 @@ public class MicroServiceDictionaryController { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); MicroServiceConfigName microServiceConfigName; - if(fromAPI){ - microServiceConfigName = mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceConfigName.class); - }else{ - microServiceConfigName = mapper.readValue(root.get("microServiceConfigNameDictionaryData").toString(), MicroServiceConfigName.class); + if (fromAPI) { + microServiceConfigName = + mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceConfigName.class); + } else { + microServiceConfigName = mapper.readValue(root.get("microServiceConfigNameDictionaryData").toString(), + MicroServiceConfigName.class); } - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class); + List<Object> duplicateData = commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", + MicroServiceConfigName.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { MicroServiceConfigName data = (MicroServiceConfigName) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { microServiceConfigName.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != microServiceConfigName.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null + && (data.getId() != microServiceConfigName.getId()))) { duplicateflag = true; } } String responseString = null; - if(!duplicateflag){ - if(microServiceConfigName.getId() == 0){ + if (!duplicateflag) { + if (microServiceConfigName.getId() == 0) { commonClassDao.save(microServiceConfigName); - }else{ + } else { commonClassDao.update(microServiceConfigName); } responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, microServiceConfigNameDatas, responseString); } - }catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - @RequestMapping(value={"/ms_dictionary/remove_msConfigName"}, method={RequestMethod.POST}) - public void removeMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { + @RequestMapping(value = {"/ms_dictionary/remove_msConfigName"}, method = {RequestMethod.POST}) + public void removeMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, microServiceConfigNameDatas, MicroServiceConfigName.class); } - @RequestMapping(value={"/get_MicroServiceLocationDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceLocationDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, microServiceLocationDatas, "name", MicroServiceLocation.class); } - @RequestMapping(value={"/get_MicroServiceLocationData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceLocationDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceLocationData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceLocationDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, microServiceLocationDatas, MicroServiceLocation.class); } - @RequestMapping(value={"/ms_dictionary/save_location"}, method={RequestMethod.POST}) - public ModelAndView saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response)throws IOException{ + @RequestMapping(value = {"/ms_dictionary/save_location"}, method = {RequestMethod.POST}) + public ModelAndView saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); @@ -264,207 +354,227 @@ public class MicroServiceDictionaryController { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); MicroServiceLocation microServiceLocation; - if(fromAPI){ - microServiceLocation = mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceLocation.class); - }else{ - microServiceLocation = mapper.readValue(root.get("microServiceLocationDictionaryData").toString(), MicroServiceLocation.class); + if (fromAPI) { + microServiceLocation = + mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceLocation.class); + } else { + microServiceLocation = mapper.readValue(root.get("microServiceLocationDictionaryData").toString(), + MicroServiceLocation.class); } - - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class); + + List<Object> duplicateData = commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", + MicroServiceLocation.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { MicroServiceLocation data = (MicroServiceLocation) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { microServiceLocation.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != microServiceLocation.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null + && (data.getId() != microServiceLocation.getId()))) { duplicateflag = true; } } String responseString = null; - if(!duplicateflag){ - if(microServiceLocation.getId() == 0){ + if (!duplicateflag) { + if (microServiceLocation.getId() == 0) { commonClassDao.save(microServiceLocation); - }else{ + } else { commonClassDao.update(microServiceLocation); } responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, microServiceLocationDatas, responseString); } - }catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - @RequestMapping(value={"/ms_dictionary/remove_msLocation"}, method={RequestMethod.POST}) - public void removeMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { + @RequestMapping(value = {"/ms_dictionary/remove_msLocation"}, method = {RequestMethod.POST}) + public void removeMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, microServiceLocationDatas, MicroServiceLocation.class); } - @RequestMapping(value={"/get_MicroServiceAttributeDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceAttributeDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, microServiceAttributeDatas, "name", MicroServiceAttribute.class); } - - @RequestMapping(value={"/get_MicroServiceAttributeData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceAttributeDictionaryEntityData(HttpServletResponse response){ + + @RequestMapping(value = {"/get_MicroServiceAttributeData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceAttributeDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, microServiceAttributeDatas, MicroServiceAttribute.class); } - - @RequestMapping(value={"/ms_dictionary/save_modelAttribute"}, method={RequestMethod.POST}) - public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + @RequestMapping(value = {"/ms_dictionary/save_modelAttribute"}, method = {RequestMethod.POST}) + public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - + MicroServiceAttribute microServiceAttribute; String checkValue; if (fromAPI) { - microServiceAttribute = mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceAttribute.class); + microServiceAttribute = + mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceAttribute.class); } else { - microServiceAttribute = mapper.readValue(root.get("modelAttributeDictionaryData").toString(), MicroServiceAttribute.class); + microServiceAttribute = mapper.readValue(root.get("modelAttributeDictionaryData").toString(), + MicroServiceAttribute.class); } - checkValue = microServiceAttribute.getName() + ":" + microServiceAttribute.getValue() + ":" + microServiceAttribute.getModelName(); - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class); + checkValue = microServiceAttribute.getName() + ":" + microServiceAttribute.getValue() + ":" + + microServiceAttribute.getModelName(); + List<Object> duplicateData = + commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { MicroServiceAttribute data = (MicroServiceAttribute) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { microServiceAttribute.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != microServiceAttribute.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null + && (data.getId() != microServiceAttribute.getId()))) { duplicateflag = true; } } String responseString = null; - if(!duplicateflag){ - if(microServiceAttribute.getId() == 0){ + if (!duplicateflag) { + if (microServiceAttribute.getId() == 0) { commonClassDao.save(microServiceAttribute); - }else{ + } else { commonClassDao.update(microServiceAttribute); } responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, microServiceAttributeDatas, responseString); } - } - catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - - @RequestMapping(value={"/ms_dictionary/remove_modelAttribute"}, method={RequestMethod.POST}) - public void removeMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + @RequestMapping(value = {"/ms_dictionary/remove_modelAttribute"}, method = {RequestMethod.POST}) + public void removeMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, microServiceAttributeDatas, MicroServiceAttribute.class); } - - @RequestMapping(value={"/get_MicroServiceModelsDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletResponse response){ + + @RequestMapping(value = {"/get_MicroServiceModelsDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, microServiceModelsDictionaryDatas, modelName, MicroServiceModels.class); } - @RequestMapping(value={"/get_MicroServiceModelsDataByVersion"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceModelsDictionaryByVersionEntityData(HttpServletRequest request, HttpServletResponse response){ - try{ + @RequestMapping(value = {"/get_MicroServiceModelsDataByVersion"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceModelsDictionaryByVersionEntityData(HttpServletRequest request, + HttpServletResponse response) { + try { Map<String, Object> model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readTree(request.getReader()); String modelName = null; - if (root.get(microServiceModelsDictionaryData).has(modelName)){ + if (root.get(microServiceModelsDictionaryData).has(modelName)) { modelName = root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", ""); } - if (modelName!=null){ - model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(commonClassDao.getDataById(MicroServiceModels.class, modelName, modelName))); - } else{ - model.put(errorMsg, "No model name given"); - } + if (modelName != null) { + model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString( + commonClassDao.getDataById(MicroServiceModels.class, modelName, modelName))); + } else { + model.put(errorMsg, "No model name given"); + } JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); response.getWriter().write(j.toString()); - } - catch (Exception e){ + } catch (Exception e) { LOGGER.error(e); } } - - @RequestMapping(value={"/get_MicroServiceModelsData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceModelsDictionaryEntityData(HttpServletResponse response){ + + @RequestMapping(value = {"/get_MicroServiceModelsData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceModelsDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, microServiceModelsDictionaryDatas, MicroServiceModels.class); } - @RequestMapping(value={"/get_MicroServiceModelsDataServiceVersion"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletResponse response){ - try{ + @RequestMapping(value = {"/get_MicroServiceModelsDataServiceVersion"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletResponse response) { + try { Map<String, Object> model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); List<String> data = new ArrayList<>(); List<Object> datas = commonClassDao.getData(MicroServiceModels.class); - for(int i = 0; i < datas.size(); i++){ + for (int i = 0; i < datas.size(); i++) { MicroServiceModels msmodel = (MicroServiceModels) datas.get(i); - if (!data.contains(msmodel.getModelName())){ + if (!data.contains(msmodel.getModelName())) { data.add(msmodel.getModelName() + "-v" + msmodel.getVersion()); } } model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(data)); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); - response.addHeader("successMapKey", "success"); + response.addHeader("successMapKey", "success"); response.addHeader("operation", "getDictionary"); response.getWriter().write(j.toString()); - - } - catch (Exception e){ - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.addHeader("error", "dictionaryDBQuery"); LOGGER.error(e); } } - - @RequestMapping(value={"/get_MicroServiceModelsDataByClass"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceModelsDictionaryClassEntityData(HttpServletResponse response){ - try{ + + @RequestMapping(value = {"/get_MicroServiceModelsDataByClass"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceModelsDictionaryClassEntityData(HttpServletResponse response) { + try { Map<String, Object> model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("microServiceModelsDictionaryClassDatas", mapper.writeValueAsString(modelList)); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); - response.addHeader(successMapKey, successMsg); + response.addHeader(successMapKey, successMsg); response.addHeader(operation, getDictionary); response.getWriter().write(j.toString()); - - } - catch (Exception e){ - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.addHeader(errorMsg, dictionaryDBQuery); LOGGER.error(e); } } - - @RequestMapping(value={"/ms_dictionary/save_model"}, method={RequestMethod.POST}) - public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + @RequestMapping(value = {"/ms_dictionary/save_model"}, method = {RequestMethod.POST}) + public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { this.newModel = new MicroServiceModels(); @@ -476,24 +586,27 @@ public class MicroServiceDictionaryController { String userId = null; String dataOrderInfo = null; - if(root.has("dataOrderInfo")){ + if (root.has("dataOrderInfo")) { dataOrderInfo = root.get("dataOrderInfo").toString(); } - if(root.has("modelType")){ + if (root.has("modelType")) { JsonNode dataType = root.get("modelType"); - String modelType= dataType.toString(); - if(modelType.contains("yml")){ - if (root.has(microServiceModelsDictionaryData)){ - if (root.get(microServiceModelsDictionaryData).has(description)){ - microServiceModels.setDescription(root.get(microServiceModelsDictionaryData).get(description).asText().replace("\"", "")); + String modelType = dataType.toString(); + if (modelType.contains("yml")) { + if (root.has(microServiceModelsDictionaryData)) { + if (root.get(microServiceModelsDictionaryData).has(description)) { + microServiceModels.setDescription(root.get(microServiceModelsDictionaryData) + .get(description).asText().replace("\"", "")); } - if (root.get(microServiceModelsDictionaryData).has(modelName)){ - microServiceModels.setModelName(root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", "")); + if (root.get(microServiceModelsDictionaryData).has(modelName)) { + microServiceModels.setModelName(root.get(microServiceModelsDictionaryData).get(modelName) + .asText().replace("\"", "")); this.newModel.setModelName(microServiceModels.getModelName()); } - if (root.get(microServiceModelsDictionaryData).has(version)){ - microServiceModels.setVersion(root.get(microServiceModelsDictionaryData).get(version).asText().replace("\"", "")); + if (root.get(microServiceModelsDictionaryData).has(version)) { + microServiceModels.setVersion( + root.get(microServiceModelsDictionaryData).get(version).asText().replace("\"", "")); this.newModel.setVersion(microServiceModels.getVersion()); } } @@ -501,13 +614,13 @@ public class MicroServiceDictionaryController { classMap = new LinkedHashMap<>(); JsonNode data = root.get(classMapData); ObjectMapper mapper1 = new ObjectMapper(); - String data1 = data.toString().substring(1, data.toString().length()-1); + String data1 = data.toString().substring(1, data.toString().length() - 1); data1 = data1.replace("\\", ""); - data1=data1.replace("\"{","{"); - data1=data1.replace("}\"","}"); + data1 = data1.replace("\"{", "{"); + data1 = data1.replace("}\"", "}"); JSONObject jsonObject = new JSONObject(data1); Set<String> keys = jsonObject.keySet(); - for(String key : keys){ + for (String key : keys) { String value = jsonObject.get(key).toString(); MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class); classMap.put(key, msAttributeObject); @@ -518,44 +631,49 @@ public class MicroServiceDictionaryController { this.newModel.setDependency("[]"); String value = new Gson().toJson(mainClass.getSubClass()); this.newModel.setSub_attributes(value); - String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", ""); - int equalsIndexForAttributes= attributes.indexOf('='); - String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1); + String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", ""); + int equalsIndexForAttributes = attributes.indexOf('='); + String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1); this.newModel.setAttributes(atttributesAfterFirstEquals); - String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); - int equalsIndex= refAttributes.indexOf("="); - String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1); + String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""); + int equalsIndex = refAttributes.indexOf("="); + String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1); this.newModel.setRef_attributes(refAttributesAfterFirstEquals); this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", "")); - this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); + this.newModel + .setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", "")); - }else{ + } else { if (fromAPI) { - microServiceModels = mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceModels.class); + microServiceModels = + mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceModels.class); userId = "API"; } else { - if (root.has(microServiceModelsDictionaryData)){ - if (root.get(microServiceModelsDictionaryData).has(description)){ - microServiceModels.setDescription(root.get(microServiceModelsDictionaryData).get(description).asText().replace("\"", "")); + if (root.has(microServiceModelsDictionaryData)) { + if (root.get(microServiceModelsDictionaryData).has(description)) { + microServiceModels.setDescription(root.get(microServiceModelsDictionaryData) + .get(description).asText().replace("\"", "")); } - if (root.get(microServiceModelsDictionaryData).has(modelName)){ - microServiceModels.setModelName(root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", "")); + if (root.get(microServiceModelsDictionaryData).has(modelName)) { + microServiceModels.setModelName(root.get(microServiceModelsDictionaryData) + .get(modelName).asText().replace("\"", "")); this.newModel.setModelName(microServiceModels.getModelName()); } - if (root.get(microServiceModelsDictionaryData).has(version)){ - microServiceModels.setVersion(root.get(microServiceModelsDictionaryData).get(version).asText().replace("\"", "")); + if (root.get(microServiceModelsDictionaryData).has(version)) { + microServiceModels.setVersion(root.get(microServiceModelsDictionaryData).get(version) + .asText().replace("\"", "")); this.newModel.setVersion(microServiceModels.getVersion()); } } - if(root.has(classMapData)){ + if (root.has(classMapData)) { classMap = new LinkedHashMap<>(); JsonNode data = root.get(classMapData); ObjectMapper mapper1 = new ObjectMapper(); - String data1 = data.toString().substring(1, data.toString().length()-1); + String data1 = data.toString().substring(1, data.toString().length() - 1); data1 = data1.replace("\\", ""); JSONObject jsonObject = new JSONObject(data1); Set<String> keys = jsonObject.keySet(); - for(String key : keys){ + for (String key : keys) { String value = jsonObject.get(key).toString(); MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class); classMap.put(key, msAttributeObject); @@ -574,79 +692,83 @@ public class MicroServiceDictionaryController { microServiceModels.setVersion(this.newModel.getVersion()); microServiceModels.setEnumValues(this.newModel.getEnumValues()); microServiceModels.setAnnotation(this.newModel.getAnnotation()); - if(dataOrderInfo != null){ - microServiceModels.setDataOrderInfo(dataOrderInfo); + if (dataOrderInfo != null) { + microServiceModels.setDataOrderInfo(dataOrderInfo); } String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion(); - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class); + List<Object> duplicateData = + commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { MicroServiceModels data = (MicroServiceModels) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { microServiceModels.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != microServiceModels.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null && (data.getId() != microServiceModels.getId()))) { duplicateflag = true; } } UserInfo userInfo = utils.getUserInfo(userId); String responseString = null; - if(!duplicateflag){ + if (!duplicateflag) { microServiceModels.setUserCreatedBy(userInfo); - if(microServiceModels.getId() == 0){ + if (microServiceModels.getId() == 0) { commonClassDao.save(microServiceModels); - }else{ + } else { commonClassDao.update(microServiceModels); } responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, microServiceModelsDictionaryDatas, responseString); } - }catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - @RequestMapping(value={"/ms_dictionary/remove_msModel"}, method={RequestMethod.POST}) - public void removeMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { + @RequestMapping(value = {"/ms_dictionary/remove_msModel"}, method = {RequestMethod.POST}) + public void removeMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, microServiceModelsDictionaryDatas, MicroServiceModels.class); } - private void addValuesToNewModel(HashMap<String,MSAttributeObject > classMap) { - //Loop through the classmap and pull out the required info for the new file. + private void addValuesToNewModel(HashMap<String, MSAttributeObject> classMap) { + // Loop through the classmap and pull out the required info for the new file. String subAttribute = null; MSAttributeObject mainClass = classMap.get(this.newModel.getModelName()); - if (mainClass !=null){ - String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""}); + if (mainClass != null) { + String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "}, + new String[] {"", "", ""}); ArrayList<String> dependency = new ArrayList<>(Arrays.asList(dependTemp.split(","))); dependency = getFullDependencyList(dependency); - for (String element : dependency){ + for (String element : dependency) { MSAttributeObject temp = classMap.get(element); - if (temp!=null){ + if (temp != null) { mainClass.addAllRefAttribute(temp.getRefAttribute()); mainClass.addAllAttribute(temp.getAttribute()); } } subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName()); - }else{ + } else { subAttribute = "{}"; this.newModel.setDependency(""); } - if (mainClass != null && mainClass.getDependency()==null){ + if (mainClass != null && mainClass.getDependency() == null) { mainClass.setDependency(""); } - if(mainClass != null){ + if (mainClass != null) { this.newModel.setDependency(mainClass.getDependency()); this.newModel.setSub_attributes(subAttribute); this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", "")); @@ -660,15 +782,16 @@ public class MicroServiceDictionaryController { ArrayList<String> returnList = new ArrayList<>(); ArrayList<String> workingList = new ArrayList<>(); returnList.addAll(dependency); - for (String element : dependency ){ - if (classMap.containsKey(element)){ + for (String element : dependency) { + if (classMap.containsKey(element)) { MSAttributeObject value = classMap.get(element); - String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""}); + String rawValue = + StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""}); workingList = new ArrayList<>(Arrays.asList(rawValue.split(","))); - for(String depend : workingList){ - if (!returnList.contains(depend) && !depend.isEmpty()){ + for (String depend : workingList) { + if (!returnList.contains(depend) && !depend.isEmpty()) { returnList.add(depend.trim()); - //getFullDepedency(workingList) + // getFullDepedency(workingList) } } } @@ -677,73 +800,80 @@ public class MicroServiceDictionaryController { return returnList; } - @RequestMapping(value={"/get_MicroServiceHeaderDefaultsDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceHeaderDefaultsEntityDataByName(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceHeaderDefaultsDataByName"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceHeaderDefaultsEntityDataByName(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getDataByEntity(response, microServiceHeaderDefaultDatas, "modelName", MicroserviceHeaderdeFaults.class); } - @RequestMapping(value={"/get_MicroServiceHeaderDefaultsData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) - public void getMicroServiceHeaderDefaultsEntityData(HttpServletResponse response){ + @RequestMapping(value = {"/get_MicroServiceHeaderDefaultsData"}, method = {RequestMethod.GET}, + produces = MediaType.APPLICATION_JSON_VALUE) + public void getMicroServiceHeaderDefaultsEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.getData(response, microServiceHeaderDefaultDatas, MicroserviceHeaderdeFaults.class); } - - - @RequestMapping(value={"/ms_dictionary/save_headerDefaults"}, method={RequestMethod.POST}) - public ModelAndView saveMicroServiceHeaderDefaultValues(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + + @RequestMapping(value = {"/ms_dictionary/save_headerDefaults"}, method = {RequestMethod.POST}) + public ModelAndView saveMicroServiceHeaderDefaultValues(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); try { boolean fromAPI = utils.isRequestFromAPI(request); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - + MicroserviceHeaderdeFaults msHeaderdeFaults; - if(fromAPI){ - msHeaderdeFaults = mapper.readValue(root.get(dictionaryFields).toString(), MicroserviceHeaderdeFaults.class); - }else{ - msHeaderdeFaults = mapper.readValue(root.get("modelAttributeDictionaryData").toString(), MicroserviceHeaderdeFaults.class); + if (fromAPI) { + msHeaderdeFaults = + mapper.readValue(root.get(dictionaryFields).toString(), MicroserviceHeaderdeFaults.class); + } else { + msHeaderdeFaults = mapper.readValue(root.get("modelAttributeDictionaryData").toString(), + MicroserviceHeaderdeFaults.class); } - - List<Object> duplicateData = commonClassDao.checkDuplicateEntry(msHeaderdeFaults.getModelName(), "modelName", MicroserviceHeaderdeFaults.class); + + List<Object> duplicateData = commonClassDao.checkDuplicateEntry(msHeaderdeFaults.getModelName(), + "modelName", MicroserviceHeaderdeFaults.class); boolean duplicateflag = false; - if(duplicateData != null && !duplicateData.isEmpty()){ + if (duplicateData != null && !duplicateData.isEmpty()) { MicroserviceHeaderdeFaults data = (MicroserviceHeaderdeFaults) duplicateData.get(0); - if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){ + if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { msHeaderdeFaults.setId(data.getId()); - }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || - (request.getParameter(operation) == null && (data.getId() != msHeaderdeFaults.getId()))){ + } else if ((request.getParameter(operation) != null + && !"update".equals(request.getParameter(operation))) + || (request.getParameter(operation) == null && (data.getId() != msHeaderdeFaults.getId()))) { duplicateflag = true; } } - + String responseString = null; - if(!duplicateflag){ - if(msHeaderdeFaults.getId() == 0){ + if (!duplicateflag) { + if (msHeaderdeFaults.getId() == 0) { commonClassDao.save(msHeaderdeFaults); - }else{ + } else { commonClassDao.update(msHeaderdeFaults); } responseString = mapper.writeValueAsString(commonClassDao.getData(MicroserviceHeaderdeFaults.class)); - }else{ + } else { responseString = duplicateResponseString; } - if(fromAPI){ + if (fromAPI) { return utils.getResultForApi(responseString); - }else{ + } else { utils.setResponseData(response, microServiceHeaderDefaultDatas, responseString); } - } - catch (Exception e){ + } catch (Exception e) { utils.setErrorResponseData(response, e); } return null; } - - @RequestMapping(value={"/ms_dictionary/remove_headerDefaults"}, method={RequestMethod.POST}) - public void removeMicroServiceHeaderDefaults(HttpServletRequest request, HttpServletResponse response) throws IOException{ + + @RequestMapping(value = {"/ms_dictionary/remove_headerDefaults"}, method = {RequestMethod.POST}) + public void removeMicroServiceHeaderDefaults(HttpServletRequest request, HttpServletResponse response) + throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); utils.removeData(request, response, microServiceHeaderDefaultDatas, MicroserviceHeaderdeFaults.class); } -}
\ No newline at end of file +} diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java index ef6092d72..5fc737887 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.pap.xacml.rest.handler; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.pap.xacml.rest.service.DictionaryService; @@ -31,6 +31,7 @@ public class DictionaryHandlerImpl implements DictionaryHandler { /* * Get Equivalent for Dictionary Services. */ + @Override public void doDictionaryAPIGet(HttpServletRequest request, HttpServletResponse response) { String dictionaryType = request.getParameter("dictionaryType"); try { @@ -111,6 +112,9 @@ public class DictionaryHandlerImpl implements DictionaryHandler { case "MicroServiceConfigName": dictionary.getMicroServiceConfigNameDictionary(response); break; + case "MicroServiceDictionaryData": + dictionary.getMicroServiceDictionaryData(response); + break; case "DCAEUUID": dictionary.getDCAEUUIDDictionary(response); break; @@ -159,13 +163,13 @@ public class DictionaryHandlerImpl implements DictionaryHandler { /** * Can be used to extend the services. * <p> - * getflag=true indicates Get Request. - * getflag=false indicates Put Request. + * getflag=true indicates Get Request. getflag=false indicates Put Request. * * @return */ + @Override public String extendedOptions(String dictionaryType, HttpServletRequest request, HttpServletResponse response, - boolean getflag) { + boolean getflag) { // Default code String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Invalid Dictionary in Request."; PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "DictionaryHandler", " Invalid Dictionary in Request."); @@ -175,6 +179,7 @@ public class DictionaryHandlerImpl implements DictionaryHandler { return null; } + @Override public void doDictionaryAPIPut(HttpServletRequest request, HttpServletResponse response) { String result = null; String dictionaryType = request.getParameter("dictionaryType"); @@ -257,6 +262,9 @@ public class DictionaryHandlerImpl implements DictionaryHandler { case "MicroServiceConfigName": result = dictionary.saveMicroServiceConfigNameDictionary(request, response); break; + case "MicroServiceDictionaryData": + dictionary.saveMicroServiceDictionaryData(request, response); + break; case "DCAEUUID": result = dictionary.saveDCAEUUIDDictionary(request, response); break; @@ -305,7 +313,7 @@ public class DictionaryHandlerImpl implements DictionaryHandler { response.addHeader("error", message); return; } - if (result.equalsIgnoreCase("Success")) { + if(("Success").equalsIgnoreCase(result)) { response.setStatus(HttpServletResponse.SC_OK); response.addHeader("successMapKey", "success"); if (operation.equalsIgnoreCase("update")) { @@ -313,10 +321,10 @@ public class DictionaryHandlerImpl implements DictionaryHandler { } else { response.addHeader("operation", "createDictionary"); } - } else if (result.equalsIgnoreCase("Duplicate")) { + } else if (("Duplicate").equalsIgnoreCase(result)) { response.setStatus(HttpServletResponse.SC_CONFLICT); response.addHeader("error", "dictionaryItemExists"); - } else if (result.equalsIgnoreCase("DuplicateGroup")) { + } else if (("DuplicateGroup").equalsIgnoreCase(result)) { response.setStatus(HttpServletResponse.SC_CONFLICT); response.addHeader("error", "duplicateGroup"); } else { diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java index dd24aafc9..2dea96517 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java @@ -38,116 +38,221 @@ import org.springframework.stereotype.Service; import org.springframework.web.servlet.ModelAndView; +// TODO: Auto-generated Javadoc +/** + * The Class DictionaryService. + */ @Service("DictionaryService") public class DictionaryService { + /** + * Save onap dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ /* * Methods that call the controller method directly to Save and Update dictionary data */ - public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryController dictionary = new DictionaryController(); ModelAndView result = dictionary.saveOnapDictionary(request, response); return result.getViewName(); } - public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save attribute dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryController dictionary = new DictionaryController(); ModelAndView result = dictionary.saveAttributeDictionary(request, response); return result.getViewName(); } - public String saveActionPolicyDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save action policy dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { ActionPolicyDictionaryController action = new ActionPolicyDictionaryController(); ModelAndView result = action.saveActionPolicyDictionary(request, response); return result.getViewName(); } - public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save BRMS param dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { BRMSDictionaryController dictionary = new BRMSDictionaryController(); ModelAndView result = dictionary.saveBRMSParamDictionary(request, response); return result.getViewName(); } - public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save VSCL action. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.saveVSCLAction(request, response); return result.getViewName(); } - public String saveVnfType(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save vnf type. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.saveVnfType(request, response); return result.getViewName(); } - public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save PEP options. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.savePEPOptions(request, response); return result.getViewName(); } - public String saveVarbind(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save varbind. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.saveVarbind(request, response); return result.getViewName(); } - public String saveServiceType(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save service type. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.saveServiceType(request, response); return result.getViewName(); } - public String saveSiteType(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save site type. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); ModelAndView result = dictionary.saveSiteType(request, response); return result.getViewName(); } - public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save settings dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); ModelAndView result = dictionary.saveSettingsDictionary(request, response); return result.getViewName(); } - public String saveRainyDayDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save rainy day dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveRainyDayDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); ModelAndView result = dictionary.saveRainyDayDictionary(request, response); return result.getViewName(); } - public String saveDescriptiveDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save descriptive dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController(); ModelAndView result = dictionary.saveDescriptiveDictionary(request, response); return result.getViewName(); } + /** + * Save action list dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -156,30 +261,61 @@ public class DictionaryService { return result.getViewName(); } - public String saveProtocolListDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save protocol list dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveProtocolListDictionary(request, response); return result.getViewName(); } - public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save zone dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveZoneDictionary(request, response); return result.getViewName(); } - public String saveSecurityZoneDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save security zone dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveSecurityZoneDictionary(request, response); return result.getViewName(); } + /** + * Save prefix list dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ public String savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -188,32 +324,63 @@ public class DictionaryService { return result.getViewName(); } - public String saveAddressGroupDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save address group dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveAddressGroupDictionary(request, response); return result.getViewName(); } - public String saveServiceGroupDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save service group dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveServiceGroupDictionary(request, response); return result.getViewName(); } - public String saveServiceListDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save service list dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveServiceListDictionary(request, response); return result.getViewName(); } - public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save term list dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { FirewallDictionaryController dictionary = new FirewallDictionaryController(); ModelAndView result = dictionary.saveTermListDictionary(request, response); @@ -222,62 +389,140 @@ public class DictionaryService { - public String saveMicroServiceLocationDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save micro service location dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); ModelAndView result = dictionary.saveMicroServiceLocationDictionary(request, response); return result.getViewName(); } - public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save micro service config name dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); ModelAndView result = dictionary.saveMicroServiceConfigNameDictionary(request, response); return result.getViewName(); } - public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) + /** + * Save micro service dictionary data. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveMicroServiceDictionaryData(HttpServletRequest request, HttpServletResponse response) throws IOException { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); + ModelAndView result = dictionary.saveDictionaryData(request, response); + return result.getViewName(); + } + + /** + * Save DCAEUUID dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { + + MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); ModelAndView result = dictionary.saveDCAEUUIDDictionary(request, response); return result.getViewName(); } - public String saveMicroServiceModelsDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save micro service models dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); ModelAndView result = dictionary.saveMicroServiceModelsDictionary(request, response); return result.getViewName(); } - public String saveMicroServiceDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save micro service dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); ModelAndView result = dictionary.saveMicroServiceAttributeDictionary(request, response); return result.getViewName(); } - public String saveOptimizationModelsDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save optimization models dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveOptimizationModelsDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { OptimizationDictionaryController dictionary = new OptimizationDictionaryController(); ModelAndView result = dictionary.saveOptimizationModelsDictionary(request, response); return result.getViewName(); } - public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save PS service dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); ModelAndView result = dictionary.savePSServiceDictionary(request, response); return result.getViewName(); } + /** + * Save PS resource dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ public String savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -286,46 +531,90 @@ public class DictionaryService { return result.getViewName(); } - public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save PS type dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); ModelAndView result = dictionary.savePSTypeDictionary(request, response); return result.getViewName(); } - public String savePSClosedLoopDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save PS closed loop dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); ModelAndView result = dictionary.savePSClosedLoopDictionary(request, response); return result.getViewName(); } - public String savePSGroupScopeDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save PS group scope dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); ModelAndView result = dictionary.savePSGroupScopeDictionary(request, response); return result.getViewName(); } - public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) - throws IOException { + /** + * Save risk type dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { SafePolicyController dictionary = new SafePolicyController(); ModelAndView result = dictionary.saveRiskTypeDictionary(request, response); return result.getViewName(); } - public String saveSafePolicyWarningDictionary(HttpServletRequest request, - HttpServletResponse response) throws IOException { + /** + * Save safe policy warning dictionary. + * + * @param request the request + * @param response the response + * @return the string + * @throws IOException Signals that an I/O exception has occurred. + */ + public String saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) + throws IOException { SafePolicyController dictionary = new SafePolicyController(); ModelAndView result = dictionary.saveSafePolicyWarningDictionary(request, response); return result.getViewName(); } + /** + * Gets the onap dictionary. + * + * @param response the response + * @return the onap dictionary + */ /* * Methods that call the controller get methods directly to get dictionary data */ @@ -334,172 +623,387 @@ public class DictionaryService { dictionary.getOnapNameDictionaryEntityData(response); } + /** + * Gets the attribute dictionary. + * + * @param response the response + * @return the attribute dictionary + */ public void getAttributeDictionary(HttpServletResponse response) { DictionaryController dictionary = new DictionaryController(); dictionary.getAttributeDictionaryEntityData(response); } + /** + * Gets the action policy dictionary. + * + * @param response the response + * @return the action policy dictionary + */ public void getActionPolicyDictionary(HttpServletResponse response) { ActionPolicyDictionaryController action = new ActionPolicyDictionaryController(); action.getActionPolicyDictionaryEntityData(response); } + /** + * Gets the BRMS param dictionary. + * + * @param response the response + * @return the BRMS param dictionary + */ public void getBRMSParamDictionary(HttpServletResponse response) { BRMSDictionaryController dictionary = new BRMSDictionaryController(); dictionary.getBRMSParamDictionaryEntityData(response); } + /** + * Gets the VSCL action. + * + * @param response the response + * @return the VSCL action + */ public void getVSCLAction(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getVSCLActionDictionaryEntityData(response); } + /** + * Gets the vnf type. + * + * @param response the response + * @return the vnf type + */ public void getVnfType(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getVNFTypeDictionaryEntityData(response); } + /** + * Gets the PEP options. + * + * @param response the response + * @return the PEP options + */ public void getPEPOptions(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getPEPOptionsDictionaryEntityData(response); } + /** + * Gets the varbind. + * + * @param response the response + * @return the varbind + */ public void getVarbind(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getVarbindDictionaryEntityData(response); } + /** + * Gets the service type. + * + * @param response the response + * @return the service type + */ public void getServiceType(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getClosedLoopServiceDictionaryEntityData(response); } + /** + * Gets the site type. + * + * @param response the response + * @return the site type + */ public void getSiteType(HttpServletResponse response) { ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController(); dictionary.getClosedLoopSiteDictionaryEntityData(response); } + /** + * Gets the settings dictionary. + * + * @param response the response + * @return the settings dictionary + */ public void getSettingsDictionary(HttpServletResponse response) { DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); dictionary.getSettingsDictionaryEntityData(response); } + /** + * Gets the rainy day dictionary. + * + * @param response the response + * @return the rainy day dictionary + */ public void getRainyDayDictionary(HttpServletResponse response) { DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController(); dictionary.getRainyDayDictionaryEntityData(response); } + /** + * Gets the descriptive dictionary. + * + * @param response the response + * @return the descriptive dictionary + */ public void getDescriptiveDictionary(HttpServletResponse response) { DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController(); dictionary.getDescriptiveDictionaryEntityData(response); } + /** + * Gets the action list dictionary. + * + * @param response the response + * @return the action list dictionary + */ public void getActionListDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getActionListDictionaryEntityData(response); } + /** + * Gets the protocol list dictionary. + * + * @param response the response + * @return the protocol list dictionary + */ public void getProtocolListDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getProtocolListDictionaryEntityData(response); } + /** + * Gets the zone dictionary. + * + * @param response the response + * @return the zone dictionary + */ public void getZoneDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getZoneDictionaryEntityData(response); } + /** + * Gets the security zone dictionary. + * + * @param response the response + * @return the security zone dictionary + */ public void getSecurityZoneDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getSecurityZoneDictionaryEntityData(response); } + /** + * Gets the prefix list dictionary. + * + * @param response the response + * @return the prefix list dictionary + */ public void getPrefixListDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getPrefixListDictionaryEntityData(response); } + /** + * Gets the address group dictionary. + * + * @param response the response + * @return the address group dictionary + */ public void getAddressGroupDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getAddressGroupDictionaryEntityData(response); } + /** + * Gets the service group dictionary. + * + * @param response the response + * @return the service group dictionary + */ public void getServiceGroupDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getServiceGroupDictionaryEntityData(response); } + /** + * Gets the service list dictionary. + * + * @param response the response + * @return the service list dictionary + */ public void getServiceListDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getServiceListDictionaryEntityData(response); } + /** + * Gets the term list dictionary. + * + * @param response the response + * @return the term list dictionary + */ public void getTermListDictionary(HttpServletResponse response) { FirewallDictionaryController dictionary = new FirewallDictionaryController(); dictionary.getTermListDictionaryEntityData(response); } + /** + * Gets the micro service location dictionary. + * + * @param response the response + * @return the micro service location dictionary + */ public void getMicroServiceLocationDictionary(HttpServletResponse response) { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); dictionary.getMicroServiceLocationDictionaryEntityData(response); } + /** + * Gets the micro service config name dictionary. + * + * @param response the response + * @return the micro service config name dictionary + */ public void getMicroServiceConfigNameDictionary(HttpServletResponse response) { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); dictionary.getMicroServiceConfigNameDictionaryEntityData(response); } + /** + * Gets the micro service dictionary data. + * + * @param response the response + * @return the micro service dictionary data + */ + public void getMicroServiceDictionaryData(HttpServletResponse response) { + MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); + dictionary.getMicroServiceDictNameDictionaryEntityData(response); + } + + /** + * Gets the DCAEUUID dictionary. + * + * @param response the response + * @return the DCAEUUID dictionary + */ public void getDCAEUUIDDictionary(HttpServletResponse response) { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); dictionary.getDCAEUUIDDictionaryEntityData(response); } + /** + * Gets the micro service models dictionary. + * + * @param response the response + * @return the micro service models dictionary + */ public void getMicroServiceModelsDictionary(HttpServletResponse response) { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); dictionary.getMicroServiceModelsDictionaryEntityData(response); } + /** + * Gets the micro service dictionary. + * + * @param response the response + * @return the micro service dictionary + */ public void getMicroServiceDictionary(HttpServletResponse response) { MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController(); dictionary.getMicroServiceModelsDictionaryEntityData(response); } + /** + * Gets the optimization models dictionary. + * + * @param response the response + * @return the optimization models dictionary + */ public void getOptimizationModelsDictionary(HttpServletResponse response) { OptimizationDictionaryController dictionary = new OptimizationDictionaryController(); dictionary.getOptimizationModelsDictionaryEntityData(response); } + /** + * Gets the PS service dictionary. + * + * @param response the response + * @return the PS service dictionary + */ public void getPSServiceDictionary(HttpServletResponse response) { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); dictionary.getPSServiceEntityData(response); } + /** + * Gets the PS resource dictionary. + * + * @param response the response + * @return the PS resource dictionary + */ public void getPSResourceDictionary(HttpServletResponse response) { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); dictionary.getPSResourceEntityData(response); } + /** + * Gets the PS type dictionary. + * + * @param response the response + * @return the PS type dictionary + */ public void getPSTypeDictionary(HttpServletResponse response) { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); dictionary.getPSTypeEntityData(response); } + /** + * Gets the PS closed loop dictionary. + * + * @param response the response + * @return the PS closed loop dictionary + */ public void getPSClosedLoopDictionary(HttpServletResponse response) { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); dictionary.getPSClosedLoopEntityData(response); } + /** + * Gets the PS group scope dictionary. + * + * @param response the response + * @return the PS group scope dictionary + */ public void getPSGroupScopeDictionary(HttpServletResponse response) { PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController(); dictionary.getGroupPolicyScopeEntityData(response); } + /** + * Gets the risk type dictionary. + * + * @param response the response + * @return the risk type dictionary + */ public void getRiskTypeDictionary(HttpServletResponse response) { SafePolicyController dictionary = new SafePolicyController(); dictionary.getRiskTypeDictionaryEntityData(response); } + /** + * Gets the safe policy warning dictionary. + * + * @param response the response + * @return the safe policy warning dictionary + */ public void getSafePolicyWarningDictionary(HttpServletResponse response) { SafePolicyController dictionary = new SafePolicyController(); dictionary.getSafePolicyWarningeEntityData(response); |