@Override
  protected BasicAjaxResponse doDelete(
      HttpServletRequest request, HttpServletResponse response, Role entity) throws Exception {
    final BasicAjaxResponse ajaxResponse = new BasicAjaxResponse();
    final String callerId = getRequesterId(request);
    IdmAuditLog idmAuditLog = new IdmAuditLog();
    idmAuditLog.setRequestorUserId(callerId);
    idmAuditLog.setAction(AuditAction.DELETE_ROLE.value());
    idmAuditLog.setAuditDescription("Delete role");
    idmAuditLog.setTargetResource(entity.getId(), entity.getName());

    final Response wsResponse = roleServiceClient.removeRole(entity.getId(), callerId);
    if (wsResponse.isSuccess()) {
      ajaxResponse.setStatus(200);
      ajaxResponse.setRedirectURL("roles.html");
      ajaxResponse.setSuccessToken(new SuccessToken(SuccessMessage.ROLE_DELETE));
      idmAuditLog.succeed();
    } else {
      ajaxResponse.setErrorList(getDeleteErrors(wsResponse, request, entity));
      idmAuditLog.fail();
      idmAuditLog.setFailureReason(wsResponse.getErrorCode());
      idmAuditLog.setFailureReason(wsResponse.getErrorText());
      idmAuditLog.setTargetResource(entity.getId(), entity.getName());
    }
    auditLogService.addLog(idmAuditLog);

    return ajaxResponse;
  }
  @Override
  protected BasicAjaxResponse doEdit(
      HttpServletRequest request, HttpServletResponse response, Role role) throws Exception {
    final BasicAjaxResponse ajaxResponse = new BasicAjaxResponse();
    IdmAuditLog idmAuditLog = new IdmAuditLog();
    idmAuditLog.setRequestorUserId(getRequesterId(request));
    if (role.getId() == null) {
      idmAuditLog.setAction(AuditAction.ADD_ROLE.value());
      idmAuditLog.setAuditDescription("Create new role");
    } else {
      idmAuditLog.setAction(AuditAction.EDIT_ROLE.value());
      idmAuditLog.setAuditDescription("Edit new role");
    }

    final Response wsResponse = roleServiceClient.saveRole(role, getRequesterId(request));
    if (wsResponse.isSuccess()) {
      String roleId = (String) wsResponse.getResponseValue();
      ajaxResponse.setStatus(200);
      ajaxResponse.setSuccessToken(new SuccessToken(SuccessMessage.ROLE_SAVED));
      if (StringUtils.isBlank(role.getId())) {
        ajaxResponse.setRedirectURL(
            new StringBuilder("editRole.html?id=")
                .append(wsResponse.getResponseValue())
                .toString());
      }
      idmAuditLog.setTargetRole(roleId, role.getName());
      idmAuditLog.succeed();
    } else {
      final List<ErrorToken> errorList = getEditErrors(wsResponse, request, role);
      ajaxResponse.setErrorList(errorList);
      ajaxResponse.setStatus(500);
      idmAuditLog.fail();
      idmAuditLog.setFailureReason(wsResponse.getErrorCode());
      idmAuditLog.setFailureReason(wsResponse.getErrorText());
      idmAuditLog.setTargetRole(role.getId(), role.getName());
    }
    auditLogService.addLog(idmAuditLog);
    return ajaxResponse;
  }