summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src
diff options
context:
space:
mode:
authorTej, Tarun <tt3868@att.com>2017-08-21 20:00:50 -0400
committerTarun Tej Velaga <tt3868@att.com>2017-08-23 17:29:35 +0000
commit80f072f60509ef3a35369a60857fe05f6c2a993a (patch)
tree7dca6266b225be3f192623fdc859ca80f4d1d493 /POLICY-SDK-APP/src
parentc53fa990ea27ec074859eb94bcb7ec6deaa2157b (diff)
Fixes for sonar critical issues
Fixes for critical and blocker issues reported in sonar. Issue-Id: POLICY-113 Change-Id: I50969fe93a94b0497f3fb30864a6c45e63208fe6 Signed-off-by: Tej, Tarun <tt3868@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java416
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AdminTabController.java3
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java11
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java19
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java14
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java5
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyValidationController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java32
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java33
15 files changed, 312 insertions, 273 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index e99f35bde..7234a3b6a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -361,7 +361,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
@RequestMapping(value={"/saveDictionary/*/*"}, method={RequestMethod.POST})
- public ModelAndView saveDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView saveDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException{
String uri = request.getRequestURI().replace("/saveDictionary", "");
if(uri.contains(importDictionary)){
String userId = UserUtils.getUserSession(request).getOrgUserId();
@@ -373,7 +373,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
@RequestMapping(value={"/deleteDictionary/*/*"}, method={RequestMethod.POST})
- public ModelAndView deletetDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView deletetDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException {
String uri = request.getRequestURI().replace("/deleteDictionary", "");
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
response.getWriter().write(body);
@@ -381,7 +381,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
@RequestMapping(value={"/searchDictionary"}, method={RequestMethod.POST})
- public ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException {
Object resultList = null;
String uri = request.getRequestURI();
try{
@@ -410,7 +410,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
@RequestMapping(value={"/searchPolicy"}, method={RequestMethod.POST})
- public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
Object resultList = null;
String uri = request.getRequestURI()+"?action=search";
String body = callPAP(request, "POST", uri.replaceFirst("/", "").trim());
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
index 0a985045d..c8b7a9630 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
@@ -20,7 +20,6 @@
package org.onap.policy.controller;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -36,7 +35,6 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
@@ -50,219 +48,227 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@Controller
-@RequestMapping({"/"})
-public class ActionPolicyController extends RestrictedBaseController{
- private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicyController.class);
-
- public ActionPolicyController(){
- //Default Constructor
- }
+@RequestMapping({ "/" })
+public class ActionPolicyController extends RestrictedBaseController {
+ private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicyController.class);
+
+ public ActionPolicyController() {
+ // Default Constructor
+ }
- private ArrayList<Object> attributeList;
- protected LinkedList<Integer> ruleAlgoirthmTracker;
- public static final String PERFORMER_ATTRIBUTEID = "performer";
- protected Map<String, String> performer = new HashMap<>();
- private ArrayList<Object> ruleAlgorithmList;
+ private ArrayList<Object> attributeList;
+ protected LinkedList<Integer> ruleAlgoirthmTracker;
+ public static final String PERFORMER_ATTRIBUTEID = "performer";
+ protected Map<String, String> performer = new HashMap<>();
+ private ArrayList<Object> ruleAlgorithmList;
- public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- attributeList = new ArrayList<>();
- ruleAlgorithmList = new ArrayList<>();
- performer.put("PDP", "PDPAction");
- performer.put("PEP", "PEPAction");
+ public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
+ attributeList = new ArrayList<>();
+ ruleAlgorithmList = new ArrayList<>();
+ performer.put("PDP", "PDPAction");
+ performer.put("PEP", "PEPAction");
- if (policyAdapter.getPolicyData() instanceof PolicyType) {
- Object policyData = policyAdapter.getPolicyData();
- PolicyType policy = (PolicyType) policyData;
- policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
- String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("_") + 1);
- policyAdapter.setPolicyName(policyNameValue);
- String description = "";
- try{
- description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
- }catch(Exception e){
- description = policy.getDescription();
- }
- policyAdapter.setPolicyDescription(description);
- // Get the target data under policy for Action.
- TargetType target = policy.getTarget();
- if (target != null) {
- // under target we have AnyOFType
- List<AnyOfType> anyOfList = target.getAnyOf();
- if (anyOfList != null) {
- Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
- while (iterAnyOf.hasNext()) {
- AnyOfType anyOf = iterAnyOf.next();
- // Under AntOfType we have AllOfType
- List<AllOfType> allOfList = anyOf.getAllOf();
- if (allOfList != null) {
- Iterator<AllOfType> iterAllOf = allOfList.iterator();
- while (iterAllOf.hasNext()) {
- AllOfType allOf = iterAllOf.next();
- // Under AllOfType we have Mathch.
- List<MatchType> matchList = allOf.getMatch();
- if (matchList != null) {
- Iterator<MatchType> iterMatch = matchList.iterator();
- while (iterMatch.hasNext()) {
- MatchType match = iterMatch.next();
- //
- // Under the match we have attributevalue and
- // attributeDesignator. So,finally down to the actual attribute.
- //
- AttributeValueType attributeValue = match.getAttributeValue();
- String value = (String) attributeValue.getContent().get(0);
- AttributeDesignatorType designator = match.getAttributeDesignator();
- String attributeId = designator.getAttributeId();
- // Component attributes are saved under Target here we are fetching them back.
- // One row is default so we are not adding dynamic component at index 0.
- Map<String, String> attribute = new HashMap<>();
- attribute.put("key", attributeId);
- attribute.put("value", value);
- attributeList.add(attribute);
- }
- }
- policyAdapter.setAttributes(attributeList);
- }
- }
- }
- }
+ if (policyAdapter.getPolicyData() instanceof PolicyType) {
+ Object policyData = policyAdapter.getPolicyData();
+ PolicyType policy = (PolicyType) policyData;
+ policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
+ String policyNameValue = policyAdapter.getPolicyName()
+ .substring(policyAdapter.getPolicyName().indexOf("_") + 1);
+ policyAdapter.setPolicyName(policyNameValue);
+ String description = "";
+ try {
+ description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
+ } catch (Exception e) {
+ LOGGER.error("Error while collecting the desciption tag in ActionPolicy " + policyNameValue, e);
+ description = policy.getDescription();
+ }
+ policyAdapter.setPolicyDescription(description);
+ // Get the target data under policy for Action.
+ TargetType target = policy.getTarget();
+ if (target != null) {
+ // under target we have AnyOFType
+ List<AnyOfType> anyOfList = target.getAnyOf();
+ if (anyOfList != null) {
+ Iterator<AnyOfType> iterAnyOf = anyOfList.iterator();
+ while (iterAnyOf.hasNext()) {
+ AnyOfType anyOf = iterAnyOf.next();
+ // Under AntOfType we have AllOfType
+ List<AllOfType> allOfList = anyOf.getAllOf();
+ if (allOfList != null) {
+ Iterator<AllOfType> iterAllOf = allOfList.iterator();
+ while (iterAllOf.hasNext()) {
+ AllOfType allOf = iterAllOf.next();
+ // Under AllOfType we have Mathch.
+ List<MatchType> matchList = allOf.getMatch();
+ if (matchList != null) {
+ Iterator<MatchType> iterMatch = matchList.iterator();
+ while (iterMatch.hasNext()) {
+ MatchType match = iterMatch.next();
+ //
+ // Under the match we have attributevalue and
+ // attributeDesignator. So,finally down to the actual attribute.
+ //
+ AttributeValueType attributeValue = match.getAttributeValue();
+ String value = (String) attributeValue.getContent().get(0);
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
+ // Component attributes are saved under Target here we are fetching them back.
+ // One row is default so we are not adding dynamic component at index 0.
+ Map<String, String> attribute = new HashMap<>();
+ attribute.put("key", attributeId);
+ attribute.put("value", value);
+ attributeList.add(attribute);
+ }
+ }
+ policyAdapter.setAttributes(attributeList);
+ }
+ }
+ }
+ }
- List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
- // Under rule we have Condition and obligation.
- for (Object o : ruleList) {
- if (o instanceof RuleType) {
- ConditionType condition = ((RuleType) o).getCondition();
- ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions();
- if (condition != null) {
- int index = 0;
- ApplyType actionApply = (ApplyType) condition.getExpression().getValue();
- ruleAlgoirthmTracker = new LinkedList<>();
- // Populating Rule Algorithms starting from compound.
- prePopulateCompoundRuleAlgorithm(index, actionApply);
- }
- policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
- // get the Obligation data under the rule for Form elements.
- if (obligations != null) {
- // Under the obligationExpressions we have obligationExpression.
- List<ObligationExpressionType> obligationList = obligations.getObligationExpression();
- if (obligationList != null) {
- Iterator<ObligationExpressionType> iterObligation = obligationList.iterator();
- while (iterObligation.hasNext()) {
- ObligationExpressionType obligation = iterObligation.next();
- policyAdapter.setActionAttributeValue(obligation.getObligationId());
- // Under the obligationExpression we have attributeAssignmentExpression.
- List<AttributeAssignmentExpressionType> attributeAssignmentExpressionList = obligation.getAttributeAssignmentExpression();
- if (attributeAssignmentExpressionList != null) {
- Iterator<AttributeAssignmentExpressionType> iterAttributeAssignmentExpression = attributeAssignmentExpressionList.iterator();
- while (iterAttributeAssignmentExpression.hasNext()) {
- AttributeAssignmentExpressionType attributeAssignmentExpression = iterAttributeAssignmentExpression.next();
- String attributeID = attributeAssignmentExpression.getAttributeId();
- AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression.getExpression().getValue();
- if (attributeID.equals(PERFORMER_ATTRIBUTEID)) {
- for (String key : performer.keySet()) {
- String keyValue = performer.get(key);
- if (keyValue.equals(attributeValue.getContent().get(0))) {
- policyAdapter.setActionPerformer(key);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
+ List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
+ // Under rule we have Condition and obligation.
+ for (Object o : ruleList) {
+ if (o instanceof RuleType) {
+ ConditionType condition = ((RuleType) o).getCondition();
+ ObligationExpressionsType obligations = ((RuleType) o).getObligationExpressions();
+ if (condition != null) {
+ int index = 0;
+ ApplyType actionApply = (ApplyType) condition.getExpression().getValue();
+ ruleAlgoirthmTracker = new LinkedList<>();
+ // Populating Rule Algorithms starting from compound.
+ prePopulateCompoundRuleAlgorithm(index, actionApply);
+ }
+ policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
+ // get the Obligation data under the rule for Form elements.
+ if (obligations != null) {
+ // Under the obligationExpressions we have obligationExpression.
+ List<ObligationExpressionType> obligationList = obligations.getObligationExpression();
+ if (obligationList != null) {
+ Iterator<ObligationExpressionType> iterObligation = obligationList.iterator();
+ while (iterObligation.hasNext()) {
+ ObligationExpressionType obligation = iterObligation.next();
+ policyAdapter.setActionAttributeValue(obligation.getObligationId());
+ // Under the obligationExpression we have attributeAssignmentExpression.
+ List<AttributeAssignmentExpressionType> attributeAssignmentExpressionList = obligation
+ .getAttributeAssignmentExpression();
+ if (attributeAssignmentExpressionList != null) {
+ Iterator<AttributeAssignmentExpressionType> iterAttributeAssignmentExpression = attributeAssignmentExpressionList
+ .iterator();
+ while (iterAttributeAssignmentExpression.hasNext()) {
+ AttributeAssignmentExpressionType attributeAssignmentExpression = iterAttributeAssignmentExpression
+ .next();
+ String attributeID = attributeAssignmentExpression.getAttributeId();
+ AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression
+ .getExpression().getValue();
+ if (attributeID.equals(PERFORMER_ATTRIBUTEID)) {
+ for (String key : performer.keySet()) {
+ String keyValue = performer.get(key);
+ if (keyValue.equals(attributeValue.getContent().get(0))) {
+ policyAdapter.setActionPerformer(key);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
- private int prePopulateCompoundRuleAlgorithm(int index, ApplyType actionApply) {
- boolean isCompoundRule = true;
- List<JAXBElement<?>> jaxbActionTypes = actionApply.getExpression();
- for (JAXBElement<?> jaxbElement : jaxbActionTypes) {
- // If There is Attribute Value under Action Type that means we came to the final child
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Prepopulating rule algoirthm: " + index);
- }
- // Check to see if Attribute Value exists, if yes then it is not a compound rule
- if (jaxbElement.getValue() instanceof AttributeValueType) {
- prePopulateRuleAlgorithms(index, actionApply, jaxbActionTypes);
- ruleAlgoirthmTracker.addLast(index);
- isCompoundRule = false;
- index++;
- }
- }
- if (isCompoundRule) {
- // As it's compound rule, Get the Apply types
- for (JAXBElement<?> jaxbElement : jaxbActionTypes) {
- ApplyType innerActionApply = (ApplyType) jaxbElement.getValue();
- index = prePopulateCompoundRuleAlgorithm(index, innerActionApply);
- }
- // Populate combo box
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Prepopulating Compound rule algorithm: " + index);
- }
- Map<String, String> rule = new HashMap<String, String>();
- for (String key : PolicyController.getDropDownMap().keySet()) {
- String keyValue = PolicyController.getDropDownMap().get(key);
- if (keyValue.equals(actionApply.getFunctionId())) {
- rule.put("dynamicRuleAlgorithmCombo", key);
- }
- }
- rule.put("id", "A" + (index +1));
- // Populate Key and values for Compound Rule
- rule.put("dynamicRuleAlgorithmField1", "A" + (ruleAlgoirthmTracker.getLast() + 1 ));
- ruleAlgoirthmTracker.removeLast();
- rule.put("dynamicRuleAlgorithmField2", "A" + (ruleAlgoirthmTracker.getLast() + 1));
- ruleAlgoirthmTracker.removeLast();
- ruleAlgoirthmTracker.addLast(index);
- ruleAlgorithmList.add(rule);
- index++;
- }
- return index;
- }
+ private int prePopulateCompoundRuleAlgorithm(int index, ApplyType actionApply) {
+ boolean isCompoundRule = true;
+ List<JAXBElement<?>> jaxbActionTypes = actionApply.getExpression();
+ for (JAXBElement<?> jaxbElement : jaxbActionTypes) {
+ // If There is Attribute Value under Action Type that means we came to the final child
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Prepopulating rule algoirthm: " + index);
+ }
+ // Check to see if Attribute Value exists, if yes then it is not a compound rule
+ if (jaxbElement.getValue() instanceof AttributeValueType) {
+ prePopulateRuleAlgorithms(index, actionApply, jaxbActionTypes);
+ ruleAlgoirthmTracker.addLast(index);
+ isCompoundRule = false;
+ index++;
+ }
+ }
+ if (isCompoundRule) {
+ // As it's compound rule, Get the Apply types
+ for (JAXBElement<?> jaxbElement : jaxbActionTypes) {
+ ApplyType innerActionApply = (ApplyType) jaxbElement.getValue();
+ index = prePopulateCompoundRuleAlgorithm(index, innerActionApply);
+ }
+ // Populate combo box
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Prepopulating Compound rule algorithm: " + index);
+ }
+ Map<String, String> rule = new HashMap<String, String>();
+ for (String key : PolicyController.getDropDownMap().keySet()) {
+ String keyValue = PolicyController.getDropDownMap().get(key);
+ if (keyValue.equals(actionApply.getFunctionId())) {
+ rule.put("dynamicRuleAlgorithmCombo", key);
+ }
+ }
+ rule.put("id", "A" + (index + 1));
+ // Populate Key and values for Compound Rule
+ rule.put("dynamicRuleAlgorithmField1", "A" + (ruleAlgoirthmTracker.getLast() + 1));
+ ruleAlgoirthmTracker.removeLast();
+ rule.put("dynamicRuleAlgorithmField2", "A" + (ruleAlgoirthmTracker.getLast() + 1));
+ ruleAlgoirthmTracker.removeLast();
+ ruleAlgoirthmTracker.addLast(index);
+ ruleAlgorithmList.add(rule);
+ index++;
+ }
+ return index;
+ }
- private void prePopulateRuleAlgorithms(int index, ApplyType actionApply, List<JAXBElement<?>> jaxbActionTypes) {
- Map<String, String> ruleMap = new HashMap<String, String>();
- ruleMap.put("id", "A" + (index +1));
- // Populate combo box
- Map<String, String> dropDownMap = PolicyController.getDropDownMap();
- for (String key : dropDownMap.keySet()) {
- String keyValue = dropDownMap.get(key);
- if (keyValue.equals(actionApply.getFunctionId())) {
- ruleMap.put("dynamicRuleAlgorithmCombo", key);
- }
- }
- // Populate the key and value fields
- // Rule Attribute added as key
- if ((jaxbActionTypes.get(0).getValue()) instanceof ApplyType) {
- // Get from Attribute Designator
- ApplyType innerActionApply = (ApplyType) jaxbActionTypes.get(0).getValue();
- List<JAXBElement<?>> jaxbInnerActionTypes = innerActionApply.getExpression();
- AttributeDesignatorType attributeDesignator = (AttributeDesignatorType) jaxbInnerActionTypes.get(0).getValue();
- ruleMap.put("dynamicRuleAlgorithmField1", attributeDesignator.getAttributeId());
+ private void prePopulateRuleAlgorithms(int index, ApplyType actionApply, List<JAXBElement<?>> jaxbActionTypes) {
+ Map<String, String> ruleMap = new HashMap<String, String>();
+ ruleMap.put("id", "A" + (index + 1));
+ // Populate combo box
+ Map<String, String> dropDownMap = PolicyController.getDropDownMap();
+ for (String key : dropDownMap.keySet()) {
+ String keyValue = dropDownMap.get(key);
+ if (keyValue.equals(actionApply.getFunctionId())) {
+ ruleMap.put("dynamicRuleAlgorithmCombo", key);
+ }
+ }
+ // Populate the key and value fields
+ // Rule Attribute added as key
+ if ((jaxbActionTypes.get(0).getValue()) instanceof ApplyType) {
+ // Get from Attribute Designator
+ ApplyType innerActionApply = (ApplyType) jaxbActionTypes.get(0).getValue();
+ List<JAXBElement<?>> jaxbInnerActionTypes = innerActionApply.getExpression();
+ AttributeDesignatorType attributeDesignator = (AttributeDesignatorType) jaxbInnerActionTypes.get(0)
+ .getValue();
+ ruleMap.put("dynamicRuleAlgorithmField1", attributeDesignator.getAttributeId());
- // Get from Attribute Value
- AttributeValueType actionConditionAttributeValue = (AttributeValueType) jaxbActionTypes.get(1).getValue();
- String attributeValue = (String) actionConditionAttributeValue.getContent().get(0);
- ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);
- }
- // Rule Attribute added as value
- else if (((jaxbActionTypes.get(0).getValue()) instanceof AttributeValueType)) {
- AttributeValueType actionConditionAttributeValue = (AttributeValueType) jaxbActionTypes.get(0).getValue();
- String attributeValue = (String) actionConditionAttributeValue.getContent().get(0);
- ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);
+ // Get from Attribute Value
+ AttributeValueType actionConditionAttributeValue = (AttributeValueType) jaxbActionTypes.get(1).getValue();
+ String attributeValue = (String) actionConditionAttributeValue.getContent().get(0);
+ ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);
+ }
+ // Rule Attribute added as value
+ else if (((jaxbActionTypes.get(0).getValue()) instanceof AttributeValueType)) {
+ AttributeValueType actionConditionAttributeValue = (AttributeValueType) jaxbActionTypes.get(0).getValue();
+ String attributeValue = (String) actionConditionAttributeValue.getContent().get(0);
+ ruleMap.put("dynamicRuleAlgorithmField2", attributeValue);
- ApplyType innerActionApply = (ApplyType) jaxbActionTypes.get(1).getValue();
- List<JAXBElement<?>> jaxbInnerActionTypes = innerActionApply.getExpression();
- AttributeDesignatorType attributeDesignator = (AttributeDesignatorType) jaxbInnerActionTypes.get(0).getValue();
- ruleMap.put("dynamicRuleAlgorithmField1", attributeDesignator.getAttributeId());
- }
- ruleAlgorithmList.add(ruleMap);
- }
+ ApplyType innerActionApply = (ApplyType) jaxbActionTypes.get(1).getValue();
+ List<JAXBElement<?>> jaxbInnerActionTypes = innerActionApply.getExpression();
+ AttributeDesignatorType attributeDesignator = (AttributeDesignatorType) jaxbInnerActionTypes.get(0)
+ .getValue();
+ ruleMap.put("dynamicRuleAlgorithmField1", attributeDesignator.getAttributeId());
+ }
+ ruleAlgorithmList.add(ruleMap);
+ }
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AdminTabController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AdminTabController.java
index 820a1ebd9..3b88f8472 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AdminTabController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AdminTabController.java
@@ -21,6 +21,7 @@
package org.onap.policy.controller;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
@@ -86,7 +87,7 @@ public class AdminTabController extends RestrictedBaseController{
}
@RequestMapping(value={"/adminTabController/save_LockDownValue.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView saveAdminTabLockdownValue(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView saveAdminTabLockdownValue(HttpServletRequest request, HttpServletResponse response) throws IOException{
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
index b72993f19..c1468e365 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java
@@ -177,7 +177,7 @@ public class AutoPushController extends RestrictedBaseController{
}
@RequestMapping(value={"/auto_Push/PushPolicyToPDP.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView PushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView pushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
ArrayList<Object> selectedPDPS = new ArrayList<>();
ArrayList<String> selectedPoliciesInUI = new ArrayList<>();
@@ -256,7 +256,7 @@ public class AutoPushController extends RestrictedBaseController{
// Create the policy
selectedPolicy = new StdPDPPolicy(name, true, id, selectedURI);
} catch (IOException e) {
- logger.error("Unable to create policy '" + name + "': "+ e.getMessage());
+ logger.error("Unable to create policy '" + name + "': "+ e.getMessage(), e);
}
StdPDPGroup selectedGroup = (StdPDPGroup) pdpDestinationGroupId;
if (selectedPolicy != null) {
@@ -319,7 +319,7 @@ public class AutoPushController extends RestrictedBaseController{
refreshGroups();
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
- out.write(j.toString());
+ out.write(j.toString());
return null;
}
}
@@ -327,6 +327,7 @@ public class AutoPushController extends RestrictedBaseController{
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
+ logger.error(e);
out.write(e.getMessage());
}
return null;
@@ -334,7 +335,7 @@ public class AutoPushController extends RestrictedBaseController{
@SuppressWarnings("unchecked")
@RequestMapping(value={"/auto_Push/remove_GroupPolicies.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
PolicyController controller = getPolicyControllerInstance();
this.container = new PDPGroupContainer(controller.getPapEngine());
@@ -376,6 +377,7 @@ public class AutoPushController extends RestrictedBaseController{
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
+ logger.error(e);
out.write(e.getMessage());
}
return null;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
index a7ce45ec4..e7740c336 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
@@ -279,6 +279,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
}
}
} catch(Exception e){
+ policyLogger.warn("Error during callTrap" , e);
return "(" + trap + ")";
}
}else{
@@ -316,7 +317,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
attrib = getVarbindOID(attrib);
attributes = attributes + "("+ URLEncoder.encode(attrib, "UTF-8")+ ")";
} catch (UnsupportedEncodingException e1) {
- //logger.error("Caused Exception while Encoding Varbind Dictionary Values"+e1);
+ policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values",e1);
}
}
}else{
@@ -324,7 +325,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
attrib = getVarbindOID(attrib);
attributes = attributes + "("+ URLEncoder.encode(attrib, "UTF-8")+ ")";
} catch (UnsupportedEncodingException e) {
- //logger.error("Caused Exception while Encoding Varbind Dictionary Values"+e);
+ policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values",e);
}
}
}else{
@@ -348,7 +349,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
attrib = getVarbindOID(attrib);
attributes = attributes + "("+ URLEncoder.encode(attrib, "UTF-8") + ")";
} catch (UnsupportedEncodingException e1) {
- //logger.error("Caused Exception while Encoding Varbind Dictionary Values"+e1);
+ policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values",e1);
}
}
}else{
@@ -356,7 +357,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
attrib = getVarbindOID(attrib);
attributes = attributes + "("+ URLEncoder.encode(attrib, "UTF-8") + ")";
} catch (UnsupportedEncodingException e) {
- //logger.error("Caused Exception while Encoding Varbind Dictionary Values"+e);
+ policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values",e);
}
}
}
@@ -369,6 +370,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
varbindId = (VarbindDictionary) commonclassdao.getEntityItem(VarbindDictionary.class, "varbindName", attrib);
return varbindId.getVarbindOID();
}catch(Exception e){
+ policyLogger.error("Error during retrieving varbindName " + attrib, e);
return attrib;
}
}
@@ -511,6 +513,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ policyLogger.error("Error during collecting the description tag info for createClosedLoopFault " + policyNameValue , e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
index 609a45c20..815b88f70 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
@@ -55,6 +55,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FileUtils;
@@ -850,7 +851,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
@RequestMapping(value={"/policyController/getDCAEMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView getDCAEMSTemplateData(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView getDCAEMSTemplateData(HttpServletRequest request, HttpServletResponse response) throws IOException{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -980,7 +981,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
@RequestMapping(value={"/policyController/getModelServiceVersioneData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response) throws IOException{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
@@ -1068,6 +1069,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ LOGGER.error("Error while collecting the desciption tag in ActionPolicy " + policyNameValue ,e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
@@ -1270,7 +1272,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
@RequestMapping(value={"/ms_dictionary/set_MSModelData"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public void SetMSModelData(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void SetMSModelData(HttpServletRequest request, HttpServletResponse response) throws IOException, FileUploadException{
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
boolean zip = false;
boolean yml= false;
@@ -1425,7 +1427,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}
} catch (IOException e) {
- LOGGER.error("Failed to unzip model file " + zipFile);
+ LOGGER.error("Failed to unzip model file " + zipFile, e);
}finally{
try {
if(zip != null)
@@ -1470,7 +1472,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try {
FileUtils.forceDelete(new File(path));
} catch (IOException e) {
- LOGGER.error("Failed to delete folder " + path);
+ LOGGER.error("Failed to delete folder " + path, e);
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
index 9c07876c1..4506fb84c 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
@@ -27,6 +27,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyEntity;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
@@ -45,7 +47,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@Controller
@RequestMapping("/")
public class CreatePolicyController extends RestrictedBaseController{
-
+ private static Logger policyLogger = FlexLogger.getLogger(CreatePolicyController.class);
protected PolicyRestAdapter policyAdapter = null;
private ArrayList<Object> attributeList;
boolean isValidForm = false;
@@ -74,12 +76,13 @@ public class CreatePolicyController extends RestrictedBaseController{
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
policyAdapter.setConfigType(entity.getConfigurationData().getConfigType());
policyAdapter.setConfigBodyData(entity.getConfigurationData().getConfigBody());
- String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("_") + 1);
+ String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf(' ') + 1);
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ policyLogger.error("Error while collecting the desciption tag in ActionPolicy " + policyNameValue ,e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
index f40587d4b..bb06cb3fe 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
@@ -34,11 +34,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.onap.policy.admin.RESTfulPAPEngine;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.model.PDPGroupContainer;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
+import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
import org.onap.policy.xacml.std.pap.StdPDP;
import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.openecomp.policy.model.Roles;
@@ -106,6 +108,9 @@ public class PDPController extends RestrictedBaseController {
}
}
}
+ if(!junit&& controller.getPapEngine()==null){
+ setPAPEngine(request);
+ }
if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST) ) {
if(!junit){
this.groups.addAll(controller.getPapEngine().getOnapPDPGroups());
@@ -156,7 +161,19 @@ public class PDPController extends RestrictedBaseController {
}
}
- @RequestMapping(value={"/get_PDPGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
+ private void setPAPEngine(HttpServletRequest request) {
+ String myRequestURL = request.getRequestURL().toString();
+ try {
+ //
+ // Set the URL for the RESTful PAP Engine
+ //
+ PolicyController.setPapEngine((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
+ }catch(Exception e){
+ policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP",e);
+ }
+ }
+
+ @RequestMapping(value={"/get_PDPGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
public void getPDPGroupEntityData(HttpServletRequest request, HttpServletResponse response){
try{
ObjectMapper mapper = new ObjectMapper();
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
index 35b9b959d..4a6c230c1 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
@@ -40,6 +40,8 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.onap.policy.admin.PolicyNotificationMail;
import org.onap.policy.admin.RESTfulPAPEngine;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.model.PDPGroupContainer;
import org.onap.policy.rest.XACMLRestProperties;
import org.onap.policy.rest.XacmlAdminAuthorization;
@@ -49,6 +51,8 @@ import org.onap.policy.rest.jpa.FunctionDefinition;
import org.onap.policy.rest.jpa.PolicyEntity;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
+import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
import org.openecomp.policy.model.Roles;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
@@ -60,15 +64,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
-
import com.att.research.xacml.util.XACMLProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-
@Controller
@RequestMapping("/")
@@ -321,7 +319,7 @@ public class PolicyController extends RestrictedBaseController {
}
//Policy tabs Model and View
- @RequestMapping(value= {"/policy", "/policy/Editor" } , method = RequestMethod.GET)
+ @RequestMapping(value= {"/policy", "/policy/Editor" } , method = RequestMethod.GET)
public ModelAndView view(HttpServletRequest request){
String myRequestURL = request.getRequestURL().toString();
try {
@@ -341,7 +339,7 @@ public class PolicyController extends RestrictedBaseController {
return papEngine;
}
- public void setPapEngine(PAPPolicyEngine papEngine) {
+ public static void setPapEngine(PAPPolicyEngine papEngine) {
PolicyController.papEngine = papEngine;
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
index bb6f38b8e..a6c6bf6ac 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
@@ -24,6 +24,7 @@ package org.onap.policy.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
@@ -116,7 +117,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
public PolicyExportAndImportController(){}
@RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
String file = null;
selectedPolicy = new ArrayList<>();
@@ -202,7 +203,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
}
//Policy Import
- public JSONObject importRepositoryFile(String file, HttpServletRequest request) throws Exception{
+ public JSONObject importRepositoryFile(String file, HttpServletRequest request) throws IOException{
boolean configExists = false;
boolean actionExists = false;
String configName = null;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
index 731217573..21f3793f1 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyNotificationController.java
@@ -25,6 +25,7 @@ package org.onap.policy.controller;
*
* */
import java.io.File;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@@ -33,6 +34,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
@@ -50,12 +53,13 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
@Controller
@RequestMapping({"/"})
public class PolicyNotificationController extends RestrictedBaseController {
+ private static Logger logger = FlexLogger.getLogger(PolicyNotificationController.class);
@Autowired
CommonClassDao commonClassDao;
@RequestMapping(value={"/watchPolicy"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView watchPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView watchPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
String path = "";
String responseValue = "";
try {
@@ -118,6 +122,7 @@ public class PolicyNotificationController extends RestrictedBaseController {
}catch(Exception e){
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
+ logger.error("Error druing watchPolicy function " + e);
PrintWriter out = response.getWriter();
out.write(e.getMessage());
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyValidationController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyValidationController.java
index 5fb0c1a7e..d1fba383f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyValidationController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyValidationController.java
@@ -22,6 +22,7 @@ package org.onap.policy.controller;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringReader;
@@ -97,7 +98,7 @@ public class PolicyValidationController extends RestrictedBaseController {
CommonClassDao commonClassDao;
@RequestMapping(value={"/policyController/validate_policy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView validatePolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public ModelAndView validatePolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
boolean valid = true;
StringBuilder responseString = new StringBuilder();
@@ -266,6 +267,7 @@ public class PolicyValidationController extends RestrictedBaseController {
valid = false;
}
}catch(Exception e){
+ LOGGER.error("ERROR in ClosedLoop_PM PolicyName" , e);
responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required</i><br>");
valid = false;
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
index 336c42ca8..946f90ac7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
@@ -27,6 +27,7 @@ import java.util.Map;
import javax.script.SimpleBindings;
import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -277,9 +278,8 @@ public class CommonClassDaoImpl implements CommonClassDao{
}finally{
try{
session.close();
- }catch(Exception e1){
+ }catch(HibernateException e1){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
- throw e1;
}
}
return data;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
index ae2144b10..c05a67441 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
@@ -40,66 +40,64 @@ import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.api.pap.PDP;
-//import com.att.research.xacml.api.pap.PDP;
-//import com.att.research.xacml.api.pap.PDPGroup;
import com.att.research.xacml.api.pap.PDPPIPConfig;
import com.att.research.xacml.api.pap.PDPPolicy;
public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed, PolicyContainer.ItemSetChangeNotifier {
private static final long serialVersionUID = 1L;
- private static Logger LOGGER = FlexLogger.getLogger(PDPGroupContainer.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(PDPGroupContainer.class);
/**
* String identifier of a file's "Id" property.
*/
- private static String PROPERTY_ID = "Id";
+ private static final String PROPERTY_ID = "Id";
/**
* String identifier of a file's "name" property.
*/
- private static String PROPERTY_NAME = "Name";
+ private static final String PROPERTY_NAME = "Name";
/**
* String identifier of a file's "Description" property.
*/
- private static String PROPERTY_DESCRIPTION = "Description";
+ private static final String PROPERTY_DESCRIPTION = "Description";
/**
* String identifier of a file's "Default" property.
*/
- private static String PROPERTY_DEFAULT = "Default";
+ private static final String PROPERTY_DEFAULT = "Default";
/**
* String identifier of a file's "Status" property.
*/
- private static String PROPERTY_STATUS = "Status";
+ private static final String PROPERTY_STATUS = "Status";
/**
* String identifier of a file's "PDPs" property.
*/
- private static String PROPERTY_PDPS = "PDPs";
+ private static final String PROPERTY_PDPS = "PDPs";
/**
* String identifier of a file's "Policies" property.
*/
- private static String PROPERTY_POLICIES = "Policies";
+ private static final String PROPERTY_POLICIES = "Policies";
/**
* String identifier of a file's "PIP Configurations" property.
*/
- private static String PROPERTY_PIPCONFIG = "PIP Configurations";
+ private static final String PROPERTY_PIPCONFIG = "PIP Configurations";
/**
* String identifier of a file's "Selected" property.
*/
- private static String PROPERTY_SELECTED = "Selected";
+ private static final String PROPERTY_SELECTED = "Selected";
/**
* List of the string identifiers for the available properties.
*/
- private static Collection<String> PDP_PROPERTIES;
+ private static Collection<String> pDPProperties;
- private PAPPolicyEngine papEngine = null;
- protected List<OnapPDPGroup> groups = Collections.synchronizedList(new ArrayList<OnapPDPGroup>());
+ private transient PAPPolicyEngine papEngine = null;
+ protected transient List<OnapPDPGroup> groups = Collections.synchronizedList(new ArrayList<OnapPDPGroup>());
public PDPGroupContainer(PAPPolicyEngine papPolicyEngine) {
super();
@@ -107,7 +105,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
//
//
//
- this.papEngine = (PAPPolicyEngine) papPolicyEngine;
+ this.papEngine = papPolicyEngine;
//
//
//
@@ -197,7 +195,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
@Override
public Collection<?> getContainerPropertyIds() {
- return PDP_PROPERTIES;
+ return pDPProperties;
}
@Override
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
index 864078439..a3e3e28ad 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
@@ -27,67 +27,68 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.utils.PolicyContainer;
import org.onap.policy.utils.PolicyItemSetChangeNotifier;
-import org.onap.policy.common.logging.flexlogger.*;
-
import org.onap.policy.xacml.api.XACMLErrorConstants;
+import org.onap.policy.xacml.std.pap.StdPDPPolicy;
+
import com.att.research.xacml.api.pap.PDP;
import com.att.research.xacml.api.pap.PDPGroup;
import com.att.research.xacml.api.pap.PDPPolicy;
-import org.onap.policy.xacml.std.pap.StdPDPPolicy;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
private static final long serialVersionUID = 1L;
- private static Logger LOGGER = FlexLogger.getLogger(PDPPolicyContainer.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(PDPPolicyContainer.class);
/**
* String identifier of a file's "Id" property.
*/
- private static String PROPERTY_ID = "Id";
+ private static final String PROPERTY_ID = "Id";
/**
* String identifier of a file's "name" property.
*/
- private static String PROPERTY_NAME = "Name";
+ private static final String PROPERTY_NAME = "Name";
/**
* String identifier of a file's "name" property.
*/
- private static String PROPERTY_VERSION = "Version";
+ private static final String PROPERTY_VERSION = "Version";
/**
* String identifier of a file's "Description" property.
*/
- private static String PROPERTY_DESCRIPTION = "Description";
+ private static final String PROPERTY_DESCRIPTION = "Description";
/**
* String identifier of a file's "IsRoot" property.
*/
- private static String PROPERTY_ISROOT = "Root";
+ private static final String PROPERTY_ISROOT = "Root";
/**
* List of the string identifiers for the available properties.
*/
- private static Collection<String> PDPPOLICY_PROPERTIES;
+ private static Collection<String> pDPPolicyProperties;
- private final Object data;
- private List<PDPPolicy> policies;
+ private final transient Object data;
+ private transient List<PDPPolicy> policies;
@SuppressWarnings("unchecked")
public PDPPolicyContainer(Object data) {
super();
this.data = data;
if (this.data instanceof PDPGroup) {
- policies = new ArrayList<PDPPolicy> (((PDPGroup) this.data).getPolicies());
+ policies = new ArrayList<> (((PDPGroup) this.data).getPolicies());
}
if (this.data instanceof PDP) {
- policies = new ArrayList<PDPPolicy> (((PDP) this.data).getPolicies());
+ policies = new ArrayList<> (((PDP) this.data).getPolicies());
}
if (this.data instanceof Set) {
- policies = new ArrayList<PDPPolicy> ((Set<PDPPolicy>)data);
+ policies = new ArrayList<> ((Set<PDPPolicy>)data);
}
if (this.policies == null) {
LOGGER.info("NULL policies");
@@ -172,7 +173,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
@Override
public Collection<?> getContainerPropertyIds() {
- return PDPPOLICY_PROPERTIES;
+ return pDPPolicyProperties;
}
@Override