- //This would occur if we received a notification of a policy creation or update
- String policyToCreateUpdate = request.getParameter("policyToCreateUpdate");
- if(policyToCreateUpdate != null){
- if(LOGGER.isDebugEnabled()){
- LOGGER.debug("\nXACMLPapServlet.doPut() - before decoding"
- + "\npolicyToCreateUpdate = " + policyToCreateUpdate);
- }
- //decode it
- try{
- policyToCreateUpdate = URLDecoder.decode(policyToCreateUpdate, "UTF-8");
- if(LOGGER.isDebugEnabled()){
- LOGGER.debug("\nXACMLPapServlet.doPut() - after decoding"
- + "\npolicyToCreateUpdate = " + policyToCreateUpdate);
- }
- } catch(UnsupportedEncodingException e){
- PolicyLogger.error("\nXACMLPapServlet.doPut() - Unsupported URL encoding of policyToCreateUpdate (UTF-8)"
- + "\npolicyToCreateUpdate = " + policyToCreateUpdate);
- response.sendError(500,"policyToCreateUpdate encoding not supported"
- + "\nfailure with the following exception: " + e);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See error.log");
- im.endTransaction();
- return;
- }
- //send it to PolicyDBDao
- PolicyDBDaoTransaction createUpdateTransaction = policyDBDao.getNewTransaction();
- try{
- createUpdateTransaction.createPolicy(policyToCreateUpdate, "XACMLPapServlet.doPut");
- }catch(Exception e){
- createUpdateTransaction.rollbackTransaction();
- response.sendError(500,"createUpdateTransaction.createPolicy(policyToCreateUpdate, XACMLPapServlet.doPut) "
- + "\nfailure with the following exception: " + e);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See error.log");
- im.endTransaction();
- return;
- }
- createUpdateTransaction.commitTransaction();
- // Before sending Ok. Lets call AutoPush.
- if(autoPushFlag){
- Set<StdPDPGroup> changedGroups = autoPushPolicy.checkGroupsToPush(policyToCreateUpdate, XACMLPapServlet.papEngine);
- if(!changedGroups.isEmpty()){
- for(StdPDPGroup group: changedGroups){
- try{
- papEngine.updateGroup(group);
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Group '" + group.getId() + "' updated");
- }
- notifyAC();
- // Group changed, which might include changing the policies
- groupChanged(group);
- }catch(Exception e){
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW + " Failed to Push policy. ");
- }
- }
- }
- }
- response.setStatus(HttpServletResponse.SC_OK);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Ended Successfully");
- im.endTransaction();
- return;
- }