summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src
diff options
context:
space:
mode:
authoruj426b <30905205+uj426b@users.noreply.github.com>2019-03-28 18:40:54 -0400
committeruj426b <uj426b@att.com>2019-04-08 17:37:49 -0400
commit06e02108525c3e5e8c85de233aef3bb332173c00 (patch)
tree87554edd057f73a0fd7674d9a4a3c5f27f02b276 /ONAP-PAP-REST/src
parent6da5838f43a4bf0dc8786c539f9a9aa521139e55 (diff)
CLAMP Model policy creation support
Change-Id: Ia69f061c078e4f6ed4b4d2cd12f03f58514f2123 Issue-ID: POLICY-1416 Signed-off-by: uj426b <uj426b@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java180
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java638
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandlerImpl.java18
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java630
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java269
5 files changed, 1238 insertions, 497 deletions
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/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..5fd0b9169 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;
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);
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
index 213d774bd..e561a65b2 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.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.
* ================================================================================
* Modifications Copyright (C) 2019 Samsung
* ================================================================================
@@ -51,8 +51,8 @@ import org.springframework.mock.web.MockHttpServletResponse;
* The class <code>MicroServiceDictionaryControllerTest</code> contains tests for the class
* {@link <code>MicroServiceDictionaryController</code>}*
*
- * All JUnits are designed to run in the local development environment where they have write
- * privileges and can execute time-sensitive tasks.
+ * All JUnits are designed to run in the local development environment where they have write privileges and can execute
+ * time-sensitive tasks.
*/
public class MicroServiceDictionaryControllerTest {
@@ -71,8 +71,7 @@ public class MicroServiceDictionaryControllerTest {
UserInfo userInfo = new UserInfo();
userInfo.setUserLoginId("testUserId");
userInfo.setUserName("John");
- when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing"))
- .thenReturn(userInfo);
+ when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
List<String> listIds = new ArrayList<String>();
listIds.add("Jack");
@@ -80,8 +79,7 @@ public class MicroServiceDictionaryControllerTest {
List<String> microList = new ArrayList<String>();
microList.add("MC-Model");
- when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name"))
- .thenReturn(microList);
+ when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
List<Object> listId = new ArrayList<Object>();
listId.add("smith");
@@ -96,18 +94,17 @@ public class MicroServiceDictionaryControllerTest {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
- jsonString =
- "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
- + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
- + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
- + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
- + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
- + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
- + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
- + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
- + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
- + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
- + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+ jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
+ + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
+ + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
+ + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
+ + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
+ + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
br = new BufferedReader(new StringReader(jsonString));
// --- mock the getReader() call
@@ -268,19 +265,18 @@ public class MicroServiceDictionaryControllerTest {
try {
// mock the getReader() call
- jsonString =
- "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
- + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
- + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
- + " \"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
- + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
- + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
- + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
- + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
- + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
- + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
- + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
- + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+ jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
+ + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
+ + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
+ + " \"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
+ + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
+ + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveDCAEUUIDDictionary(request, response);
@@ -318,8 +314,8 @@ public class MicroServiceDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.removeMicroServiceConfigNameDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceConfigNameDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
@@ -335,8 +331,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceConfigNameDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -354,8 +350,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceConfigNameDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceConfigNameDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -373,25 +369,24 @@ public class MicroServiceDictionaryControllerTest {
try {
// mock the getReader() call
- jsonString =
- "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
- + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
- + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
- + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
- + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\","
- + "\"subScopename\": \"\"},\"policy\": "
- + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
- + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
- + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
- + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
- + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
- + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+ jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
+ + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
+ + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
+ + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
+ + "\"recursive\": false},\"tempModel\": {\"name\": \"testingdata\","
+ + "\"subScopename\": \"\"},\"policy\": "
+ + "{\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveMicroServiceConfigNameDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceConfigNameDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
@@ -423,8 +418,8 @@ public class MicroServiceDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.removeMicroServiceConfigNameDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceConfigNameDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
@@ -441,8 +436,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceLocationByNameDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceLocationDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -460,8 +455,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceLocationDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceLocationDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -479,25 +474,24 @@ public class MicroServiceDictionaryControllerTest {
try {
// mock the getReader() call
- jsonString =
- "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
- + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
- + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\","
- + "\"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
- + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
- + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
- + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
- + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
- + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
- + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
- + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
- + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+ jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
+ + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
+ + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\","
+ + "\"version\": \"\",\"createdBy\": \"someone\",\"modifiedBy\": \"someone\","
+ + "\"content\": \"\",\"recursive\": false},\"tempModel\": "
+ + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveMicroServiceLocationDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceLocationDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
@@ -531,8 +525,8 @@ public class MicroServiceDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.removeMicroServiceLocationDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceLocationDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
@@ -548,8 +542,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceAttributeDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -567,8 +561,8 @@ public class MicroServiceDictionaryControllerTest {
controller.getMicroServiceAttributeDictionaryEntityData(response);
try {
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceAttributeDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
logger.info("response.getContentAsString(): " + response.getContentAsString());
} catch (UnsupportedEncodingException e) {
fail("Exception: " + e);
@@ -586,25 +580,23 @@ public class MicroServiceDictionaryControllerTest {
try {
// mock the getReader() call
- jsonString =
- "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
- + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
- + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
- + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
- + "\"recursive\": false},\"tempModel\": "
- + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
- + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
- + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
- + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
- + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
- + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
- + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+ jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",\"inprocess\": false,"
+ + "\"model\": {\"name\": \"testingdata\",\"subScopename\": \"\",\"path\": [],"
+ + "\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\","
+ + "\"createdBy\": \"someone\",\"modifiedBy\": \"someone\",\"content\": \"\","
+ + "\"recursive\": false},\"tempModel\": " + "{\"name\": \"testingdata\",\"subScopename\": \"\"},"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
BufferedReader br = new BufferedReader(new StringReader(jsonString));
when(request.getReader()).thenReturn(br);
controller.saveMicroServiceAttributeDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceAttributeDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
}
@@ -636,8 +628,8 @@ public class MicroServiceDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.removeMicroServiceAttributeDictionary(request, response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceAttributeDictionaryDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
} catch (Exception e) {
fail("Exception: " + e);
@@ -755,8 +747,8 @@ public class MicroServiceDictionaryControllerTest {
when(request.getReader()).thenReturn(br);
controller.getMicroServiceModelsDictionaryClassEntityData(response);
logger.info("response.getContentAsString(): " + response.getContentAsString());
- assertTrue(response.getContentAsString() != null && response.getContentAsString()
- .contains("microServiceModelsDictionaryClassDatas"));
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas"));
} catch (Exception e) {
fail("Exception: " + e);
@@ -820,4 +812,83 @@ public class MicroServiceDictionaryControllerTest {
}
logger.info("testRemoveMicroServiceModelsDictionary: exit");
}
+
+ @Test
+ public void testRemoveMicroServiceDictionaryData() {
+ logger.info("testRemoveMicroServiceModelsDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ jsonString =
+ "{\"data\": {\"modelName\": \"test\",\"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
+ + "\"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,"
+ + "\"date\": \"2017-04-12T21:26:57.000Z\",\"version\": \"\",\"createdBy\": \"someone\","
+ + "\"modifiedBy\": \"someone\",\"content\": \"\",\"recursive\": false},"
+ + "\"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"},"
+ + "\"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\","
+ + "\"policyName\": \"may1501\",\"policyDescription\": \"testing input\","
+ + "\"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\","
+ + "\"riskLevel\": \"2\",\"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\","
+ + "\"version\": \"1707.41.02\",\"ruleGridData\": [[\"fileId\"]],\"ttlDate\": null}},"
+ + "\"policyJSON\": {\"pmTableName\": \"test\",\"dmdTopic\": \"1\",\"fileId\": \"56\"}}";
+
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.removeMicroServiceDictionaryData(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceDictionaryData"));
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+ logger.info("testRemoveMicroServiceModelsDictionary: exit");
+ }
+
+ @Test
+ public void getMicroServiceDictNameDictionaryEntityData() {
+ logger.info("getMicroServiceDictNameDictionaryEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ String msModelJson = "{\"microServiceDictionaryData\":[\"modelName\"]}";
+
+ BufferedReader br = new BufferedReader(new StringReader(msModelJson));
+ request = mock(HttpServletRequest.class);
+
+ try {
+ when(request.getReader()).thenReturn(br);
+ controller.getMicroServiceDictNameDictionaryEntityData(response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceDictionaryData"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("getMicroServiceDictNameDictionaryEntityData: exit");
+ }
+
+ @Test
+ public void testSaveDictionaryData() {
+ logger.info("testSaveDictionaryData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ jsonString = "{\"microServiceDictionaryDatas\": {\"id\": 1,\"dictionaryName\": \"tes1t\","
+ + "\"dictionaryUrl\": \"tes1t\",\"dictionaryDataByName\": \"test\"}}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.saveDictionaryData(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue(response.getContentAsString() != null
+ && response.getContentAsString().contains("microServiceDictionaryDatas"));
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+ logger.info("testSaveDictionaryData: exit");
+ }
}