- if (responseString.equals("success")) {
- loggingContext.transactionEnded();
- PolicyLogger.info("Policy successfully deleted!");
- PolicyLogger.audit("Policy successfully deleted!");
- response.setStatus(HttpServletResponse.SC_OK);
- response.addHeader("successMapKey", "success");
- response.addHeader("operation", "delete");
- return;
- } else if (responseString.equals("No Group")) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Group update had bad input.";
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " Group update had bad input.");
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- response.addHeader(ERROR, "groupUpdate");
- response.addHeader("message", message);
- return;
- } else if (responseString.equals("DB Error")) {
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW + " Error while updating group in the database");
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- response.addHeader(ERROR, "deleteDB");
- return;
- } else {
- PolicyLogger.error(MessageCodes.ERROR_UNKNOWN + " Failed to delete the policy for an unknown reason. Check the file system and other logs for further information.");
- response.addHeader(ERROR, UNKNOWN);
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- return;
+ OnapPDPGroup updatedGroup = removePolicy.getUpdatedObject();
+ String userId = request.getParameter("userId");
+ String responseString = deletePolicyFromPdpGroup(updatedGroup, loggingContext, userId);
+
+ switch (responseString) {
+ case SUCCESS:
+ loggingContext.transactionEnded();
+ LOGGER.info("Policy successfully removed from PDP - " + polName + " - RequestId - " + requestId);
+ PolicyLogger.audit("Policy successfully deleted!");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.addHeader("successMapKey", SUCCESS);
+ response.addHeader(OPERATION, DELETE);
+ break;
+ case "No Group":
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Group update had bad input.";
+ LOGGER.error(message + " - RequestId - " + requestId);
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ response.addHeader(ERROR, "groupUpdate");
+ response.addHeader(MESSAGE, message);
+ break;
+ case "DB Error":
+ LOGGER.error(MessageCodes.ERROR_PROCESS_FLOW + " Error while updating group in the database"
+ + " - RequestId - " + requestId);
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ response.addHeader(ERROR, "deleteDB");
+ break;
+ default:
+ LOGGER.error(MessageCodes.ERROR_UNKNOWN
+ + " Failed to delete the policy for an unknown reason. Check the file system and other logs "
+ + "for " + "further information.");
+ response.addHeader(ERROR, UNKNOWN);
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ break;