aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-10 01:49:27 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-10 01:49:27 +0000
commit418b33f0488a4e80667d7d998620b20ced1f3882 (patch)
tree2de3562b69fdaf72523af66979f81f23689f66ae /ONAP-PAP-REST/src/main
parenta654d6f4986f9151ee58cec93388c5d006ac17e8 (diff)
parent3c51deca3d848a988f16a88c04327d6c61026d54 (diff)
Merge "New junits and bug fixes"
Diffstat (limited to 'ONAP-PAP-REST/src/main')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java16
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java54
2 files changed, 36 insertions, 34 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
index 41c91ec27..52e4060b5 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
@@ -185,7 +185,8 @@ public class ConsoleAndApiService {
if (policyId.contains("Config_MS_") || policyId.contains("BRMS_Param")) {
PushPolicyHandler pushPolicyHandler = PushPolicyHandler.getInstance();
policyForSafetyCheck.setId(policyId);
- if (pushPolicyHandler.preSafetyCheck(policyForSafetyCheck, XACMLPapServlet.getConfigHome())) {
+ if (pushPolicyHandler.preSafetyCheck(policyForSafetyCheck,
+ XACMLPapServlet.getConfigHome())) {
LOGGER.debug("Precheck Successful.");
}
}
@@ -218,8 +219,8 @@ public class ConsoleAndApiService {
}
/*
- * If request comes from the API we need to run the PolicyDBDao updateGroup() to
- * notify other paps of the change. The GUI does this from the POLICY-SDK-APP code.
+ * If request comes from the API we need to run the PolicyDBDao updateGroup() to notify other paps of
+ * the change. The GUI does this from the POLICY-SDK-APP code.
*/
// Get new transaction to perform updateGroup()
@@ -288,7 +289,8 @@ public class ConsoleAndApiService {
// It should never be the case that multiple groups are
// currently marked as the default, but protect against that
// anyway.
- PolicyDBDaoTransaction setDefaultGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
+ PolicyDBDaoTransaction setDefaultGroupTransaction =
+ XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
setDefaultGroupTransaction.changeDefaultGroup(group, PAPSERVLETDOACPOST);
papEngine.setDefaultGroup(group);
@@ -587,6 +589,7 @@ public class ConsoleAndApiService {
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_NOT_FOUND, message);
+ acPutTransaction.rollbackTransaction();
return;
}
if (request.getParameter("policy") != null) {
@@ -601,6 +604,7 @@ public class ConsoleAndApiService {
PolicyLogger.audit(TRANSACTIONFAILED);
auditLogger.info(SUCCESS);
PolicyLogger.audit(TRANSENDED);
+ acPutTransaction.rollbackTransaction();
return;
} else if (request.getParameter("pdpId") != null) {
// ARGS: group=<groupId> pdpId=<pdpId/URL> <= create a new PDP
@@ -708,6 +712,7 @@ public class ConsoleAndApiService {
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_BAD_REQUEST, "UNIMPLEMENTED");
+ acPutTransaction.rollbackTransaction();
return;
} else {
// Assume that this is an update of an existing PDP Group
@@ -824,6 +829,7 @@ public class ConsoleAndApiService {
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_NOT_FOUND, "Unknown groupId '" + groupId + "'");
+ removePdpOrGroupTransaction.rollbackTransaction();
return;
}
// determine the operation needed based on the parameters in the
@@ -836,6 +842,7 @@ public class ConsoleAndApiService {
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_BAD_REQUEST, "UNIMPLEMENTED");
+ removePdpOrGroupTransaction.rollbackTransaction();
return;
} else if (request.getParameter("pdpId") != null) {
// ARGS: group=<groupId> pdpId=<pdpId> <= delete PDP
@@ -865,6 +872,7 @@ public class ConsoleAndApiService {
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_BAD_REQUEST, "UNIMPLEMENTED");
+ removePdpOrGroupTransaction.rollbackTransaction();
return;
} else {
// ARGS: group=<groupId> movePDPsToGroupId=<movePDPsToGroupId>
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java
index 571a82036..780ed86c7 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.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,7 @@
package org.onap.policy.pap.xacml.rest.components;
+import com.att.research.xacml.api.pap.PAPException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -31,18 +32,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-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.dao.CommonClassDao;
-import org.onap.policy.rest.jpa.FunctionDefinition;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
-
-import com.att.research.xacml.api.pap.PAPException;
-
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;
@@ -58,12 +47,17 @@ 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.eelf.MessageCodes;
+import org.onap.policy.common.logging.eelf.PolicyLogger;
+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.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.FunctionDefinition;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
public class ActionPolicy extends Policy {
- /**
- * ActionPolicy Fields
- */
private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicy.class);
public static final String JSON_CONFIG = "JSON";
@@ -93,7 +87,7 @@ public class ActionPolicy extends Policy {
private static boolean isAttribute = false;
- private synchronized static boolean getAttribute() {
+ private static synchronized boolean getAttribute() {
return isAttribute;
}
@@ -122,7 +116,7 @@ public class ActionPolicy extends Policy {
}
if (!isPreparedToSave()) {
- //Prep and configure the policy for saving
+ // Prep and configure the policy for saving
prepareToSave();
}
@@ -133,13 +127,13 @@ public class ActionPolicy extends Policy {
return successMap;
}
- //This is the method for preparing the policy for saving. We have broken it out
- //separately because the fully configured policy is used for multiple things
+ // This is the method for preparing the policy for saving. We have broken it out
+ // separately because the fully configured policy is used for multiple things
@Override
public boolean prepareToSave() throws PAPException {
if (isPreparedToSave()) {
- //we have already done this
+ // we have already done this
return true;
}
@@ -165,15 +159,15 @@ public class ActionPolicy extends Policy {
String actionBody = policyAdapter.getActionBody();
setAttribute(false);
- //if actionBody is null or empty then we know the ActionAttribute in the request does not exist in the
+ // if actionBody is null or empty then we know the ActionAttribute in the request does not exist in the
// dictionary
if (!(actionBody == null || "".equals(actionBody))) {
saveActionBody(policyName, actionBody);
setAttribute(true);
} else {
if (!getAttribute()) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Could not find " + comboDictValue +
- " in the ActionPolicyDict table.");
+ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Could not find " + comboDictValue
+ + " in the ActionPolicyDict table.");
return false;
}
}
@@ -237,8 +231,8 @@ public class ActionPolicy extends Policy {
}
// if rule algorithm not a compound
if (!isCompound) {
- condition.setExpression(new ObjectFactory().createApply(getInnerActionApply(
- dynamicLabelRuleAlgorithms.get(index))));
+ condition.setExpression(new ObjectFactory()
+ .createApply(getInnerActionApply(dynamicLabelRuleAlgorithms.get(index))));
}
rule.setCondition(condition);
}
@@ -247,8 +241,8 @@ public class ActionPolicy extends Policy {
actionPolicy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule);
policyAdapter.setPolicyData(actionPolicy);
} else {
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "Unsupported data object." + Objects
- .requireNonNull(policyAdapter.getData()).getClass().getCanonicalName());
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "Unsupported data object."
+ + Objects.requireNonNull(policyAdapter.getData()).getClass().getCanonicalName());
}
setPreparedToSave(true);
@@ -502,11 +496,11 @@ public class ActionPolicy extends Policy {
public String getFunctionDefinitionId(String key) {
FunctionDefinition object =
- (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+ (FunctionDefinition) commonClassDao.getEntityItem(FunctionDefinition.class, "short_name", key);
if (object != null) {
return object.getXacmlid();
}
return null;
}
-} \ No newline at end of file
+}