import com.att.research.xacml.api.pap.PAPException;
import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcPost(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
PolicyDBDaoTransaction doAcPostTransaction = null;
try {
String groupName = request.getParameter("groupName");
} catch (UnsupportedEncodingException e) {
LOGGER.error(e);
}
- PolicyDBDaoTransaction newGroupTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ PolicyDBDaoTransaction newGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
newGroupTransaction.createGroup(PolicyDBDao.createNewPDPGroupId(unescapedName), unescapedName,
unescapedDescription, PAPSERVLETDOACPOST);
StdPDPPolicy policyForSafetyCheck = new StdPDPPolicy();
for (String policyId : policyIdList) {
PolicyDBDaoTransaction addPolicyToGroupTransaction =
- XACMLPapServlet.policyDBDao.getNewTransaction();
+ XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
// Copying the policy to the file system and updating groups
// in database
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.");
}
}
}
/*
- * 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()
- PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
// Assume that this is an update of an existing PDP
// Group
// It should never be the case that multiple groups are
// currently marked as the default, but protect against that
// anyway.
- PolicyDBDaoTransaction setDefaultGroupTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ PolicyDBDaoTransaction setDefaultGroupTransaction =
+ XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
setDefaultGroupTransaction.changeDefaultGroup(group, PAPSERVLETDOACPOST);
papEngine.setDefaultGroup(group);
LOGGER.info(TRANSENDED);
return;
} else if (request.getParameter("pdpId") != null) {
- doAcPostTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ doAcPostTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
// Args: group=<groupId> pdpId=<pdpId> <= move PDP to group
loggingContext.setServiceName("AC:PAP.movePDP");
String pdpId = request.getParameter("pdpId");
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcGet(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
try {
String parameterDefault = request.getParameter("default");
String pdpId = request.getParameter("pdpId");
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcPut(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
- PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
String userId = request.getParameter("userId");
// for PUT operations the group may or may not need to exist before
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_NOT_FOUND, message);
+ acPutTransaction.rollbackTransaction();
return;
}
if (request.getParameter("policy") != null) {
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
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
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcDelete(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
- PolicyDBDaoTransaction removePdpOrGroupTransaction = XACMLPapServlet.policyDBDao.getNewTransaction();
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ PolicyDBDaoTransaction removePdpOrGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
// for all DELETE operations the group must exist before the
// operation can be done
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
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
loggingContext.transactionEnded();
PolicyLogger.audit(TRANSACTIONFAILED);
setResponseError(response, HttpServletResponse.SC_BAD_REQUEST, "UNIMPLEMENTED");
+ removePdpOrGroupTransaction.rollbackTransaction();
return;
} else {
// ARGS: group=<groupId> movePDPsToGroupId=<movePDPsToGroupId>