Ejemplo n.º 1
0
  /**
   * Handles performing a create on a resource, and optionally returns an associated result. The
   * request is first logged.
   *
   * @param context {@inheritDoc}
   * @param request {@inheritDoc}
   * @return {@inheritDoc}
   */
  @Override
  public Promise<ResourceResponse, ResourceException> filterCreate(
      Context context, CreateRequest request, RequestHandler next) {
    final String resource = ServerContextUtils.getResourceId(request, context);
    final String action = ServerContextUtils.getCreateString(request);

    logAccess(resource, action, context);
    return next.handleCreate(context, request);
  }
Ejemplo n.º 2
0
  /**
   * Records an 'access' audit event before and after the filtered CREST resource receives an create
   * request.
   *
   * <p>If the 'before' audit event fails due to an error, the request is cancelled and an error
   * response is returned. If the 'after' audit event fails due to an error, the request is not
   * cancelled as it's affects may have already been applied.
   *
   * @param context {@inheritDoc}
   * @param request {@inheritDoc}
   * @param next {@inheritDoc}
   */
  @Override
  public Promise<ResourceResponse, ResourceException> filterCreate(
      Context context, CreateRequest request, RequestHandler next) {

    AuditingResultHandler auditingHandler = newAuditingResultHandler(context, request);
    try {
      auditingHandler.auditAccessAttempt();
    } catch (AuditException e) {
      return newExceptionPromise(ResourceException.getException(ResourceException.INTERNAL_ERROR));
    }

    return auditResponse(next.handleCreate(context, request), auditingHandler);
  }
Ejemplo n.º 3
0
  /**
   * Records an 'access' audit event before and after the filtered CREST resource receives an create
   * request.
   *
   * <p>If the 'before' audit event fails due to an error, the request is cancelled and an error
   * response is returned. If the 'after' audit event fails due to an error, the request is not
   * cancelled as it's affects may have already been applied.
   *
   * @param context {@inheritDoc}
   * @param request {@inheritDoc}
   * @param handler {@inheritDoc}
   * @param next {@inheritDoc}
   */
  @Override
  public void filterCreate(
      ServerContext context,
      CreateRequest request,
      ResultHandler<Resource> handler,
      RequestHandler next) {

    AuditingResultHandler<Resource> auditingHandler =
        newAuditingResultHandler(context, request, handler);
    try {
      auditingHandler.auditAccessAttempt();
    } catch (AuditException e) {
      handler.handleError(ResourceException.getException(ResourceException.INTERNAL_ERROR));
      return;
    }

    next.handleCreate(context, request, auditingHandler);
  }