aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java78
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java188
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java250
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java89
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java47
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java74
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java65
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java510
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java125
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java206
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java221
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java18
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java76
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/package-info.java3
14 files changed, 976 insertions, 974 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
index 8e620408b..f576bffe8 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ActionPolicyDictionaryController.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.
@@ -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 java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -38,10 +42,6 @@ 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;
-
@Controller
public class ActionPolicyDictionaryController {
@@ -51,36 +51,43 @@ public class ActionPolicyDictionaryController {
private static String actionDatas = "actionPolicyDictionaryDatas";
@Autowired
- public ActionPolicyDictionaryController(CommonClassDao commonClassDao){
+ public ActionPolicyDictionaryController(CommonClassDao commonClassDao) {
ActionPolicyDictionaryController.commonClassDao = commonClassDao;
}
- public void setCommonClassDao(CommonClassDao commonClassDao){
+ public void setCommonClassDao(CommonClassDao commonClassDao) {
ActionPolicyDictionaryController.commonClassDao = commonClassDao;
}
- public ActionPolicyDictionaryController(){
+ public ActionPolicyDictionaryController() {
super();
}
- private DictionaryUtils getDictionaryUtilsInstance(){
+ private DictionaryUtils getDictionaryUtilsInstance() {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value={"/get_ActionPolicyDictDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getActionEntitybyName(HttpServletResponse response){
+ @RequestMapping(
+ value = {"/get_ActionPolicyDictDataByName"},
+ method = {RequestMethod.GET},
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getActionEntitybyName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, actionDatas, attributeName, ActionPolicyDict.class);
}
- @RequestMapping(value={"/get_ActionPolicyDictData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getActionPolicyDictionaryEntityData(HttpServletResponse response){
+ @RequestMapping(
+ value = {"/get_ActionPolicyDictData"},
+ method = {RequestMethod.GET},
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getActionPolicyDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, actionDatas, ActionPolicyDict.class);
}
- @RequestMapping(value={"/action_dictionary/save_ActionDict"}, method={RequestMethod.POST})
- public ModelAndView saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ @RequestMapping(value = {"/action_dictionary/save_ActionDict"}, method = {RequestMethod.POST})
+ public ModelAndView saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -90,63 +97,68 @@ public class ActionPolicyDictionaryController {
ActionPolicyDict actionPolicyDict = null;
ActionAdapter adapter = null;
String userId = null;
- if(fromAPI){
+ if (fromAPI) {
actionPolicyDict = mapper.readValue(root.get("dictionaryFields").toString(), ActionPolicyDict.class);
adapter = mapper.readValue(root.get("dictionaryFields").toString(), ActionAdapter.class);
userId = "API";
- }else{
- actionPolicyDict = mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionPolicyDict.class);
+ } else {
+ actionPolicyDict =
+ mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionPolicyDict.class);
adapter = mapper.readValue(root.get("actionPolicyDictionaryData").toString(), ActionAdapter.class);
userId = root.get("userid").textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionPolicyDict.getAttributeName(), attributeName, ActionPolicyDict.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionPolicyDict.getAttributeName(),
+ attributeName, ActionPolicyDict.class);
boolean duplicateflag = false;
- if(!duplicateData.isEmpty()){
+ if (!duplicateData.isEmpty()) {
ActionPolicyDict data = (ActionPolicyDict) duplicateData.get(0);
- if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
actionPolicyDict.setId(data.getId());
- }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) ||
- (request.getParameter(operation) == null && (data.getId() != actionPolicyDict.getId()))){
+ } else if ((request.getParameter(operation) != null
+ && !"update".equals(request.getParameter(operation)))
+ || (request.getParameter(operation) == null && (data.getId() != actionPolicyDict.getId()))) {
duplicateflag = true;
}
}
actionPolicyDict.setHeader(utils.appendKeyValue(adapter.getHeaders(), ":", "="));
String responseString = null;
- if(!duplicateflag){
+ if (!duplicateflag) {
actionPolicyDict.setUserModifiedBy(userInfo);
- if(actionPolicyDict.getId() == 0){
+ if (actionPolicyDict.getId() == 0) {
actionPolicyDict.setUserCreatedBy(userInfo);
commonClassDao.save(actionPolicyDict);
- }else{
+ } else {
actionPolicyDict.setModifiedDate(new Date());
commonClassDao.update(actionPolicyDict);
}
responseString = mapper.writeValueAsString(commonClassDao.getData(ActionPolicyDict.class));
- }else{
+ } else {
responseString = "Duplicate";
}
- if(fromAPI){
+ if (fromAPI) {
return utils.getResultForApi(responseString);
- }else{
+ } else {
utils.setResponseData(response, actionDatas, responseString);
}
- }catch(Exception e){
+ } catch (Exception e) {
utils.setErrorResponseData(response, e);
}
return null;
}
- @RequestMapping(value={"/action_dictionary/remove_actionPolicyDict"}, method={RequestMethod.POST})
- public void removeActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/action_dictionary/remove_actionPolicyDict"}, method = {RequestMethod.POST})
+ public void removeActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, actionDatas, ActionPolicyDict.class);
}
}
-class ActionAdapter{
+
+class ActionAdapter {
private List<Object> headers;
public List<Object> getHeaders() {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
index d6ebed2b8..d9cde35bb 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
@@ -23,13 +23,16 @@ 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 java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.io.IOUtils;
import org.onap.policy.api.PEDependency;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -37,9 +40,9 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.components.CreateBRMSRuleTemplate;
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
-import org.onap.policy.rest.jpa.BRMSController;
-import org.onap.policy.rest.jpa.BRMSDependency;
-import org.onap.policy.rest.jpa.BRMSParamTemplate;
+import org.onap.policy.rest.jpa.BrmsController;
+import org.onap.policy.rest.jpa.BrmsDependency;
+import org.onap.policy.rest.jpa.BrmsParamTemplate;
import org.onap.policy.rest.jpa.OnapName;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
@@ -51,7 +54,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
-
@Controller
public class BRMSDictionaryController {
@@ -91,32 +93,35 @@ public class BRMSDictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_BRMSParamDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSParamDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSParamDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, brmsParamDatas, ruleName, BRMSParamTemplate.class);
+ utils.getDataByEntity(response, brmsParamDatas, ruleName, BrmsParamTemplate.class);
}
- @RequestMapping(value = {"/get_BRMSParamData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSParamData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSParamDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, brmsParamDatas, BRMSParamTemplate.class);
+ utils.getData(response, brmsParamDatas, BrmsParamTemplate.class);
}
@RequestMapping(value = {"/brms_dictionary/set_BRMSParamData"}, method = {RequestMethod.POST})
public static void setRuleData(HttpServletRequest request) throws IOException {
StringWriter writer = new StringWriter();
IOUtils.copy(request.getInputStream(), writer, StandardCharsets.UTF_8);
- String cleanStreamBoundary =
- writer.toString().replaceFirst("------(.*)(?s).*octet-stream", "");
+ String cleanStreamBoundary = writer.toString().replaceFirst("------(.*)(?s).*octet-stream", "");
rule = cleanStreamBoundary.substring(0, cleanStreamBoundary.lastIndexOf("end") + 4);
}
@RequestMapping(value = {"/brms_dictionary/save_BRMSParam"}, method = {RequestMethod.POST})
- public ModelAndView saveBRMSParamDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -124,26 +129,25 @@ public class BRMSDictionaryController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- BRMSParamTemplate bRMSParamTemplateData;
+ BrmsParamTemplate bRMSParamTemplateData;
String userId = null;
if (fromAPI) {
- bRMSParamTemplateData = mapper.readValue(root.get(dictionaryFields).toString(),
- BRMSParamTemplate.class);
+ bRMSParamTemplateData =
+ mapper.readValue(root.get(dictionaryFields).toString(), BrmsParamTemplate.class);
userId = "API";
} else {
- bRMSParamTemplateData = mapper.readValue(
- root.get("brmsParamDictionaryData").toString(), BRMSParamTemplate.class);
+ bRMSParamTemplateData =
+ mapper.readValue(root.get("brmsParamDictionaryData").toString(), BrmsParamTemplate.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- bRMSParamTemplateData.getRuleName(), ruleName, BRMSParamTemplate.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(bRMSParamTemplateData.getRuleName(),
+ ruleName, BrmsParamTemplate.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- BRMSParamTemplate data = (BRMSParamTemplate) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ BrmsParamTemplate data = (BrmsParamTemplate) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
bRMSParamTemplateData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
@@ -164,8 +168,7 @@ public class BRMSDictionaryController {
} else {
commonClassDao.update(bRMSParamTemplateData);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(BRMSParamTemplate.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(BrmsParamTemplate.class));
} else {
responseString = duplicateResponseString;
}
@@ -192,30 +195,32 @@ public class BRMSDictionaryController {
}
@RequestMapping(value = {"/brms_dictionary/remove_brmsParam"}, method = {RequestMethod.POST})
- public void removeBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, brmsParamDatas, BRMSParamTemplate.class);
+ utils.removeData(request, response, brmsParamDatas, BrmsParamTemplate.class);
}
- @RequestMapping(value = {"/get_BRMSDependencyDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSDependencyDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSDependencyDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, brmsDependencyDatas, dependencyName, BRMSDependency.class);
+ utils.getDataByEntity(response, brmsDependencyDatas, dependencyName, BrmsDependency.class);
}
- @RequestMapping(value = {"/get_BRMSDependencyData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSDependencyData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSDependencyDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, brmsDependencyDatas, BRMSDependency.class);
+ utils.getData(response, brmsDependencyDatas, BrmsDependency.class);
}
- @RequestMapping(value = {"/brms_dictionary/save_BRMSDependencyData"},
- method = {RequestMethod.POST})
- public ModelAndView saveBRMSDependencyDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/brms_dictionary/save_BRMSDependencyData"}, method = {RequestMethod.POST})
+ public ModelAndView saveBRMSDependencyDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
LOGGER.debug("DictionaryController: saveBRMSDependencyDictionary() is called");
@@ -224,46 +229,41 @@ public class BRMSDictionaryController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- BRMSDependency brmsDependency;
+ BrmsDependency brmsDependency;
String userId = null;
if (fromAPI) {
- brmsDependency = mapper.readValue(root.get(dictionaryFields).toString(),
- BRMSDependency.class);
+ brmsDependency = mapper.readValue(root.get(dictionaryFields).toString(), BrmsDependency.class);
userId = "API";
} else {
- brmsDependency = mapper.readValue(
- root.get("brmsDependencyDictionaryData").toString(), BRMSDependency.class);
+ brmsDependency =
+ mapper.readValue(root.get("brmsDependencyDictionaryData").toString(), BrmsDependency.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- brmsDependency.getDependencyName(), dependencyName, BRMSDependency.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(brmsDependency.getDependencyName(),
+ dependencyName, BrmsDependency.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- BRMSDependency data = (BRMSDependency) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ BrmsDependency data = (BrmsDependency) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
brmsDependency.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != brmsDependency.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != brmsDependency.getId()))) {
duplicateflag = true;
}
}
LOGGER.audit("the userId from the onap portal is: " + userId);
String responseString = null;
- if (brmsDependency.getDependency() != null
- && !("").equals(brmsDependency.getDependency().trim())) {
+ if (brmsDependency.getDependency() != null && !("").equals(brmsDependency.getDependency().trim())) {
PEDependency dependency = null;
try {
- dependency = PolicyUtils.jsonStringToObject(brmsDependency.getDependency(),
- PEDependency.class);
+ dependency = PolicyUtils.jsonStringToObject(brmsDependency.getDependency(), PEDependency.class);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID
- + "wrong data given for BRMS PEDependency Dictionary : "
- + brmsDependency.getDependency(), e);
+ + "wrong data given for BRMS PEDependency Dictionary : " + brmsDependency.getDependency(),
+ e);
}
if (dependency == null) {
responseString = errorMessage;
@@ -277,8 +277,7 @@ public class BRMSDictionaryController {
brmsDependency.setModifiedDate(new Date());
commonClassDao.update(brmsDependency);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(BRMSDependency.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(BrmsDependency.class));
} else {
responseString = duplicateResponseString;
}
@@ -302,33 +301,34 @@ public class BRMSDictionaryController {
return null;
}
- @RequestMapping(value = {"/brms_dictionary/remove_brmsDependency"},
- method = {RequestMethod.POST})
- public void removeBRMSDependencyDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/brms_dictionary/remove_brmsDependency"}, method = {RequestMethod.POST})
+ public void removeBRMSDependencyDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, brmsDependencyDatas, BRMSDependency.class);
+ utils.removeData(request, response, brmsDependencyDatas, BrmsDependency.class);
}
-
- @RequestMapping(value = {"/get_BRMSControllerDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSControllerDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSControllerDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, brmsControllerDatas, controllerName, BRMSController.class);
+ utils.getDataByEntity(response, brmsControllerDatas, controllerName, BrmsController.class);
}
- @RequestMapping(value = {"/get_BRMSControllerData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_BRMSControllerData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getBRMSControllerDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, brmsControllerDatas, BRMSController.class);
+ utils.getData(response, brmsControllerDatas, BrmsController.class);
}
- @RequestMapping(value = {"/brms_dictionary/save_BRMSControllerData"},
- method = {RequestMethod.POST})
- public ModelAndView saveBRMSControllerDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/brms_dictionary/save_BRMSControllerData"}, method = {RequestMethod.POST})
+ public ModelAndView saveBRMSControllerDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
LOGGER.debug("DictionaryController: saveBRMSControllerDictionary() is called");
@@ -336,45 +336,39 @@ public class BRMSDictionaryController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- BRMSController brmsController;
+ BrmsController brmsController;
String userId = null;
if (fromAPI) {
- brmsController = mapper.readValue(root.get(dictionaryFields).toString(),
- BRMSController.class);
+ brmsController = mapper.readValue(root.get(dictionaryFields).toString(), BrmsController.class);
userId = "API";
} else {
- brmsController = mapper.readValue(
- root.get("brmsControllerDictionaryData").toString(), BRMSController.class);
+ brmsController =
+ mapper.readValue(root.get("brmsControllerDictionaryData").toString(), BrmsController.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- brmsController.getControllerName(), controllerName, BRMSController.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(brmsController.getControllerName(),
+ controllerName, BrmsController.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- BRMSController data = (BRMSController) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ BrmsController data = (BrmsController) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
brmsController.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != brmsController.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != brmsController.getId()))) {
duplicateflag = true;
}
}
String responseString = null;
- if (brmsController.getController() != null
- && !("").equals(brmsController.getController().trim())) {
+ if (brmsController.getController() != null && !("").equals(brmsController.getController().trim())) {
PEDependency dependency = null;
try {
- dependency = PolicyUtils.jsonStringToObject(brmsController.getController(),
- PEDependency.class);
+ dependency = PolicyUtils.jsonStringToObject(brmsController.getController(), PEDependency.class);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID
- + "wrong data given for BRMS Controller Dictionary : "
- + brmsController.getController(), e);
+ + "wrong data given for BRMS Controller Dictionary : " + brmsController.getController(), e);
}
if (dependency == null) {
responseString = errorMessage;
@@ -388,8 +382,7 @@ public class BRMSDictionaryController {
brmsController.setModifiedDate(new Date());
commonClassDao.update(brmsController);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(OnapName.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(OnapName.class));
} else {
responseString = duplicateResponseString;
}
@@ -412,21 +405,20 @@ public class BRMSDictionaryController {
return null;
}
- @RequestMapping(value = {"/brms_dictionary/remove_brmsController"},
- method = {RequestMethod.POST})
- public void removeBRMSControllerDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/brms_dictionary/remove_brmsController"}, method = {RequestMethod.POST})
+ public void removeBRMSControllerDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, brmsControllerDatas, BRMSController.class);
+ utils.removeData(request, response, brmsControllerDatas, BrmsController.class);
}
- public BRMSDependency getDependencyDataByID(String dependencyName) {
- return (BRMSDependency) commonClassDao.getEntityItem(BRMSDependency.class,
+ public BrmsDependency getDependencyDataByID(String dependencyName) {
+ return (BrmsDependency) commonClassDao.getEntityItem(BrmsDependency.class,
BRMSDictionaryController.dependencyName, dependencyName);
}
- public BRMSController getControllerDataByID(String controllerName) {
- return (BRMSController) commonClassDao.getEntityItem(BRMSController.class,
+ public BrmsController getControllerDataByID(String controllerName) {
+ return (BrmsController) commonClassDao.getEntityItem(BrmsController.class,
BRMSDictionaryController.controllerName, controllerName);
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
index 2aec0cc0d..9ea956aa7 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/ClosedLoopDictionaryController.java
@@ -23,11 +23,14 @@ 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 java.io.IOException;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.policy.pap.xacml.rest.adapters.GridData;
import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
@@ -35,10 +38,10 @@ import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ClosedLoopD2Services;
import org.onap.policy.rest.jpa.ClosedLoopSite;
import org.onap.policy.rest.jpa.OnapName;
-import org.onap.policy.rest.jpa.PEPOptions;
+import org.onap.policy.rest.jpa.PepOptions;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.jpa.VNFType;
-import org.onap.policy.rest.jpa.VSCLAction;
+import org.onap.policy.rest.jpa.VnfType;
+import org.onap.policy.rest.jpa.VsclAction;
import org.onap.policy.rest.jpa.VarbindDictionary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@@ -51,9 +54,9 @@ import org.springframework.web.servlet.ModelAndView;
public class ClosedLoopDictionaryController {
private static CommonClassDao commonClassDao;
- private static String vsclaction = "vsclaction";
+ private static String vsclaction = "action";
private static String operation = "operation";
- private static String vnftype = "vnftype";
+ private static String vnftype = "type";
private static String pepName = "pepName";
private static String varbindName = "varbindName";
private static String serviceName = "serviceName";
@@ -89,85 +92,108 @@ public class ClosedLoopDictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_VSCLActionDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VSCLActionDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVSCLActionDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, vsclActionDatas, vsclaction, VSCLAction.class);
+ utils.getDataByEntity(response, vsclActionDatas, vsclaction, VsclAction.class);
}
-
- @RequestMapping(value = {"/get_VSCLActionData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VSCLActionData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVSCLActionDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, vsclActionDatas, VSCLAction.class);
+ utils.getData(response, vsclActionDatas, VsclAction.class);
}
- @RequestMapping(value = {"/get_VNFTypeDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VNFTypeDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVNFTypeDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, vnfTypeDatas, vnftype, VNFType.class);
+ utils.getDataByEntity(response, vnfTypeDatas, vnftype, VnfType.class);
}
- @RequestMapping(value = {"/get_VNFTypeData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VNFTypeData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVNFTypeDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, vnfTypeDatas, VNFType.class);
+ utils.getData(response, vnfTypeDatas, VnfType.class);
}
- @RequestMapping(value = {"/get_PEPOptionsDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PEPOptionsDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPEPOptionsDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, pepOptionDatas, pepName, PEPOptions.class);
+ utils.getDataByEntity(response, pepOptionDatas, pepName, PepOptions.class);
}
- @RequestMapping(value = {"/get_PEPOptionsData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PEPOptionsData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPEPOptionsDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, pepOptionDatas, PEPOptions.class);
+ utils.getData(response, pepOptionDatas, PepOptions.class);
}
- @RequestMapping(value = {"/get_VarbindDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VarbindDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVarbindDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, varbindDatas, varbindName, VarbindDictionary.class);
}
- @RequestMapping(value = {"/get_VarbindDictionaryData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_VarbindDictionaryData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getVarbindDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, varbindDatas, VarbindDictionary.class);
}
- @RequestMapping(value = {"/get_ClosedLoopServicesDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ClosedLoopServicesDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getClosedLoopServiceDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, closedLoopDatas, serviceName, ClosedLoopD2Services.class);
}
- @RequestMapping(value = {"/get_ClosedLoopServicesData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ClosedLoopServicesData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getClosedLoopServiceDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, closedLoopDatas, ClosedLoopD2Services.class);
}
- @RequestMapping(value = {"/get_ClosedLoopSiteDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ClosedLoopSiteDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getClosedLoopSiteDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, closedLoopSiteDatas, siteName, ClosedLoopSite.class);
}
- @RequestMapping(value = {"/get_ClosedLoopSiteData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ClosedLoopSiteData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getClosedLoopSiteDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -175,39 +201,34 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/save_vsclAction"}, method = {RequestMethod.POST})
- public ModelAndView saveVSCLAction(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView saveVSCLAction(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());
- VSCLAction vSCLAction;
+ VsclAction vSCLAction;
String userId = null;
if (fromAPI) {
- vSCLAction =
- mapper.readValue(root.get(dictionaryFields).toString(), VSCLAction.class);
+ vSCLAction = mapper.readValue(root.get(dictionaryFields).toString(), VsclAction.class);
userId = "API";
} else {
- vSCLAction = mapper.readValue(root.get("vsclActionDictionaryData").toString(),
- VSCLAction.class);
+ vSCLAction = mapper.readValue(root.get("vsclActionDictionaryData").toString(), VsclAction.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao
- .checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(vSCLAction.getAction(), vsclaction, VsclAction.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- VSCLAction data = (VSCLAction) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ VsclAction data = (VsclAction) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
vSCLAction.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != vSCLAction.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != vSCLAction.getId()))) {
duplicateflag = true;
}
}
@@ -221,8 +242,7 @@ public class ClosedLoopDictionaryController {
vSCLAction.setModifiedDate(new Date());
commonClassDao.update(vSCLAction);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(VsclAction.class));
} else {
responseString = duplicateResponseString;
}
@@ -239,45 +259,40 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_VsclAction"}, method = {RequestMethod.POST})
- public void removeVSCLAction(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, vsclActionDatas, OnapName.class);
}
@RequestMapping(value = {"/cl_dictionary/save_vnfType"}, method = {RequestMethod.POST})
- public ModelAndView saveVnfType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView saveVnfType(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());
- VNFType vNFType;
+ VnfType vNFType;
String userId = null;
if (fromAPI) {
- vNFType = mapper.readValue(root.get(dictionaryFields).toString(), VNFType.class);
+ vNFType = mapper.readValue(root.get(dictionaryFields).toString(), VnfType.class);
userId = "API";
} else {
- vNFType = mapper.readValue(root.get("vnfTypeDictionaryData").toString(),
- VNFType.class);
+ vNFType = mapper.readValue(root.get("vnfTypeDictionaryData").toString(), VnfType.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(vNFType.getVnftype(),
- vnftype, VNFType.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(vNFType.getType(), vnftype, VnfType.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- VNFType data = (VNFType) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ VnfType data = (VnfType) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
vNFType.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != vNFType.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != vNFType.getId()))) {
duplicateflag = true;
}
}
@@ -291,7 +306,7 @@ public class ClosedLoopDictionaryController {
vNFType.setModifiedDate(new Date());
commonClassDao.update(vNFType);
}
- responseString = mapper.writeValueAsString(commonClassDao.getData(VNFType.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(VnfType.class));
} else {
responseString = duplicateResponseString;
}
@@ -308,34 +323,29 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_vnfType"}, method = {RequestMethod.POST})
- public void removeVnfType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, vnfTypeDatas, VNFType.class);
+ utils.removeData(request, response, vnfTypeDatas, VnfType.class);
}
@RequestMapping(value = {"/cl_dictionary/save_pepOptions"}, method = {RequestMethod.POST})
- public ModelAndView savePEPOptions(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView savePEPOptions(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());
- PEPOptions pEPOptions;
+ PepOptions pEPOptions;
GridData gridData;
String userId = null;
if (fromAPI) {
- pEPOptions =
- mapper.readValue(root.get(dictionaryFields).toString(), PEPOptions.class);
+ pEPOptions = mapper.readValue(root.get(dictionaryFields).toString(), PepOptions.class);
gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
userId = "API";
} else {
- pEPOptions = mapper.readValue(root.get("pepOptionsDictionaryData").toString(),
- PEPOptions.class);
- gridData = mapper.readValue(root.get("pepOptionsDictionaryData").toString(),
- GridData.class);
+ pEPOptions = mapper.readValue(root.get("pepOptionsDictionaryData").toString(), PepOptions.class);
+ gridData = mapper.readValue(root.get("pepOptionsDictionaryData").toString(), GridData.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
@@ -344,18 +354,16 @@ public class ClosedLoopDictionaryController {
pEPOptions.setActions(utils.appendKeyValue(gridData.getAttributes(), ":#@", "=#@"));
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(),
- pepName, PEPOptions.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PepOptions.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- PEPOptions data = (PEPOptions) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ PepOptions data = (PepOptions) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
pEPOptions.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != pEPOptions.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != pEPOptions.getId()))) {
duplicateflag = true;
}
}
@@ -369,8 +377,7 @@ public class ClosedLoopDictionaryController {
pEPOptions.setModifiedDate(new Date());
commonClassDao.update(pEPOptions);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PepOptions.class));
} else {
responseString = duplicateResponseString;
}
@@ -387,15 +394,13 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_pepOptions"}, method = {RequestMethod.POST})
- public void removePEPOptions(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, pepOptionDatas, VNFType.class);
+ utils.removeData(request, response, pepOptionDatas, VnfType.class);
}
@RequestMapping(value = {"/cl_dictionary/save_service"}, method = {RequestMethod.POST})
- public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -405,29 +410,25 @@ public class ClosedLoopDictionaryController {
ClosedLoopD2Services serviceData;
String userId = null;
if (fromAPI) {
- serviceData = mapper.readValue(root.get(dictionaryFields).toString(),
- ClosedLoopD2Services.class);
+ serviceData = mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopD2Services.class);
userId = "API";
} else {
- serviceData =
- mapper.readValue(root.get("closedLoopServiceDictionaryData").toString(),
- ClosedLoopD2Services.class);
+ serviceData = mapper.readValue(root.get("closedLoopServiceDictionaryData").toString(),
+ ClosedLoopD2Services.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName,
+ ClosedLoopD2Services.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
ClosedLoopD2Services data = (ClosedLoopD2Services) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
serviceData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != serviceData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != serviceData.getId()))) {
duplicateflag = true;
}
}
@@ -441,8 +442,7 @@ public class ClosedLoopDictionaryController {
serviceData.setModifiedDate(new Date());
commonClassDao.update(serviceData);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
} else {
responseString = duplicateResponseString;
}
@@ -458,15 +458,13 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_Service"}, method = {RequestMethod.POST})
- public void removeServiceType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, closedLoopDatas, VNFType.class);
+ utils.removeData(request, response, closedLoopDatas, VnfType.class);
}
@RequestMapping(value = {"/cl_dictionary/save_siteName"}, method = {RequestMethod.POST})
- public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -476,28 +474,24 @@ public class ClosedLoopDictionaryController {
ClosedLoopSite siteData;
String userId = null;
if (fromAPI) {
- siteData = mapper.readValue(root.get(dictionaryFields).toString(),
- ClosedLoopSite.class);
+ siteData = mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopSite.class);
userId = "API";
} else {
- siteData = mapper.readValue(root.get("closedLoopSiteDictionaryData").toString(),
- ClosedLoopSite.class);
+ siteData = mapper.readValue(root.get("closedLoopSiteDictionaryData").toString(), ClosedLoopSite.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(siteData.getSiteName(),
- siteName, ClosedLoopSite.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
ClosedLoopSite data = (ClosedLoopSite) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
siteData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != siteData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != siteData.getId()))) {
duplicateflag = true;
}
}
@@ -511,8 +505,7 @@ public class ClosedLoopDictionaryController {
siteData.setModifiedDate(new Date());
commonClassDao.update(siteData);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
} else {
responseString = duplicateResponseString;
}
@@ -528,15 +521,13 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_site"}, method = {RequestMethod.POST})
- public void removeSiteType(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, closedLoopSiteDatas, VNFType.class);
+ utils.removeData(request, response, closedLoopSiteDatas, VnfType.class);
}
@RequestMapping(value = {"/cl_dictionary/save_varbind"}, method = {RequestMethod.POST})
- public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -546,28 +537,25 @@ public class ClosedLoopDictionaryController {
VarbindDictionary varbindDictionary;
String userId = null;
if (fromAPI) {
- varbindDictionary = mapper.readValue(root.get(dictionaryFields).toString(),
- VarbindDictionary.class);
+ varbindDictionary = mapper.readValue(root.get(dictionaryFields).toString(), VarbindDictionary.class);
userId = "API";
} else {
- varbindDictionary = mapper.readValue(root.get("varbindDictionaryData").toString(),
- VarbindDictionary.class);
+ varbindDictionary =
+ mapper.readValue(root.get("varbindDictionaryData").toString(), VarbindDictionary.class);
userId = root.get(userid).textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(),
+ varbindName, VarbindDictionary.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
VarbindDictionary data = (VarbindDictionary) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
varbindDictionary.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != varbindDictionary.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != varbindDictionary.getId()))) {
duplicateflag = true;
}
}
@@ -582,8 +570,7 @@ public class ClosedLoopDictionaryController {
varbindDictionary.setModifiedDate(new Date());
commonClassDao.update(varbindDictionary);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
} else {
responseString = duplicateResponseString;
}
@@ -599,9 +586,8 @@ public class ClosedLoopDictionaryController {
}
@RequestMapping(value = {"/cl_dictionary/remove_varbindDict"}, method = {RequestMethod.POST})
- public void removeVarbind(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, varbindDatas, VNFType.class);
+ utils.removeData(request, response, varbindDatas, VnfType.class);
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
index c89d21e91..4b6492baa 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DecisionPolicyDictionaryController.java
@@ -23,12 +23,15 @@ 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 java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.DecisionSettings;
@@ -66,16 +69,18 @@ public class DecisionPolicyDictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_SettingsDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SettingsDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
- public void getSettingsDictionaryByNameEntityData(HttpServletRequest request,
- HttpServletResponse response) {
+ public void getSettingsDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, settingDatas, xacmlId, DecisionSettings.class);
}
-
- @RequestMapping(value = {"/get_SettingsDictionaryData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SettingsDictionaryData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getSettingsDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -83,8 +88,8 @@ public class DecisionPolicyDictionaryController {
}
@RequestMapping(value = {"/decision_dictionary/save_Settings"}, method = {RequestMethod.POST})
- public ModelAndView saveSettingsDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -95,27 +100,24 @@ public class DecisionPolicyDictionaryController {
String userId = null;
if (fromAPI) {
- decisionSettings = mapper.readValue(root.get(dictionaryFields).toString(),
- DecisionSettings.class);
+ decisionSettings = mapper.readValue(root.get(dictionaryFields).toString(), DecisionSettings.class);
userId = "API";
} else {
- decisionSettings = mapper.readValue(root.get("settingsDictionaryData").toString(),
- DecisionSettings.class);
+ decisionSettings =
+ mapper.readValue(root.get("settingsDictionaryData").toString(), DecisionSettings.class);
userId = root.get("userid").textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- decisionSettings.getXacmlId(), xacmlId, DecisionSettings.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(decisionSettings.getXacmlId(), xacmlId, DecisionSettings.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
DecisionSettings data = (DecisionSettings) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
decisionSettings.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != decisionSettings.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != decisionSettings.getId()))) {
duplicateflag = true;
}
}
@@ -133,8 +135,7 @@ public class DecisionPolicyDictionaryController {
decisionSettings.setModifiedDate(new Date());
commonClassDao.update(decisionSettings);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(DecisionSettings.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(DecisionSettings.class));
} else {
responseString = duplicateResponseString;
}
@@ -150,21 +151,23 @@ public class DecisionPolicyDictionaryController {
}
@RequestMapping(value = {"/settings_dictionary/remove_settings"}, method = {RequestMethod.POST})
- public void removeSettingsDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, settingDatas, DecisionSettings.class);
}
- @RequestMapping(value = {"/get_RainyDayDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_RainyDayDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
- public void getRainyDayDictionaryByNameEntityData(HttpServletRequest request,
- HttpServletResponse response) {
+ public void getRainyDayDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, rainDayDatas, bbID, RainyDayTreatments.class);
}
- @RequestMapping(value = {"/get_RainyDayDictionaryData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_RainyDayDictionaryData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getRainyDayDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -172,8 +175,8 @@ public class DecisionPolicyDictionaryController {
}
@RequestMapping(value = {"/decision_dictionary/save_RainyDay"}, method = {RequestMethod.POST})
- public ModelAndView saveRainyDayDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveRainyDayDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -183,32 +186,26 @@ public class DecisionPolicyDictionaryController {
RainyDayTreatments decisionRainyDay;
TreatmentValues treatmentsData = null;
if (fromAPI) {
- decisionRainyDay = mapper.readValue(root.get(dictionaryFields).toString(),
- RainyDayTreatments.class);
- treatmentsData = mapper.readValue(root.get(dictionaryFields).toString(),
- TreatmentValues.class);
+ decisionRainyDay = mapper.readValue(root.get(dictionaryFields).toString(), RainyDayTreatments.class);
+ treatmentsData = mapper.readValue(root.get(dictionaryFields).toString(), TreatmentValues.class);
} else {
- decisionRainyDay = mapper.readValue(root.get("rainyDayDictionaryData").toString(),
- RainyDayTreatments.class);
- treatmentsData = mapper.readValue(root.get("rainyDayDictionaryData").toString(),
- TreatmentValues.class);
+ decisionRainyDay =
+ mapper.readValue(root.get("rainyDayDictionaryData").toString(), RainyDayTreatments.class);
+ treatmentsData = mapper.readValue(root.get("rainyDayDictionaryData").toString(), TreatmentValues.class);
}
- decisionRainyDay.setTreatments(
- utils.appendKey(treatmentsData.getUserDataTypeValues(), "treatment", ","));
+ decisionRainyDay.setTreatments(utils.appendKey(treatmentsData.getUserDataTypeValues(), "treatment", ","));
List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- decisionRainyDay.getBbid() + ":" + decisionRainyDay.getWorkstep(),
- "bbid:workstep", RainyDayTreatments.class);
+ decisionRainyDay.getBbid() + ":" + decisionRainyDay.getWorkstep(), "bbid:workstep",
+ RainyDayTreatments.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
RainyDayTreatments data = (RainyDayTreatments) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
decisionRainyDay.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != decisionRainyDay.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != decisionRainyDay.getId()))) {
duplicateflag = true;
}
}
@@ -219,8 +216,7 @@ public class DecisionPolicyDictionaryController {
} else {
commonClassDao.update(decisionRainyDay);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(RainyDayTreatments.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(RainyDayTreatments.class));
} else {
responseString = duplicateResponseString;
}
@@ -236,8 +232,7 @@ public class DecisionPolicyDictionaryController {
}
@RequestMapping(value = {"/decision_dictionary/remove_rainyDay"}, method = {RequestMethod.POST})
- public void removeRainyDayDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeRainyDayDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, rainDayDatas, RainyDayTreatments.class);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
index 51c8a1d91..1645b0af9 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DescriptiveDictionaryController.java
@@ -23,11 +23,14 @@ 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 java.io.IOException;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.policy.pap.xacml.rest.adapters.GridData;
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
@@ -65,24 +68,27 @@ public class DescriptiveDictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_DescriptiveScopeByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_DescriptiveScopeByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getDescriptiveDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, descriptiveDatas, dScopeName, DescriptiveScope.class);
}
- @RequestMapping(value = {"/get_DescriptiveScope"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_DescriptiveScope"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getDescriptiveDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, descriptiveDatas, DescriptiveScope.class);
}
- @RequestMapping(value = {"/descriptive_dictionary/save_descriptive"},
- method = {RequestMethod.POST})
- public ModelAndView saveDescriptiveDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/descriptive_dictionary/save_descriptive"}, method = {RequestMethod.POST})
+ public ModelAndView saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -93,32 +99,27 @@ public class DescriptiveDictionaryController {
GridData data;
String userId = null;
if (fromAPI) {
- descriptiveScope = mapper.readValue(root.get("dictionaryFields").toString(),
- DescriptiveScope.class);
+ descriptiveScope = mapper.readValue(root.get("dictionaryFields").toString(), DescriptiveScope.class);
data = mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
userId = "API";
} else {
descriptiveScope =
- mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(),
- DescriptiveScope.class);
- data = mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(),
- GridData.class);
+ mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), DescriptiveScope.class);
+ data = mapper.readValue(root.get("descriptiveScopeDictionaryData").toString(), GridData.class);
userId = root.get("userid").textValue();
}
descriptiveScope.setSearch(utils.appendKeyValue(data.getAttributes(), "AND", ":"));
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- descriptiveScope.getScopeName(), dScopeName, DescriptiveScope.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(descriptiveScope.getScopeName(), dScopeName,
+ DescriptiveScope.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
DescriptiveScope data1 = (DescriptiveScope) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
descriptiveScope.setId(data1.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data1.getId() != descriptiveScope.getId()))) {
+ || (request.getParameter(operation) == null && (data1.getId() != descriptiveScope.getId()))) {
duplicateflag = true;
}
}
@@ -132,8 +133,7 @@ public class DescriptiveDictionaryController {
descriptiveScope.setModifiedDate(new Date());
commonClassDao.update(descriptiveScope);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(DescriptiveScope.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(DescriptiveScope.class));
} else {
responseString = "Duplicate";
}
@@ -148,10 +148,9 @@ public class DescriptiveDictionaryController {
return null;
}
- @RequestMapping(value = {"/descriptive_dictionary/remove_descriptiveScope"},
- method = {RequestMethod.POST})
- public void removeDescriptiveDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/descriptive_dictionary/remove_descriptiveScope"}, method = {RequestMethod.POST})
+ public void removeDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, descriptiveDatas, DescriptiveScope.class);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
index 94275e7c1..2c0278ed5 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryController.java
@@ -23,11 +23,14 @@ 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 java.io.IOException;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
@@ -52,7 +55,7 @@ public class DictionaryController {
private static String operation = "operation";
private static String dictionaryFields = "dictionaryFields";
private static String duplicateResponseString = "Duplicate";
- private static String onapName = "onapName";
+ private static String onapName = "name";
private static String attributeDatas = "attributeDictionaryDatas";
private static String onapNameDatas = "onapNameDictionaryDatas";
@@ -69,7 +72,9 @@ public class DictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_AttributeDatabyAttributeName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_AttributeDatabyAttributeName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getAttributeDictionaryEntityDatabyAttributeName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -77,7 +82,9 @@ public class DictionaryController {
}
// Attribute Dictionary
- @RequestMapping(value = "/get_AttributeData", method = RequestMethod.GET,
+ @RequestMapping(
+ value = "/get_AttributeData",
+ method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public void getAttributeDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -85,8 +92,8 @@ public class DictionaryController {
}
@RequestMapping(value = {"/attribute_dictionary/save_attribute"}, method = {RequestMethod.POST})
- public ModelAndView saveAttributeDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -97,38 +104,33 @@ public class DictionaryController {
AttributeValues attributeValueData = null;
String userId = null;
if (fromAPI) {
- attributeData =
- mapper.readValue(root.get(dictionaryFields).toString(), Attribute.class);
- attributeValueData = mapper.readValue(root.get(dictionaryFields).toString(),
- AttributeValues.class);
+ attributeData = mapper.readValue(root.get(dictionaryFields).toString(), Attribute.class);
+ attributeValueData = mapper.readValue(root.get(dictionaryFields).toString(), AttributeValues.class);
userId = "API";
} else {
- attributeData = mapper.readValue(root.get("attributeDictionaryData").toString(),
- Attribute.class);
- attributeValueData = mapper.readValue(
- root.get("attributeDictionaryData").toString(), AttributeValues.class);
+ attributeData = mapper.readValue(root.get("attributeDictionaryData").toString(), Attribute.class);
+ attributeValueData =
+ mapper.readValue(root.get("attributeDictionaryData").toString(), AttributeValues.class);
userId = root.get("userid").textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao
- .checkDuplicateEntry(attributeData.getXacmlId(), xacmlId, Attribute.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(attributeData.getXacmlId(), xacmlId, Attribute.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
Attribute data = (Attribute) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
attributeData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != attributeData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != attributeData.getId()))) {
duplicateflag = true;
}
}
if (attributeValueData.getUserDataTypeValues() != null
&& !attributeValueData.getUserDataTypeValues().isEmpty()) {
- attributeData.setAttributeValue(utils.appendKey(
- attributeValueData.getUserDataTypeValues(), "attributeValues", ","));
+ attributeData.setAttributeValue(
+ utils.appendKey(attributeValueData.getUserDataTypeValues(), "attributeValues", ","));
}
if (attributeData.getDatatypeBean().getShortName() != null) {
@@ -162,16 +164,16 @@ public class DictionaryController {
return null;
}
- @RequestMapping(value = {"/attribute_dictionary/remove_attribute"},
- method = {RequestMethod.POST})
- public void removeAttributeDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ @RequestMapping(value = {"/attribute_dictionary/remove_attribute"}, method = {RequestMethod.POST})
+ public void removeAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, attributeDatas, Attribute.class);
}
// OnapName Dictionary
- @RequestMapping(value = {"/get_OnapNameDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_OnapNameDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getOnapNameDictionaryByNameEntityData(HttpServletResponse response) {
LOGGER.info("get_OnapNameDataByName is called");
@@ -179,7 +181,9 @@ public class DictionaryController {
utils.getDataByEntity(response, onapNameDatas, onapName, OnapName.class);
}
- @RequestMapping(value = {"/get_OnapNameData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_OnapNameData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getOnapNameDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -201,24 +205,21 @@ public class DictionaryController {
onapData = mapper.readValue(root.get(dictionaryFields).toString(), OnapName.class);
userId = "API";
} else {
- onapData = mapper.readValue(root.get("onapNameDictionaryData").toString(),
- OnapName.class);
+ onapData = mapper.readValue(root.get("onapNameDictionaryData").toString(), OnapName.class);
userId = root.get("userid").textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(onapData.getOnapName(),
- onapName, OnapName.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(onapData.getName(), onapName, OnapName.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
OnapName data = (OnapName) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
onapData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != onapData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != onapData.getId()))) {
duplicateflag = true;
}
}
@@ -248,8 +249,7 @@ public class DictionaryController {
}
@RequestMapping(value = {"/onap_dictionary/remove_onap"}, method = {RequestMethod.POST})
- public void removeOnapDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, onapNameDatas, OnapName.class);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
index b42731d61..029582213 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java
@@ -21,16 +21,20 @@
package org.onap.policy.pap.xacml.rest.controller;
import au.com.bytecode.opencsv.CSVReader;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.compress.utils.IOUtils;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -40,9 +44,9 @@ import org.onap.policy.rest.jpa.ActionList;
import org.onap.policy.rest.jpa.ActionPolicyDict;
import org.onap.policy.rest.jpa.AddressGroup;
import org.onap.policy.rest.jpa.Attribute;
-import org.onap.policy.rest.jpa.BRMSController;
-import org.onap.policy.rest.jpa.BRMSDependency;
-import org.onap.policy.rest.jpa.BRMSParamTemplate;
+import org.onap.policy.rest.jpa.BrmsController;
+import org.onap.policy.rest.jpa.BrmsDependency;
+import org.onap.policy.rest.jpa.BrmsParamTemplate;
import org.onap.policy.rest.jpa.Category;
import org.onap.policy.rest.jpa.ClosedLoopD2Services;
import org.onap.policy.rest.jpa.ClosedLoopSite;
@@ -52,15 +56,15 @@ import org.onap.policy.rest.jpa.DescriptiveScope;
import org.onap.policy.rest.jpa.GroupServiceList;
import org.onap.policy.rest.jpa.MicroServiceModels;
import org.onap.policy.rest.jpa.OnapName;
-import org.onap.policy.rest.jpa.PEPOptions;
+import org.onap.policy.rest.jpa.PepOptions;
import org.onap.policy.rest.jpa.PrefixList;
import org.onap.policy.rest.jpa.ProtocolList;
import org.onap.policy.rest.jpa.SecurityZone;
import org.onap.policy.rest.jpa.ServiceList;
import org.onap.policy.rest.jpa.TermList;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.jpa.VNFType;
-import org.onap.policy.rest.jpa.VSCLAction;
+import org.onap.policy.rest.jpa.VnfType;
+import org.onap.policy.rest.jpa.VsclAction;
import org.onap.policy.rest.jpa.VarbindDictionary;
import org.onap.policy.rest.jpa.Zone;
import org.springframework.beans.factory.annotation.Autowired;
@@ -68,7 +72,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-
@Controller
public class DictionaryImportController {
private static final Logger LOGGER = FlexLogger.getLogger(DictionaryImportController.class);
@@ -92,8 +95,7 @@ public class DictionaryImportController {
}
@RequestMapping(value = {"/dictionary/import_dictionary"}, method = {RequestMethod.POST})
- public void importDictionaryData(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void importDictionaryData(HttpServletRequest request, HttpServletResponse response) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String userId = request.getParameter("userId");
@@ -211,7 +213,7 @@ public class DictionaryImportController {
for (int j = 0; j < rows.length; j++) {
if ("onap_name".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Onap Name".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setOnapName(rows[j]);
+ attribute.setName(rows[j]);
}
if (DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setDescription(rows[j]);
@@ -250,10 +252,10 @@ public class DictionaryImportController {
attribute.setEnumValues(rows[j]);
}
if ("Ref Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setRef_attributes(rows[j]);
+ attribute.setRefAttributes(rows[j]);
}
if ("Sub Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setSub_attributes(rows[j]);
+ attribute.setSubAttributes(rows[j]);
}
if ("annotations".equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setAnnotation(rows[j]);
@@ -273,8 +275,7 @@ public class DictionaryImportController {
String[] rows = dictSheet.get(i);
for (int j = 0; j < rows.length; j++) {
if ("modelName".equalsIgnoreCase(dictSheet.get(0)[j])
- || "Optimization Service Model"
- .equalsIgnoreCase(dictSheet.get(0)[j])) {
+ || "Optimization Service Model".equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setModelName(rows[j]);
}
if ("version".equalsIgnoreCase(dictSheet.get(0)[j])
@@ -294,10 +295,10 @@ public class DictionaryImportController {
attribute.setEnumValues(rows[j]);
}
if ("Ref Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setRef_attributes(rows[j]);
+ attribute.setRefAttributes(rows[j]);
}
if ("Sub Attributes".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setSub_attributes(rows[j]);
+ attribute.setSubAttributes(rows[j]);
}
if ("annotations".equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setAnnotation(rows[j]);
@@ -310,7 +311,7 @@ public class DictionaryImportController {
if (dictionaryName.startsWith("VNFType")) {
for (int i = 1; i < dictSheet.size(); i++) {
- VNFType attribute = new VNFType();
+ VnfType attribute = new VnfType();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -319,7 +320,7 @@ public class DictionaryImportController {
for (int j = 0; j < rows.length; j++) {
if ("vnf_type".equalsIgnoreCase(dictSheet.get(0)[j])
|| "VNF Type".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setVnftype(rows[j]);
+ attribute.setType(rows[j]);
}
if (DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setDescription(rows[j]);
@@ -330,7 +331,7 @@ public class DictionaryImportController {
}
if (dictionaryName.startsWith("VSCLAction")) {
for (int i = 1; i < dictSheet.size(); i++) {
- VSCLAction attribute = new VSCLAction();
+ VsclAction attribute = new VsclAction();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -339,7 +340,7 @@ public class DictionaryImportController {
for (int j = 0; j < rows.length; j++) {
if ("vscl_action".equalsIgnoreCase(dictSheet.get(0)[j])
|| "VSCL Action".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setVsclaction(rows[j]);
+ attribute.setAction(rows[j]);
}
if (DESCRIPTION.equalsIgnoreCase(dictSheet.get(0)[j])) {
attribute.setDescription(rows[j]);
@@ -388,9 +389,9 @@ public class DictionaryImportController {
commonClassDao.save(attribute);
}
}
- if (dictionaryName.startsWith("PEPOptions")) {
+ if (dictionaryName.startsWith("PepOptions")) {
for (int i = 1; i < dictSheet.size(); i++) {
- PEPOptions attribute = new PEPOptions();
+ PepOptions attribute = new PepOptions();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -430,7 +431,7 @@ public class DictionaryImportController {
}
if ("varbind_oid".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Varbind OID".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setVarbindOID(rows[j]);
+ attribute.setVarbindOid(rows[j]);
}
}
commonClassDao.save(attribute);
@@ -438,7 +439,7 @@ public class DictionaryImportController {
}
if (dictionaryName.startsWith("BRMSParamDictionary")) {
for (int i = 1; i < dictSheet.size(); i++) {
- BRMSParamTemplate attribute = new BRMSParamTemplate();
+ BrmsParamTemplate attribute = new BrmsParamTemplate();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -460,7 +461,7 @@ public class DictionaryImportController {
}
if (dictionaryName.startsWith("BRMSControllerDictionary")) {
for (int i = 1; i < dictSheet.size(); i++) {
- BRMSController attribute = new BRMSController();
+ BrmsController attribute = new BrmsController();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -482,7 +483,7 @@ public class DictionaryImportController {
}
if (dictionaryName.startsWith("BRMSDependencyDictionary")) {
for (int i = 1; i < dictSheet.size(); i++) {
- BRMSDependency attribute = new BRMSDependency();
+ BrmsDependency attribute = new BrmsDependency();
UserInfo userinfo = new UserInfo();
userinfo.setUserLoginId(userId);
attribute.setUserCreatedBy(userinfo);
@@ -614,7 +615,7 @@ public class DictionaryImportController {
}
if ("serviceTrasProtocol".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Transport Protocol".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setServiceTransProtocol(rows[j]);
+ attribute.setServiceTransportProtocol(rows[j]);
}
if ("serviceAppProtocol".equalsIgnoreCase(dictSheet.get(0)[j])
|| "APP Protocol".equalsIgnoreCase(dictSheet.get(0)[j])) {
@@ -716,19 +717,19 @@ public class DictionaryImportController {
}
if ("fromZone".equalsIgnoreCase(dictSheet.get(0)[j])
|| "From Zone".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setFromZones(rows[j]);
+ attribute.setFromZone(rows[j]);
}
if ("toZone".equalsIgnoreCase(dictSheet.get(0)[j])
|| "To Zone".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setToZones(rows[j]);
+ attribute.setToZone(rows[j]);
}
if ("srcIPList".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Source-IP-List".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setSrcIPList(rows[j]);
+ attribute.setSrcIpList(rows[j]);
}
if ("destIPList".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Destination-IP-List".equalsIgnoreCase(dictSheet.get(0)[j])) {
- attribute.setDestIPList(rows[j]);
+ attribute.setDestIpList(rows[j]);
}
if ("srcPortList".equalsIgnoreCase(dictSheet.get(0)[j])
|| "Source-Port-List".equalsIgnoreCase(dictSheet.get(0)[j])) {
@@ -800,7 +801,7 @@ public class DictionaryImportController {
case VSCLAction:
case ClosedLoopService:
case ClosedLoopSite:
- case PEPOptions:
+ case PepOptions:
case VarbindDictionary:
case BRMSParamDictionary:
case BRMSControllerDictionary:
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
index 7cf12043c..3c3cbac30 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
@@ -23,13 +23,16 @@ 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 java.io.IOException;
import java.io.PrintWriter;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.jboss.netty.handler.ipfilter.CIDR;
import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -39,8 +42,8 @@ import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionList;
import org.onap.policy.rest.jpa.AddressGroup;
-import org.onap.policy.rest.jpa.FWTag;
-import org.onap.policy.rest.jpa.FWTagPicker;
+import org.onap.policy.rest.jpa.FwTag;
+import org.onap.policy.rest.jpa.FwTagPicker;
import org.onap.policy.rest.jpa.FirewallDictionaryList;
import org.onap.policy.rest.jpa.GroupServiceList;
import org.onap.policy.rest.jpa.PortList;
@@ -58,7 +61,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
-
@Controller
public class FirewallDictionaryController {
@@ -95,7 +97,6 @@ public class FirewallDictionaryController {
private static String fwTagPickerDatas = "fwTagPickerDictionaryDatas";
private static String fwTagDatas = "fwTagDictionaryDatas";
-
@Autowired
public FirewallDictionaryController(CommonClassDao commonClassDao) {
FirewallDictionaryController.commonClassDao = commonClassDao;
@@ -113,14 +114,18 @@ public class FirewallDictionaryController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_PrefixListDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PrefixListDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPrefixListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, pfListDatas, prefixListName, PrefixList.class);
}
- @RequestMapping(value = {"/get_PrefixListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PrefixListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPrefixListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -128,8 +133,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_prefixList"}, method = {RequestMethod.POST})
- public ModelAndView savePrefixListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -138,25 +143,21 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PrefixList prefixList;
if (fromAPI) {
- prefixList =
- mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
+ prefixList = mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
} else {
- prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(),
- PrefixList.class);
+ prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- prefixList.getPrefixListName(), prefixListName, PrefixList.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(),
+ prefixListName, PrefixList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PrefixList data = (PrefixList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
prefixList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != prefixList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != prefixList.getId()))) {
duplicateflag = true;
}
}
@@ -167,8 +168,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(prefixList);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
} else {
responseString = duplicateResponseString;
}
@@ -191,15 +191,14 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/validate_prefixList"}, method = {RequestMethod.POST})
- public void validatePrefixListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PrefixList prefixList = mapper
- .readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
+ PrefixList prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
String responseValidation = successMessage;
try {
CIDR.newCIDR(prefixList.getPrefixListValue());
@@ -219,7 +218,9 @@ public class FirewallDictionaryController {
}
}
- @RequestMapping(value = {"/get_PortListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PortListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPortListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -227,8 +228,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_portName"}, method = {RequestMethod.POST})
- public ModelAndView savePortListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -239,21 +240,18 @@ public class FirewallDictionaryController {
if (fromAPI) {
portList = mapper.readValue(root.get(dictionaryFields).toString(), PortList.class);
} else {
- portList = mapper.readValue(root.get("portListDictionaryData").toString(),
- PortList.class);
+ portList = mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(),
- "portName", PortList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PortList data = (PortList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
portList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != portList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != portList.getId()))) {
duplicateflag = true;
}
}
@@ -280,20 +278,23 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_PortList"}, method = {RequestMethod.POST})
- public void removePortListDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, portListDatas, PortList.class);
}
- @RequestMapping(value = {"/get_ProtocolListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ProtocolListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getProtocolListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, protocolListDatas, ProtocolList.class);
}
- @RequestMapping(value = {"/get_ProtocolListDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ProtocolListDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getProtocolListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -301,8 +302,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_protocolList"}, method = {RequestMethod.POST})
- public ModelAndView saveProtocolListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -311,24 +312,20 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
ProtocolList protocolList;
if (fromAPI) {
- protocolList =
- mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
+ protocolList = mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
} else {
- protocolList = mapper.readValue(root.get("protocolListDictionaryData").toString(),
- ProtocolList.class);
+ protocolList = mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- protocolList.getProtocolName(), protocolName, ProtocolList.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(),
+ protocolName, ProtocolList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
ProtocolList data = (ProtocolList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
protocolList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != protocolList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != protocolList.getId()))) {
duplicateflag = true;
}
}
@@ -339,8 +336,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(protocolList);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
} else {
responseString = duplicateResponseString;
}
@@ -356,20 +352,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_protocol"}, method = {RequestMethod.POST})
- public void removeProtocolListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, protocolListDatas, ProtocolList.class);
}
- @RequestMapping(value = {"/get_AddressGroupDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_AddressGroupDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getAddressGroupDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, addressGroupDatas, "name", AddressGroup.class);
}
- @RequestMapping(value = {"/get_AddressGroupData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_AddressGroupData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getAddressGroupDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -377,8 +377,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_addressGroup"}, method = {RequestMethod.POST})
- public ModelAndView saveAddressGroupDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -388,32 +388,27 @@ public class FirewallDictionaryController {
AddressGroup addressGroup;
GridData gridData;
if (fromAPI) {
- addressGroup =
- mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
+ addressGroup = mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
} else {
- addressGroup = mapper.readValue(root.get("addressGroupDictionaryData").toString(),
- AddressGroup.class);
- gridData = mapper.readValue(root.get("addressGroupDictionaryData").toString(),
- GridData.class);
+ addressGroup = mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
+ gridData = mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
}
if (!addressGroup.getGroupName().startsWith(groupNameStart)) {
String groupName = groupNameStart + addressGroup.getGroupName();
addressGroup.setGroupName(groupName);
}
addressGroup.setServiceList(utils.appendKey(gridData.getAttributes(), option, ","));
- List<Object> duplicateData = commonClassDao
- .checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
AddressGroup data = (AddressGroup) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
addressGroup.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != addressGroup.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != addressGroup.getId()))) {
duplicateflag = true;
}
}
@@ -424,8 +419,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(addressGroup);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
} else {
responseString = duplicateResponseString;
}
@@ -441,20 +435,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_AddressGroup"}, method = {RequestMethod.POST})
- public void removeAddressGroupDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, addressGroupDatas, AddressGroup.class);
}
- @RequestMapping(value = {"/get_ActionListDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ActionListDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getActionListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, actionListDatas, "actionName", ActionList.class);
}
- @RequestMapping(value = {"/get_ActionListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ActionListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getActionListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -462,8 +460,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_ActionList"}, method = {RequestMethod.POST})
- public ModelAndView saveActionListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -472,24 +470,20 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
ActionList actionList;
if (fromAPI) {
- actionList =
- mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
+ actionList = mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
} else {
- actionList = mapper.readValue(root.get("actionListDictionaryData").toString(),
- ActionList.class);
+ actionList = mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- actionList.getActionName(), "actionName", ActionList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
ActionList data = (ActionList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
actionList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != actionList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != actionList.getId()))) {
duplicateflag = true;
}
}
@@ -500,8 +494,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(actionList);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
} else {
responseString = duplicateResponseString;
}
@@ -523,14 +516,18 @@ public class FirewallDictionaryController {
utils.removeData(request, response, actionListDatas, ActionList.class);
}
- @RequestMapping(value = {"/get_ServiceGroupData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ServiceGroupData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getServiceGroupDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, serviceGroupDatas, GroupServiceList.class);
}
- @RequestMapping(value = {"/get_ServiceGroupDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ServiceGroupDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getServiceGroupDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -538,8 +535,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_serviceGroup"}, method = {RequestMethod.POST})
- public ModelAndView saveServiceGroupDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -549,32 +546,28 @@ public class FirewallDictionaryController {
GroupServiceList groupServiceList;
GridData gridData;
if (fromAPI) {
- groupServiceList = mapper.readValue(root.get(dictionaryFields).toString(),
- GroupServiceList.class);
+ groupServiceList = mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
} else {
- groupServiceList = mapper.readValue(
- root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
- gridData = mapper.readValue(root.get("serviceGroupDictionaryData").toString(),
- GridData.class);
+ groupServiceList =
+ mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
+ gridData = mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
}
if (!groupServiceList.getGroupName().startsWith(groupNameStart)) {
String groupName = groupNameStart + groupServiceList.getGroupName();
groupServiceList.setGroupName(groupName);
}
groupServiceList.setServiceList(utils.appendKey(gridData.getAttributes(), option, ","));
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- groupServiceList.getGroupName(), "name", GroupServiceList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
GroupServiceList data = (GroupServiceList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
groupServiceList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != groupServiceList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != groupServiceList.getId()))) {
duplicateflag = true;
}
}
@@ -585,8 +578,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(groupServiceList);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
} else {
responseString = duplicateResponseString;
}
@@ -602,20 +594,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_serviceGroup"}, method = {RequestMethod.POST})
- public void removeServiceGroupDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, serviceGroupDatas, GroupServiceList.class);
}
- @RequestMapping(value = {"/get_SecurityZoneDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SecurityZoneDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getSecurityZoneDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, securityZoneDatas, zoneName, SecurityZone.class);
}
- @RequestMapping(value = {"/get_SecurityZoneData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SecurityZoneData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getSecurityZoneDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -623,8 +619,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_securityZone"}, method = {RequestMethod.POST})
- public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -633,24 +629,20 @@ public class FirewallDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
SecurityZone securityZone;
if (fromAPI) {
- securityZone =
- mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
+ securityZone = mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
} else {
- securityZone = mapper.readValue(root.get("securityZoneDictionaryData").toString(),
- SecurityZone.class);
+ securityZone = mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
}
- List<Object> duplicateData = commonClassDao
- .checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
SecurityZone data = (SecurityZone) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
securityZone.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != securityZone.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != securityZone.getId()))) {
duplicateflag = true;
}
}
@@ -661,8 +653,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(securityZone);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
} else {
responseString = duplicateResponseString;
}
@@ -678,21 +669,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_securityZone"}, method = {RequestMethod.POST})
- public void removeSecurityZoneDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, securityZoneDatas, SecurityZone.class);
}
-
- @RequestMapping(value = {"/get_ServiceListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ServiceListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getServiceListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, serviceListDatas, ServiceList.class);
}
- @RequestMapping(value = {"/get_ServiceListDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ServiceListDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getServiceListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -700,8 +694,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_serviceList"}, method = {RequestMethod.POST})
- public ModelAndView saveServiceListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -711,33 +705,27 @@ public class FirewallDictionaryController {
ServiceList serviceList;
GridData serviceListGridData;
if (fromAPI) {
- serviceList =
- mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
- serviceListGridData =
- mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+ serviceList = mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
+ serviceListGridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
} else {
- serviceList = mapper.readValue(root.get("serviceListDictionaryData").toString(),
- ServiceList.class);
- serviceListGridData = mapper.readValue(
- root.get("serviceListDictionaryData").toString(), GridData.class);
+ serviceList = mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
+ serviceListGridData =
+ mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
}
- serviceList.setServiceTransProtocol(
- utils.appendKey(serviceListGridData.getTransportProtocols(), option, ","));
- serviceList.setServiceAppProtocol(
- utils.appendKey(serviceListGridData.getAppProtocols(), option, ","));
+ serviceList
+ .setServiceTransportProtocol(utils.appendKey(serviceListGridData.getTransportProtocols(), option, ","));
+ serviceList.setServiceAppProtocol(utils.appendKey(serviceListGridData.getAppProtocols(), option, ","));
serviceList.setServiceType("SERVICE");
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- serviceList.getServiceName(), serviceName, ServiceList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
ServiceList data = (ServiceList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
serviceList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != serviceList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != serviceList.getId()))) {
duplicateflag = true;
}
}
@@ -748,8 +736,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(serviceList);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
} else {
responseString = duplicateResponseString;
}
@@ -765,20 +752,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_serviceList"}, method = {RequestMethod.POST})
- public void removeServiceListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, serviceListDatas, ServiceList.class);
}
- @RequestMapping(value = {"/get_ZoneData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ZoneData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getZoneDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, zoneDatas, Zone.class);
}
- @RequestMapping(value = {"/get_ZoneDictionaryDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_ZoneDictionaryDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getZoneDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -800,18 +791,15 @@ public class FirewallDictionaryController {
} else {
zone = mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
}
- List<Object> duplicateData =
- commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
Zone data = (Zone) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
zone.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != zone.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != zone.getId()))) {
duplicateflag = true;
}
}
@@ -838,20 +826,23 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_zone"}, method = {RequestMethod.POST})
- public void removeZoneDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, zoneDatas, Zone.class);
}
- @RequestMapping(value = {"/get_TermListDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TermListDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTermListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, termListDictDatas, termName, TermList.class);
}
- @RequestMapping(value = {"/get_TermListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TermListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTermListDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -859,8 +850,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_termList"}, method = {RequestMethod.POST})
- public ModelAndView saveTermListDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -872,41 +863,33 @@ public class FirewallDictionaryController {
String userId = null;
if (fromAPI) {
termList = mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
- termListDatas =
- mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
+ termListDatas = mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
userId = "API";
} else {
- termList = mapper.readValue(root.get("termListDictionaryData").toString(),
- TermList.class);
- termListDatas = mapper.readValue(root.get("termListDictionaryData").toString(),
- TermListData.class);
+ termList = mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
+ termListDatas = mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
userId = root.get(userid).textValue();
}
- termList.setFromZones(utils.appendKey(termListDatas.getFromZoneDatas(), option, ","));
- termList.setToZones(utils.appendKey(termListDatas.getToZoneDatas(), option, ","));
- termList.setSrcIPList(utils.appendKey(termListDatas.getSourceListDatas(), option, ","));
- termList.setDestIPList(
- utils.appendKey(termListDatas.getDestinationListDatas(), option, ","));
- termList.setSrcPortList(
- utils.appendKey(termListDatas.getSourceServiceDatas(), option, ","));
- termList.setDestPortList(
- utils.appendKey(termListDatas.getDestinationServiceDatas(), option, ","));
+ termList.setFromZone(utils.appendKey(termListDatas.getFromZoneDatas(), option, ","));
+ termList.setToZone(utils.appendKey(termListDatas.getToZoneDatas(), option, ","));
+ termList.setSrcIpList(utils.appendKey(termListDatas.getSourceListDatas(), option, ","));
+ termList.setDestIpList(utils.appendKey(termListDatas.getDestinationListDatas(), option, ","));
+ termList.setSrcPortList(utils.appendKey(termListDatas.getSourceServiceDatas(), option, ","));
+ termList.setDestPortList(utils.appendKey(termListDatas.getDestinationServiceDatas(), option, ","));
termList.setAction(utils.appendKey(termListDatas.getActionListDatas(), option, ","));
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(),
- termName, TermList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
TermList data = (TermList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
termList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != termList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != termList.getId()))) {
duplicateflag = true;
}
}
@@ -936,22 +919,24 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_termList"}, method = {RequestMethod.POST})
- public void removeTermListDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, termListDictDatas, TermList.class);
}
// ParentList Dictionary Data
- @RequestMapping(value = {"/get_FWDictionaryListDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_FWDictionaryListDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getFWDictListDictionaryEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, fwDictListDatas, "parentItemName",
- FirewallDictionaryList.class);
+ utils.getDataByEntity(response, fwDictListDatas, "parentItemName", FirewallDictionaryList.class);
}
- @RequestMapping(value = {"/get_FWDictionaryListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_FWDictionaryListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getFWDictionaryListEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -959,8 +944,8 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/save_FWDictionaryList"}, method = {RequestMethod.POST})
- public ModelAndView saveFWDictionaryList(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -970,31 +955,27 @@ public class FirewallDictionaryController {
FirewallDictionaryList fwDictList;
GridData gridData;
if (fromAPI) {
- fwDictList = mapper.readValue(root.get(dictionaryFields).toString(),
- FirewallDictionaryList.class);
+ fwDictList = mapper.readValue(root.get(dictionaryFields).toString(), FirewallDictionaryList.class);
gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
} else {
- fwDictList = mapper.readValue(root.get("fwDictListDictionaryData").toString(),
- FirewallDictionaryList.class);
- gridData = mapper.readValue(root.get("fwDictListDictionaryData").toString(),
- GridData.class);
+ fwDictList =
+ mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
+ gridData = mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
}
fwDictList.setServiceList(utils.appendKey(gridData.getAttributes(), option, ","));
fwDictList.setAddressList(utils.appendKey(gridData.getAlAttributes(), option, ","));
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(),
+ "parentItemName", FirewallDictionaryList.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
FirewallDictionaryList data = (FirewallDictionaryList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
fwDictList.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != fwDictList.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != fwDictList.getId()))) {
duplicateflag = true;
}
}
@@ -1005,8 +986,7 @@ public class FirewallDictionaryController {
} else {
commonClassDao.update(fwDictList);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
} else {
responseString = duplicateResponseString;
}
@@ -1021,69 +1001,65 @@ public class FirewallDictionaryController {
return null;
}
- @RequestMapping(value = {"/fw_dictionary/remove_FWDictionaryList"},
- method = {RequestMethod.POST})
- public void removeFWDictionaryList(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ @RequestMapping(value = {"/fw_dictionary/remove_FWDictionaryList"}, method = {RequestMethod.POST})
+ public void removeFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, fwDictListDatas, FirewallDictionaryList.class);
}
-
- @RequestMapping(value = {"/get_TagPickerNameByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TagPickerNameByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTagPickerNameEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, fwTagPickerDatas, tagPickerName, FWTagPicker.class);
+ utils.getDataByEntity(response, fwTagPickerDatas, tagPickerName, FwTagPicker.class);
}
- @RequestMapping(value = {"/get_TagPickerListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TagPickerListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTagPickerDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, fwTagPickerDatas, FWTagPicker.class);
+ utils.getData(response, fwTagPickerDatas, FwTagPicker.class);
}
@RequestMapping(value = {"/fw_dictionary/save_fwTagPicker"}, method = {RequestMethod.POST})
- public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveFirewallTagPickerDictionary(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());
- FWTagPicker fwTagPicker;
+ FwTagPicker fwTagPicker;
TagGridValues data;
String userId = "";
if (fromAPI) {
- fwTagPicker =
- mapper.readValue(root.get(dictionaryFields).toString(), FWTagPicker.class);
+ fwTagPicker = mapper.readValue(root.get(dictionaryFields).toString(), FwTagPicker.class);
data = mapper.readValue(root.get(dictionaryFields).toString(), TagGridValues.class);
userId = "API";
} else {
- fwTagPicker = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(),
- FWTagPicker.class);
- data = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(),
- TagGridValues.class);
+ fwTagPicker = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FwTagPicker.class);
+ data = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
userId = root.get(userid).textValue();
}
fwTagPicker.setTagValues(utils.appendKeyValue(data.getTags(), "#", ":"));
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(),
+ tagPickerName, FwTagPicker.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- FWTagPicker data1 = (FWTagPicker) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ FwTagPicker data1 = (FwTagPicker) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
fwTagPicker.setId(data1.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data1.getId() != fwTagPicker.getId()))) {
+ || (request.getParameter(operation) == null && (data1.getId() != fwTagPicker.getId()))) {
duplicateflag = true;
}
}
@@ -1097,8 +1073,7 @@ public class FirewallDictionaryController {
fwTagPicker.setModifiedDate(new Date());
commonClassDao.update(fwTagPicker);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(FwTagPicker.class));
} else {
responseString = duplicateResponseString;
}
@@ -1114,65 +1089,64 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_tagPicker"}, method = {RequestMethod.POST})
- public void removeFirewallTagPickerDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, fwTagPickerDatas, FWTagPicker.class);
+ utils.removeData(request, response, fwTagPickerDatas, FwTagPicker.class);
}
- @RequestMapping(value = {"/get_TagListData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TagListData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTagDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getData(response, fwTagDatas, FWTag.class);
+ utils.getData(response, fwTagDatas, FwTag.class);
}
- @RequestMapping(value = {"/get_TagNameByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_TagNameByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getTagNameEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.getDataByEntity(response, fwTagDatas, "fwTagName", FWTag.class);
+ utils.getDataByEntity(response, fwTagDatas, "fwTagName", FwTag.class);
}
-
@RequestMapping(value = {"/fw_dictionary/save_fwTag"}, method = {RequestMethod.POST})
- public ModelAndView saveFirewallTagDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveFirewallTagDictionary(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());
- FWTag fwTag;
+ FwTag fwTag;
TagGridValues tagGridValues;
String userId = "";
if (fromAPI) {
- fwTag = mapper.readValue(root.get(dictionaryFields).toString(), FWTag.class);
- tagGridValues = mapper.readValue(root.get(dictionaryFields).toString(),
- TagGridValues.class);
+ fwTag = mapper.readValue(root.get(dictionaryFields).toString(), FwTag.class);
+ tagGridValues = mapper.readValue(root.get(dictionaryFields).toString(), TagGridValues.class);
userId = "API";
} else {
- fwTag = mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
- tagGridValues = mapper.readValue(root.get("fwTagDictionaryData").toString(),
- TagGridValues.class);
+ fwTag = mapper.readValue(root.get("fwTagDictionaryData").toString(), FwTag.class);
+ tagGridValues = mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
userId = root.get(userid).textValue();
}
fwTag.setTagValues(utils.appendKey(tagGridValues.getTags(), "tags", ","));
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(),
- "fwTagName", FWTag.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FwTag.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
- FWTag data = (FWTag) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ FwTag data = (FwTag) duplicateData.get(0);
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
fwTag.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != fwTag.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != fwTag.getId()))) {
duplicateflag = true;
}
}
@@ -1186,7 +1160,7 @@ public class FirewallDictionaryController {
fwTag.setModifiedDate(new Date());
commonClassDao.update(fwTag);
}
- responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(FwTag.class));
} else {
responseString = duplicateResponseString;
}
@@ -1202,10 +1176,10 @@ public class FirewallDictionaryController {
}
@RequestMapping(value = {"/fw_dictionary/remove_tagList"}, method = {RequestMethod.POST})
- public void removeFirewallTagDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
- utils.removeData(request, response, fwTagDatas, FWTag.class);
+ utils.removeData(request, response, fwTagDatas, FwTag.class);
}
}
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 ee274d2a7..566ac1447 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
@@ -24,6 +24,7 @@ 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;
@@ -32,8 +33,10 @@ 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;
@@ -42,7 +45,7 @@ import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
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.DcaeUuid;
import org.onap.policy.rest.jpa.DictionaryData;
import org.onap.policy.rest.jpa.MicroServiceAttribute;
import org.onap.policy.rest.jpa.MicroServiceConfigName;
@@ -51,8 +54,8 @@ import org.onap.policy.rest.jpa.MicroServiceModels;
import org.onap.policy.rest.jpa.MicroserviceHeaderdeFaults;
import org.onap.policy.rest.jpa.PrefixList;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@@ -72,11 +75,9 @@ public class MicroServiceDictionaryController {
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 update = "update";
private static String duplicateResponseString = "Duplicate";
private static String microServiceModelsDictionaryDatas = "microServiceModelsDictionaryDatas";
private static String modelName = "modelName";
@@ -108,22 +109,26 @@ public class MicroServiceDictionaryController {
MicroServiceDictionaryController.commonClassDao = commonClassDao;
}
- MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+ MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
private MicroServiceModels newModel;
- @RequestMapping(value = {"/get_DCAEUUIDDataByName"}, method = {RequestMethod.GET},
+ @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);
+ utils.getDataByEntity(response, dcaeUUIDDatas, "name", DcaeUuid.class);
}
- @RequestMapping(value = {"/get_DCAEUUIDData"}, method = {RequestMethod.GET},
+ @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);
+ utils.getData(response, dcaeUUIDDatas, DcaeUuid.class);
}
@RequestMapping(value = {"/ms_dictionary/save_dcaeUUID"}, method = {RequestMethod.POST})
@@ -135,17 +140,17 @@ public class MicroServiceDictionaryController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- DCAEuuid dCAEuuid;
+ DcaeUuid dCAEuuid;
if (fromAPI) {
- dCAEuuid = mapper.readValue(root.get(dictionaryFields).toString(), DCAEuuid.class);
+ dCAEuuid = mapper.readValue(root.get(dictionaryFields).toString(), DcaeUuid.class);
} else {
- dCAEuuid = mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DCAEuuid.class);
+ 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()) {
- DCAEuuid data = (DCAEuuid) duplicateData.get(0);
+ DcaeUuid data = (DcaeUuid) duplicateData.get(0);
if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
dCAEuuid.setId(data.getId());
} else if ((request.getParameter(operation) != null
@@ -161,7 +166,7 @@ public class MicroServiceDictionaryController {
} else {
commonClassDao.update(dCAEuuid);
}
- responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(DcaeUuid.class));
} else {
responseString = duplicateResponseString;
}
@@ -179,24 +184,30 @@ public class MicroServiceDictionaryController {
@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);
+ utils.removeData(request, response, dcaeUUIDDatas, DcaeUuid.class);
}
- @RequestMapping(value = {"/get_MicroServiceConfigNameDataByName"}, method = {RequestMethod.GET},
+ @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},
+ @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 = {"/get_MicroServiceDictData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_MicroServiceDictData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceDictNameDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -330,14 +341,18 @@ public class MicroServiceDictionaryController {
utils.removeData(request, response, microServiceConfigNameDatas, MicroServiceConfigName.class);
}
- @RequestMapping(value = {"/get_MicroServiceLocationDataByName"}, method = {RequestMethod.GET},
+ @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},
+ @RequestMapping(
+ value = {"/get_MicroServiceLocationData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceLocationDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -405,14 +420,18 @@ public class MicroServiceDictionaryController {
utils.removeData(request, response, microServiceLocationDatas, MicroServiceLocation.class);
}
- @RequestMapping(value = {"/get_MicroServiceAttributeDataByName"}, method = {RequestMethod.GET},
+ @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},
+ @RequestMapping(
+ value = {"/get_MicroServiceAttributeData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceAttributeDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -483,15 +502,18 @@ public class MicroServiceDictionaryController {
utils.removeData(request, response, microServiceAttributeDatas, MicroServiceAttribute.class);
}
-
- @RequestMapping(value = {"/get_MicroServiceModelsDataByName"}, method = {RequestMethod.GET},
+ @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},
+ @RequestMapping(
+ value = {"/get_MicroServiceModelsDataByVersion"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceModelsDictionaryByVersionEntityData(HttpServletRequest request,
HttpServletResponse response) {
@@ -517,14 +539,18 @@ public class MicroServiceDictionaryController {
}
}
- @RequestMapping(value = {"/get_MicroServiceModelsData"}, method = {RequestMethod.GET},
+ @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},
+ @RequestMapping(
+ value = {"/get_MicroServiceModelsDataServiceVersion"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletResponse response) {
try {
@@ -552,7 +578,9 @@ public class MicroServiceDictionaryController {
}
}
- @RequestMapping(value = {"/get_MicroServiceModelsDataByClass"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_MicroServiceModelsDataByClass"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getMicroServiceModelsDictionaryClassEntityData(HttpServletResponse response) {
try {
@@ -622,15 +650,15 @@ public class MicroServiceDictionaryController {
Set<String> keys = jsonObject.keySet();
for (String key : keys) {
String value = jsonObject.get(key).toString();
- MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+ MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
classMap.put(key, msAttributeObject);
}
userId = root.get("userid").textValue();
- MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+ MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
this.newModel.setDependency("[]");
String value = new Gson().toJson(mainClass.getSubClass());
- this.newModel.setSub_attributes(value);
+ this.newModel.setSubAttributes(value);
String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", "");
int equalsIndexForAttributes = attributes.indexOf('=');
String atttributesAfterFirstEquals = attributes.substring(equalsIndexForAttributes + 1);
@@ -638,7 +666,7 @@ public class MicroServiceDictionaryController {
String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
int equalsIndex = refAttributes.indexOf("=");
String refAttributesAfterFirstEquals = refAttributes.substring(equalsIndex + 1);
- this.newModel.setRef_attributes(refAttributesAfterFirstEquals);
+ this.newModel.setRefAttributes(refAttributesAfterFirstEquals);
this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
this.newModel
.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
@@ -675,7 +703,7 @@ public class MicroServiceDictionaryController {
Set<String> keys = jsonObject.keySet();
for (String key : keys) {
String value = jsonObject.get(key).toString();
- MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
+ MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
classMap.put(key, msAttributeObject);
}
}
@@ -685,10 +713,10 @@ public class MicroServiceDictionaryController {
}
}
microServiceModels.setAttributes(this.newModel.getAttributes());
- microServiceModels.setRef_attributes(this.newModel.getRef_attributes());
+ microServiceModels.setRefAttributes(this.newModel.getRefAttributes());
microServiceModels.setDependency(this.newModel.getDependency());
microServiceModels.setModelName(this.newModel.getModelName());
- microServiceModels.setSub_attributes(this.newModel.getSub_attributes());
+ microServiceModels.setSubAttributes(this.newModel.getSubAttributes());
microServiceModels.setVersion(this.newModel.getVersion());
microServiceModels.setEnumValues(this.newModel.getEnumValues());
microServiceModels.setAnnotation(this.newModel.getAnnotation());
@@ -741,11 +769,11 @@ public class MicroServiceDictionaryController {
utils.removeData(request, response, microServiceModelsDictionaryDatas, MicroServiceModels.class);
}
- private void addValuesToNewModel(HashMap<String, MSAttributeObject> classMap) {
+ 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());
+ MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
if (mainClass != null) {
String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "},
@@ -753,7 +781,7 @@ public class MicroServiceDictionaryController {
ArrayList<String> dependency = new ArrayList<>(Arrays.asList(dependTemp.split(",")));
dependency = getFullDependencyList(dependency);
for (String element : dependency) {
- MSAttributeObject temp = classMap.get(element);
+ MsAttributeObject temp = classMap.get(element);
if (temp != null) {
mainClass.addAllRefAttribute(temp.getRefAttribute());
mainClass.addAllAttribute(temp.getAttribute());
@@ -770,9 +798,9 @@ public class MicroServiceDictionaryController {
}
if (mainClass != null) {
this.newModel.setDependency(mainClass.getDependency());
- this.newModel.setSub_attributes(subAttribute);
+ this.newModel.setSubAttributes(subAttribute);
this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", ""));
- this.newModel.setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
+ this.newModel.setRefAttributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
}
@@ -784,7 +812,7 @@ public class MicroServiceDictionaryController {
returnList.addAll(dependency);
for (String element : dependency) {
if (classMap.containsKey(element)) {
- MSAttributeObject value = classMap.get(element);
+ MsAttributeObject value = classMap.get(element);
String rawValue =
StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""});
workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
@@ -800,21 +828,24 @@ public class MicroServiceDictionaryController {
return returnList;
}
- @RequestMapping(value = {"/get_MicroServiceHeaderDefaultsDataByName"}, method = {RequestMethod.GET},
+ @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},
+ @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 {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java
index 3d1dba905..a24ee0275 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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,8 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
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;
@@ -37,8 +43,8 @@ import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.OptimizationModels;
import org.onap.policy.rest.jpa.UserInfo;
-import org.onap.policy.rest.util.MSAttributeObject;
-import org.onap.policy.rest.util.MSModelUtils;
+import org.onap.policy.rest.util.MsAttributeObject;
+import org.onap.policy.rest.util.MsModelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@@ -46,18 +52,13 @@ 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 OptimizationDictionaryController {
private static CommonClassDao commonClassDao;
private static String operation = "operation";
- private LinkedHashMap<String,MSAttributeObject > classMap;
- private static String dictionaryFields ="dictionaryFields";
+ private LinkedHashMap<String, MsAttributeObject> classMap;
+ private static String dictionaryFields = "dictionaryFields";
private static String duplicateResponseString = "Duplicate";
private static String optimizationModelsDictionaryDatas = "optimizationModelsDictionaryDatas";
private static String modelName = "modelName";
@@ -67,41 +68,48 @@ public class OptimizationDictionaryController {
private static String classMapData = "classMap";
private static final String UPDATE = "update";
-
- public OptimizationDictionaryController(){
+ public OptimizationDictionaryController() {
super();
- }
+ }
- private DictionaryUtils getDictionaryUtilsInstance(){
+ private DictionaryUtils getDictionaryUtilsInstance() {
return DictionaryUtils.getDictionaryUtils();
}
-
+
@Autowired
- public OptimizationDictionaryController(CommonClassDao commonClassDao){
+ public OptimizationDictionaryController(CommonClassDao commonClassDao) {
setCommonClassDao(commonClassDao);
}
+
public static void setCommonClassDao(CommonClassDao commonClassDao) {
OptimizationDictionaryController.commonClassDao = commonClassDao;
}
- MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+ MsModelUtils utils = new MsModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
private OptimizationModels newModel;
- @RequestMapping(value={"/get_OptimizationModelsData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getOptimizationModelsDictionaryEntityData(HttpServletResponse response){
+ @RequestMapping(
+ value = {"/get_OptimizationModelsData"},
+ method = {RequestMethod.GET},
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getOptimizationModelsDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils dUtils = getDictionaryUtilsInstance();
dUtils.getData(response, optimizationModelsDictionaryDatas, OptimizationModels.class);
}
- @RequestMapping(value={"/get_OptimizationModelsDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
- public void getOptimizationModelsDictionaryByNameEntityData(HttpServletResponse response){
+ @RequestMapping(
+ value = {"/get_OptimizationModelsDataByName"},
+ method = {RequestMethod.GET},
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getOptimizationModelsDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils dUtils = getDictionaryUtilsInstance();
dUtils.getDataByEntity(response, optimizationModelsDictionaryDatas, modelName, OptimizationModels.class);
}
- @RequestMapping(value={"/oof_dictionary/save_model"}, method={RequestMethod.POST})
- public ModelAndView saveOptimizationModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+ @RequestMapping(value = {"/oof_dictionary/save_model"}, method = {RequestMethod.POST})
+ public ModelAndView saveOptimizationModelsDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils dUtils = getDictionaryUtilsInstance();
try {
this.newModel = new OptimizationModels();
@@ -113,24 +121,27 @@ public class OptimizationDictionaryController {
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(optimizationModelsDictionaryData)){
- if (root.get(optimizationModelsDictionaryData).has(description)){
- optimizationModels.setDescription(root.get(optimizationModelsDictionaryData).get(description).asText().replace("\"", ""));
+ String modelType = dataType.toString();
+ if (modelType.contains("yml")) {
+ if (root.has(optimizationModelsDictionaryData)) {
+ if (root.get(optimizationModelsDictionaryData).has(description)) {
+ optimizationModels.setDescription(root.get(optimizationModelsDictionaryData)
+ .get(description).asText().replace("\"", ""));
}
- if (root.get(optimizationModelsDictionaryData).has(modelName)){
- optimizationModels.setModelName(root.get(optimizationModelsDictionaryData).get(modelName).asText().replace("\"", ""));
+ if (root.get(optimizationModelsDictionaryData).has(modelName)) {
+ optimizationModels.setModelName(root.get(optimizationModelsDictionaryData).get(modelName)
+ .asText().replace("\"", ""));
this.newModel.setModelName(optimizationModels.getModelName());
}
- if (root.get(optimizationModelsDictionaryData).has(version)){
- optimizationModels.setVersion(root.get(optimizationModelsDictionaryData).get(version).asText().replace("\"", ""));
+ if (root.get(optimizationModelsDictionaryData).has(version)) {
+ optimizationModels.setVersion(
+ root.get(optimizationModelsDictionaryData).get(version).asText().replace("\"", ""));
this.newModel.setVersion(optimizationModels.getVersion());
}
}
@@ -138,63 +149,70 @@ public class OptimizationDictionaryController {
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);
+ MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
classMap.put(key, msAttributeObject);
}
userId = root.get("userid").textValue();
- MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
+ MsAttributeObject mainClass = classMap.get(this.newModel.getModelName());
this.newModel.setDependency("[]");
String value = new Gson().toJson(mainClass.getSubClass());
this.newModel.setSubattributes(value);
- String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", "");
- int equalsIndexForAttributes= attributes.indexOf('=');
- String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1, attributes.length()-1);
+ String attributes = mainClass.getAttribute().toString().replace("{", "").replace("}", "");
+ int equalsIndexForAttributes = attributes.indexOf('=');
+ String atttributesAfterFirstEquals =
+ attributes.substring(equalsIndexForAttributes + 1, attributes.length() - 1);
this.newModel.setAttributes(atttributesAfterFirstEquals);
- String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
- int equalsIndex= refAttributes.indexOf('=');
- String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1, refAttributes.length()-1);
+ String refAttributes = mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
+ int equalsIndex = refAttributes.indexOf('=');
+ String refAttributesAfterFirstEquals =
+ refAttributes.substring(equalsIndex + 1, refAttributes.length() - 1);
this.newModel.setRefattributes(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) {
- optimizationModels = mapper.readValue(root.get(dictionaryFields).toString(), OptimizationModels.class);
+ optimizationModels =
+ mapper.readValue(root.get(dictionaryFields).toString(), OptimizationModels.class);
userId = "API";
} else {
- if (root.has(optimizationModelsDictionaryData)){
- if (root.get(optimizationModelsDictionaryData).has(description)){
- optimizationModels.setDescription(root.get(optimizationModelsDictionaryData).get(description).asText().replace("\"", ""));
+ if (root.has(optimizationModelsDictionaryData)) {
+ if (root.get(optimizationModelsDictionaryData).has(description)) {
+ optimizationModels.setDescription(root.get(optimizationModelsDictionaryData)
+ .get(description).asText().replace("\"", ""));
}
- if (root.get(optimizationModelsDictionaryData).has(modelName)){
- optimizationModels.setModelName(root.get(optimizationModelsDictionaryData).get(modelName).asText().replace("\"", ""));
+ if (root.get(optimizationModelsDictionaryData).has(modelName)) {
+ optimizationModels.setModelName(root.get(optimizationModelsDictionaryData)
+ .get(modelName).asText().replace("\"", ""));
this.newModel.setModelName(optimizationModels.getModelName());
}
- if (root.get(optimizationModelsDictionaryData).has(version)){
- optimizationModels.setVersion(root.get(optimizationModelsDictionaryData).get(version).asText().replace("\"", ""));
+ if (root.get(optimizationModelsDictionaryData).has(version)) {
+ optimizationModels.setVersion(root.get(optimizationModelsDictionaryData).get(version)
+ .asText().replace("\"", ""));
this.newModel.setVersion(optimizationModels.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);
+ MsAttributeObject msAttributeObject = mapper1.readValue(value, MsAttributeObject.class);
classMap.put(key, msAttributeObject);
}
}
@@ -212,80 +230,83 @@ public class OptimizationDictionaryController {
optimizationModels.setEnumValues(this.newModel.getEnumValues());
optimizationModels.setAnnotation(this.newModel.getAnnotation());
- if(dataOrderInfo != null){
+ if (dataOrderInfo != null) {
optimizationModels.setDataOrderInfo(dataOrderInfo);
}
String checkName = optimizationModels.getModelName() + ":" + optimizationModels.getVersion();
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(checkName, "modelName:version", OptimizationModels.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(checkName, "modelName:version", OptimizationModels.class);
boolean duplicateflag = false;
- if(duplicateData!=null && !duplicateData.isEmpty()){
+ if (duplicateData != null && !duplicateData.isEmpty()) {
OptimizationModels data = (OptimizationModels) duplicateData.get(0);
- if(request.getParameter(operation) != null && UPDATE.equals(request.getParameter(operation))){
+ if (request.getParameter(operation) != null && UPDATE.equals(request.getParameter(operation))) {
optimizationModels.setId(data.getId());
- }else if((request.getParameter(operation) != null && !UPDATE.equals(request.getParameter(operation))) ||
- (request.getParameter(operation) == null && (data.getId() != optimizationModels.getId()))){
+ } else if ((request.getParameter(operation) != null && !UPDATE.equals(request.getParameter(operation)))
+ || (request.getParameter(operation) == null && (data.getId() != optimizationModels.getId()))) {
duplicateflag = true;
}
}
UserInfo userInfo = dUtils.getUserInfo(userId);
String responseString = null;
- if(!duplicateflag){
+ if (!duplicateflag) {
optimizationModels.setUserCreatedBy(userInfo);
- if(optimizationModels.getId() == 0){
+ if (optimizationModels.getId() == 0) {
commonClassDao.save(optimizationModels);
- }else{
+ } else {
commonClassDao.update(optimizationModels);
}
responseString = mapper.writeValueAsString(commonClassDao.getData(OptimizationModels.class));
- }else{
+ } else {
responseString = duplicateResponseString;
}
- if(fromAPI){
+ if (fromAPI) {
return dUtils.getResultForApi(responseString);
- }else{
+ } else {
dUtils.setResponseData(response, optimizationModelsDictionaryDatas, responseString);
}
- }catch (Exception e){
+ } catch (Exception e) {
dUtils.setErrorResponseData(response, e);
}
return null;
}
- @RequestMapping(value={"/oof_dictionary/remove_model"}, method={RequestMethod.POST})
- public void removeOptimizationModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/oof_dictionary/remove_model"}, method = {RequestMethod.POST})
+ public void removeOptimizationModelsDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils dUtils = getDictionaryUtilsInstance();
dUtils.removeData(request, response, optimizationModelsDictionaryDatas, OptimizationModels.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());
+ 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){
- MSAttributeObject temp = classMap.get(element);
- if (temp!=null){
+ for (String element : dependency) {
+ MsAttributeObject temp = classMap.get(element);
+ 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.setSubattributes(subAttribute);
this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", ""));
@@ -299,13 +320,14 @@ public class OptimizationDictionaryController {
ArrayList<String> returnList = new ArrayList<>();
ArrayList<String> workingList;
returnList.addAll(dependency);
- for (String element : dependency ){
- if (classMap.containsKey(element)){
- MSAttributeObject value = classMap.get(element);
- String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
+ for (String element : dependency) {
+ if (classMap.containsKey(element)) {
+ MsAttributeObject value = classMap.get(element);
+ 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());
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
index c0e7729db..a230ebe38 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
@@ -23,11 +23,14 @@ 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 java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.lang.StringUtils;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -49,8 +52,7 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
public class PolicyScopeDictionaryController {
- private static final Logger LOGGER =
- FlexLogger.getLogger(PolicyScopeDictionaryController.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyScopeDictionaryController.class);
private static CommonClassDao commonClassDao;
private static String operation = "operation";
@@ -81,24 +83,27 @@ public class PolicyScopeDictionaryController {
PolicyScopeDictionaryController.commonClassDao = commonClassDao;
}
- @RequestMapping(value = {"/get_GroupPolicyScopeDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_GroupPolicyScopeDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getGroupPolicyScopeEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, groupPolicyScopeDatas, "name", GroupPolicyScopeList.class);
}
- @RequestMapping(value = {"/get_GroupPolicyScopeData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_GroupPolicyScopeData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getGroupPolicyScopeEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, groupPolicyScopeDatas, GroupPolicyScopeList.class);
}
- @RequestMapping(value = {"/ps_dictionary/save_psGroupPolicyScope"},
- method = {RequestMethod.POST})
- public ModelAndView savePSGroupScopeDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/ps_dictionary/save_psGroupPolicyScope"}, method = {RequestMethod.POST})
+ public ModelAndView savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -109,40 +114,33 @@ public class PolicyScopeDictionaryController {
GroupPolicyScope groupData = null;
boolean duplicateGroupFlag = false;
if (fromAPI) {
- gpdata = mapper.readValue(root.get(dictionaryFields).toString(),
- GroupPolicyScopeList.class);
+ gpdata = mapper.readValue(root.get(dictionaryFields).toString(), GroupPolicyScopeList.class);
try {
- groupData = mapper.readValue(root.get(groupPolicyScopeListData1).toString(),
- GroupPolicyScope.class);
+ groupData =
+ mapper.readValue(root.get(groupPolicyScopeListData1).toString(), GroupPolicyScope.class);
} catch (Exception e) {
groupData = new GroupPolicyScope();
- groupData.setResource(root.get(dictionaryFields).get("resource").toString()
- .replace("\"", ""));
- groupData.setClosedloop(root.get(dictionaryFields).get("closedloop").toString()
- .replace("\"", ""));
- groupData.setService(
- root.get(dictionaryFields).get("service").toString().replace("\"", ""));
- groupData.setType(
- root.get(dictionaryFields).get("type").toString().replace("\"", ""));
+ groupData.setResource(root.get(dictionaryFields).get("resource").toString().replace("\"", ""));
+ groupData.setClosedloop(root.get(dictionaryFields).get("closedloop").toString().replace("\"", ""));
+ groupData.setService(root.get(dictionaryFields).get("service").toString().replace("\"", ""));
+ groupData.setType(root.get(dictionaryFields).get("type").toString().replace("\"", ""));
LOGGER.error(e);
}
} else {
- gpdata = mapper.readValue(root.get("groupPolicyScopeListData").toString(),
- GroupPolicyScopeList.class);
+ gpdata = mapper.readValue(root.get("groupPolicyScopeListData").toString(), GroupPolicyScopeList.class);
try {
- groupData = mapper.readValue(root.get(groupPolicyScopeListData1).toString(),
- GroupPolicyScope.class);
+ groupData =
+ mapper.readValue(root.get(groupPolicyScopeListData1).toString(), GroupPolicyScope.class);
} catch (Exception e) {
LOGGER.error(e);
groupData = new GroupPolicyScope();
- groupData.setResource(root.get(groupPolicyScopeListData1).get("resource")
- .toString().replace("\"", ""));
- groupData.setClosedloop(root.get(groupPolicyScopeListData1).get("closedloop")
- .toString().replace("\"", ""));
- groupData.setService(root.get(groupPolicyScopeListData1).get("service")
- .toString().replace("\"", ""));
- groupData.setType(root.get(groupPolicyScopeListData1).get("type").toString()
- .replace("\"", ""));
+ groupData.setResource(
+ root.get(groupPolicyScopeListData1).get("resource").toString().replace("\"", ""));
+ groupData.setClosedloop(
+ root.get(groupPolicyScopeListData1).get("closedloop").toString().replace("\"", ""));
+ groupData.setService(
+ root.get(groupPolicyScopeListData1).get("service").toString().replace("\"", ""));
+ groupData.setType(root.get(groupPolicyScopeListData1).get("type").toString().replace("\"", ""));
}
}
if (!gpdata.getGroupName().startsWith(policyScope)) {
@@ -158,15 +156,15 @@ public class PolicyScopeDictionaryController {
valueList.add("service=" + serviceValue);
valueList.add("type=" + typeValue);
valueList.add("closedLoopControlName=" + closedLoopValue);
- String list = StringUtils.replaceEach(valueList.toString(),
- new String[] {"[", "]", " "}, new String[] {"", "", ""});
+ String list = StringUtils.replaceEach(valueList.toString(), new String[] {"[", "]", " "},
+ new String[] {"", "", ""});
gpdata.setGroupList(list);
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(gpdata.getGroupName(),
- "name", GroupPolicyScopeList.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(gpdata.getGroupName(), "name", GroupPolicyScopeList.class);
if (duplicateData.isEmpty()) {
- duplicateData = commonClassDao.checkDuplicateEntry(gpdata.getGroupList(),
- "groupList", GroupPolicyScopeList.class);
+ duplicateData = commonClassDao.checkDuplicateEntry(gpdata.getGroupList(), "groupList",
+ GroupPolicyScopeList.class);
if (duplicateData.isEmpty()) {
duplicateGroupFlag = true;
}
@@ -174,13 +172,11 @@ public class PolicyScopeDictionaryController {
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
GroupPolicyScopeList data = (GroupPolicyScopeList) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
gpdata.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != gpdata.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != gpdata.getId()))) {
duplicateflag = true;
}
}
@@ -191,8 +187,7 @@ public class PolicyScopeDictionaryController {
} else {
commonClassDao.update(gpdata);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(GroupPolicyScopeList.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(GroupPolicyScopeList.class));
} else if (duplicateGroupFlag) {
responseString = "DuplicateGroup";
} else {
@@ -209,22 +204,25 @@ public class PolicyScopeDictionaryController {
return null;
}
- @RequestMapping(value = {"/ps_dictionary/remove_GroupPolicyScope"},
- method = {RequestMethod.POST})
- public void removePSGroupScopeDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/ps_dictionary/remove_GroupPolicyScope"}, method = {RequestMethod.POST})
+ public void removePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, groupPolicyScopeDatas, GroupPolicyScopeList.class);
}
- @RequestMapping(value = {"/get_PSClosedLoopDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSClosedLoopDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSClosedLoopEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, psCLDatas, "name", OnapName.class);
}
- @RequestMapping(value = {"/get_PSClosedLoopData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSClosedLoopData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSClosedLoopEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -232,8 +230,8 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/save_psClosedLoop"}, method = {RequestMethod.POST})
- public ModelAndView savePSClosedLoopDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -242,25 +240,22 @@ public class PolicyScopeDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PolicyScopeClosedLoop onapData;
if (fromAPI) {
- onapData = mapper.readValue(root.get(dictionaryFields).toString(),
- PolicyScopeClosedLoop.class);
+ onapData = mapper.readValue(root.get(dictionaryFields).toString(), PolicyScopeClosedLoop.class);
} else {
onapData = mapper.readValue(root.get("psClosedLoopDictionaryData").toString(),
PolicyScopeClosedLoop.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(onapData.getName(),
- "name", PolicyScopeClosedLoop.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(onapData.getName(), "name", PolicyScopeClosedLoop.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PolicyScopeClosedLoop data = (PolicyScopeClosedLoop) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
onapData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != onapData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != onapData.getId()))) {
duplicateflag = true;
}
}
@@ -271,8 +266,7 @@ public class PolicyScopeDictionaryController {
} else {
commonClassDao.update(onapData);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(PolicyScopeClosedLoop.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PolicyScopeClosedLoop.class));
} else {
responseString = duplicateResponseString;
}
@@ -288,20 +282,24 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/remove_PSClosedLoop"}, method = {RequestMethod.POST})
- public void removePSClosedLoopDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public void removePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, psCLDatas, PolicyScopeClosedLoop.class);
}
- @RequestMapping(value = {"/get_PSServiceDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSServiceDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSServiceEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, psServiceDatas, "name", PolicyScopeService.class);
}
- @RequestMapping(value = {"/get_PSServiceData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSServiceData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSServiceEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -309,8 +307,8 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/save_psService"}, method = {RequestMethod.POST})
- public ModelAndView savePSServiceDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -319,25 +317,21 @@ public class PolicyScopeDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PolicyScopeService onapData;
if (fromAPI) {
- onapData = mapper.readValue(root.get(dictionaryFields).toString(),
- PolicyScopeService.class);
+ onapData = mapper.readValue(root.get(dictionaryFields).toString(), PolicyScopeService.class);
} else {
- onapData = mapper.readValue(root.get("psServiceDictionaryData").toString(),
- PolicyScopeService.class);
+ onapData = mapper.readValue(root.get("psServiceDictionaryData").toString(), PolicyScopeService.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(onapData.getName(),
- "name", PolicyScopeService.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(onapData.getName(), "name", PolicyScopeService.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PolicyScopeService data = (PolicyScopeService) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
onapData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != onapData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != onapData.getId()))) {
duplicateflag = true;
}
}
@@ -348,8 +342,7 @@ public class PolicyScopeDictionaryController {
} else {
commonClassDao.update(onapData);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(PolicyScopeService.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PolicyScopeService.class));
} else {
responseString = duplicateResponseString;
}
@@ -365,20 +358,23 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/remove_PSService"}, method = {RequestMethod.POST})
- public void removePSServiceDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, psServiceDatas, PolicyScopeService.class);
}
- @RequestMapping(value = {"/get_PSTypeDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSTypeDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSTypeEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, psTypeDatas, "name", PolicyScopeType.class);
}
- @RequestMapping(value = {"/get_PSTypeData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSTypeData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSTypeEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -386,8 +382,8 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/save_psType"}, method = {RequestMethod.POST})
- public ModelAndView savePSTypeDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -396,25 +392,21 @@ public class PolicyScopeDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PolicyScopeType onapData;
if (fromAPI) {
- onapData = mapper.readValue(root.get(dictionaryFields).toString(),
- PolicyScopeType.class);
+ onapData = mapper.readValue(root.get(dictionaryFields).toString(), PolicyScopeType.class);
} else {
- onapData = mapper.readValue(root.get("psTypeDictionaryData").toString(),
- PolicyScopeType.class);
+ onapData = mapper.readValue(root.get("psTypeDictionaryData").toString(), PolicyScopeType.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(onapData.getName(),
- "name", PolicyScopeType.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(onapData.getName(), "name", PolicyScopeType.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PolicyScopeType data = (PolicyScopeType) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
onapData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != onapData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != onapData.getId()))) {
duplicateflag = true;
}
}
@@ -425,8 +417,7 @@ public class PolicyScopeDictionaryController {
} else {
commonClassDao.update(onapData);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(PolicyScopeType.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PolicyScopeType.class));
} else {
responseString = duplicateResponseString;
}
@@ -442,20 +433,23 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/remove_PSType"}, method = {RequestMethod.POST})
- public void removePSTypeDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, psTypeDatas, PolicyScopeType.class);
}
- @RequestMapping(value = {"/get_PSResourceDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSResourceDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSResourceEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, psResourceDatas, "name", PolicyScopeResource.class);
}
- @RequestMapping(value = {"/get_PSResourceData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_PSResourceData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getPSResourceEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -463,8 +457,8 @@ public class PolicyScopeDictionaryController {
}
@RequestMapping(value = {"/ps_dictionary/save_psResource"}, method = {RequestMethod.POST})
- public ModelAndView savePSResourceDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -473,25 +467,21 @@ public class PolicyScopeDictionaryController {
JsonNode root = mapper.readTree(request.getReader());
PolicyScopeResource onapData;
if (fromAPI) {
- onapData = mapper.readValue(root.get(dictionaryFields).toString(),
- PolicyScopeResource.class);
+ onapData = mapper.readValue(root.get(dictionaryFields).toString(), PolicyScopeResource.class);
} else {
- onapData = mapper.readValue(root.get("psResourceDictionaryData").toString(),
- PolicyScopeResource.class);
+ onapData = mapper.readValue(root.get("psResourceDictionaryData").toString(), PolicyScopeResource.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(onapData.getName(),
- "name", PolicyScopeResource.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(onapData.getName(), "name", PolicyScopeResource.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
PolicyScopeResource data = (PolicyScopeResource) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
onapData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != onapData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != onapData.getId()))) {
duplicateflag = true;
}
}
@@ -502,8 +492,7 @@ public class PolicyScopeDictionaryController {
} else {
commonClassDao.update(onapData);
}
- responseString = mapper
- .writeValueAsString(commonClassDao.getData(PolicyScopeResource.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(PolicyScopeResource.class));
} else {
responseString = duplicateResponseString;
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
index 17fce7142..b7b63a9e0 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/PushPolicyController.java
@@ -24,6 +24,7 @@ import com.att.research.xacml.api.pap.PAPException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -32,9 +33,11 @@ import java.io.ObjectOutputStream;
import java.net.URI;
import java.util.List;
import java.util.UUID;
+
import javax.script.SimpleBindings;
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.common.logging.flexlogger.FlexLogger;
@@ -93,8 +96,8 @@ public class PushPolicyController {
LOGGER.info("No request ID provided, sending generated ID: " + requestID);
}
LOGGER.info("Push policy Request to get the selectedPolicy : " + root.asText());
- String policyVersionName = policyScope.replace(".", File.separator) + File.separator
- + filePrefix + policyName;
+ String policyVersionName =
+ policyScope.replace(".", File.separator) + File.separator + filePrefix + policyName;
List<?> policyVersionObject =
commonClassDao.getDataById(PolicyVersion.class, policyNames, policyVersionName);
if (policyVersionObject != null) {
@@ -120,10 +123,10 @@ public class PushPolicyController {
}
private void addPolicyToGroup(String policyScope, String policyID, String policyName, String pdpGroup,
- HttpServletResponse response) {
+ HttpServletResponse response) {
StdPDPGroup selectedPDPGroup = null;
StdPDPPolicy selectedPolicy = null;
- //Get the selected PDP Group to push the policy
+ // Get the selected PDP Group to push the policy
try {
selectedPDPGroup = (StdPDPGroup) XACMLPapServlet.getPAPEngine().getGroup(pdpGroup);
} catch (PAPException e1) {
@@ -147,16 +150,15 @@ public class PushPolicyController {
params.put("scope", policyScope);
params.put(policyNames, policyName.substring(policyScope.length() + 1));
List<?> createPolicyQueryList = commonClassDao.getDataByQuery(createPolicyQuery, params);
- LOGGER.info("addPolicyToGroup:Total execution time to retrieve " + policyNames
- + " from PolicyEntity");
+ LOGGER.info("addPolicyToGroup:Total execution time to retrieve " + policyNames + " from PolicyEntity");
PolicyEntity policyEntity = null;
if (!createPolicyQueryList.isEmpty()) {
policyEntity = (PolicyEntity) createPolicyQueryList.get(0);
} else {
PolicyLogger
- .error("Somehow, more than one policy with the same scope, name, and deleted status were found in" +
- " the database");
+ .error("Somehow, more than one policy with the same scope, name, and deleted status were found in"
+ + " the database");
String message = "Unknown Policy '" + policyName + "'";
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " " + message);
response.addHeader(errorMsg, "unknownPolicy");
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
index 6e794d966..577870c70 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/SafePolicyController.java
@@ -23,11 +23,14 @@ 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 java.io.IOException;
import java.util.Date;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.RiskType;
@@ -66,14 +69,18 @@ public class SafePolicyController {
return DictionaryUtils.getDictionaryUtils();
}
- @RequestMapping(value = {"/get_RiskTypeDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_RiskTypeDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getRiskTypeDictionaryByNameEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, riskTypeDatas, "name", RiskType.class);
}
- @RequestMapping(value = {"/get_RiskTypeData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_RiskTypeData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getRiskTypeDictionaryEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
@@ -81,8 +88,8 @@ public class SafePolicyController {
}
@RequestMapping(value = {"/sp_dictionary/save_riskType"}, method = {RequestMethod.POST})
- public ModelAndView saveRiskTypeDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -92,27 +99,23 @@ public class SafePolicyController {
RiskType riskTypeData;
String userId = null;
if (fromAPI) {
- riskTypeData =
- mapper.readValue(root.get("dictionaryFields").toString(), RiskType.class);
+ riskTypeData = mapper.readValue(root.get("dictionaryFields").toString(), RiskType.class);
userId = "API";
} else {
- riskTypeData = mapper.readValue(root.get("riskTypeDictionaryData").toString(),
- RiskType.class);
+ riskTypeData = mapper.readValue(root.get("riskTypeDictionaryData").toString(), RiskType.class);
userId = root.get("userid").textValue();
}
UserInfo userInfo = utils.getUserInfo(userId);
- List<Object> duplicateData = commonClassDao
- .checkDuplicateEntry(riskTypeData.getRiskName(), "name", RiskType.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(riskTypeData.getName(), "name", RiskType.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
RiskType data = (RiskType) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
riskTypeData.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != riskTypeData.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != riskTypeData.getId()))) {
duplicateflag = true;
}
}
@@ -142,30 +145,32 @@ public class SafePolicyController {
}
@RequestMapping(value = {"/sp_dictionary/remove_riskType"}, method = {RequestMethod.POST})
- public void removeRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ public void removeRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, riskTypeDatas, RiskType.class);
}
- @RequestMapping(value = {"/get_SafePolicyWarningDataByName"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SafePolicyWarningDataByName"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningEntityDataByName(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getDataByEntity(response, safePolicyWarningDatas, "name", SafePolicyWarning.class);
}
- @RequestMapping(value = {"/get_SafePolicyWarningData"}, method = {RequestMethod.GET},
+ @RequestMapping(
+ value = {"/get_SafePolicyWarningData"},
+ method = {RequestMethod.GET},
produces = MediaType.APPLICATION_JSON_VALUE)
public void getSafePolicyWarningeEntityData(HttpServletResponse response) {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.getData(response, safePolicyWarningDatas, SafePolicyWarning.class);
}
- @RequestMapping(value = {"/sp_dictionary/save_safePolicyWarning"},
- method = {RequestMethod.POST})
- public ModelAndView saveSafePolicyWarningDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/sp_dictionary/save_safePolicyWarning"}, method = {RequestMethod.POST})
+ public ModelAndView saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
try {
boolean fromAPI = utils.isRequestFromAPI(request);
@@ -174,25 +179,22 @@ public class SafePolicyController {
JsonNode root = mapper.readTree(request.getReader());
SafePolicyWarning safePolicyWarning;
if (fromAPI) {
- safePolicyWarning = mapper.readValue(root.get("dictionaryFields").toString(),
- SafePolicyWarning.class);
+ safePolicyWarning = mapper.readValue(root.get("dictionaryFields").toString(), SafePolicyWarning.class);
} else {
- safePolicyWarning = mapper.readValue(root.get("safePolicyWarningData").toString(),
- SafePolicyWarning.class);
+ safePolicyWarning =
+ mapper.readValue(root.get("safePolicyWarningData").toString(), SafePolicyWarning.class);
}
- List<Object> duplicateData = commonClassDao.checkDuplicateEntry(
- safePolicyWarning.getName(), "name", SafePolicyWarning.class);
+ List<Object> duplicateData =
+ commonClassDao.checkDuplicateEntry(safePolicyWarning.getName(), "name", SafePolicyWarning.class);
boolean duplicateflag = false;
if (!duplicateData.isEmpty()) {
SafePolicyWarning data = (SafePolicyWarning) duplicateData.get(0);
- if (request.getParameter(operation) != null
- && "update".equals(request.getParameter(operation))) {
+ if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) {
safePolicyWarning.setId(data.getId());
} else if ((request.getParameter(operation) != null
&& !"update".equals(request.getParameter(operation)))
- || (request.getParameter(operation) == null
- && (data.getId() != safePolicyWarning.getId()))) {
+ || (request.getParameter(operation) == null && (data.getId() != safePolicyWarning.getId()))) {
duplicateflag = true;
}
}
@@ -203,8 +205,7 @@ public class SafePolicyController {
} else {
commonClassDao.update(safePolicyWarning);
}
- responseString =
- mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
+ responseString = mapper.writeValueAsString(commonClassDao.getData(SafePolicyWarning.class));
} else {
responseString = duplicateResponseString;
}
@@ -219,10 +220,9 @@ public class SafePolicyController {
return null;
}
- @RequestMapping(value = {"/sp_dictionary/remove_SafePolicyWarning"},
- method = {RequestMethod.POST})
- public void removeSafePolicyWarningDictionary(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ @RequestMapping(value = {"/sp_dictionary/remove_SafePolicyWarning"}, method = {RequestMethod.POST})
+ public void removeSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
DictionaryUtils utils = getDictionaryUtilsInstance();
utils.removeData(request, response, safePolicyWarningDatas, SafePolicyWarning.class);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/package-info.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/package-info.java
index bb42fb6aa..7e940a2a1 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/package-info.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/package-info.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 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.
@@ -18,5 +18,4 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.policy.pap.xacml.rest.controller;