X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2FConsoleAndApiService.java;h=bde5e5f09bddeaaed77896d27cdb4f0185335c4e;hb=92febb7abd1e6dfe89633d3d92cd70fabf5f0434;hp=41c91ec27bde0b486fe4eee842c6717f712f5bdd;hpb=c683a67fbf4a50e68bf8736517865b43db75ed4b;p=policy%2Fengine.git 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..bde5e5f09 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 @@ -35,7 +35,7 @@ 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; @@ -79,7 +79,7 @@ public class ConsoleAndApiService { * @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"); @@ -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); @@ -368,7 +370,7 @@ public class ConsoleAndApiService { * @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"); @@ -570,7 +572,7 @@ public class ConsoleAndApiService { * @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 { + OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException { PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction(); try { String userId = request.getParameter("userId"); @@ -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= pdpId= <= 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 @@ -811,7 +816,7 @@ public class ConsoleAndApiService { * @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 { + OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException { PolicyDBDaoTransaction removePdpOrGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction(); try { // for all DELETE operations the group must exist before the @@ -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= 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= movePDPsToGroupId=