Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


    try {
      stack.next(method, controller);
      mailer.deliverPostponedMails();
    } catch (Exception e) {
      LOGGER.error("The following emails were not delivered because of an exception: {}", mailer.clearPostponedMails());
      throw new InterceptionException(e);
    }
  }
View Full Code Here


    try {
      if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) {
        request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
      }
    } catch (IOException e) {
      throw new InterceptionException(e);
    }
  }
View Full Code Here

  public void couldntFind(RequestInfo request) {
    FilterChain chain = request.getChain();
    try {
      chain.doFilter(request.getRequest(), request.getResponse());
    } catch (IOException | ServletException e) {
      throw new InterceptionException(e);
    }
  }
View Full Code Here

      download.write(response);

      output.flush();
      output.close();
    } catch (IOException e) {
      throw new InterceptionException(e);
    }

  }
View Full Code Here

      log.debug("Invoking {}", Stringnifier.simpleNameFor(reflectionMethod));
      Object result = reflectionMethod.invoke(resourceInstance, parameters);

      if (validator.hasErrors()) { // method should have thrown
        // ValidationError
        throw new InterceptionException(
            "There are validation errors and you forgot to specify where to go. Please add in your method "
                + "something like:\n"
                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }

      if (reflectionMethod.getReturnType().equals(Void.TYPE)) {
        // vraptor2 compatibility
        this.info.setResult("ok");
      } else {
        this.info.setResult(result);
      }
      stack.next(method, resourceInstance);
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (IllegalAccessException e) {
      throw new InterceptionException(e);
    } catch (InvocationTargetException e) {
      Throwable cause = e.getCause();
      if (cause instanceof ValidationException) {
        // fine... already parsed
        log.trace("swallowing {}", cause);
      } else {
        throw new InterceptionException("an exception was raised while executing resource method", cause);
      }
    }
  }
View Full Code Here

  public void execute(InterceptorStack stack, ResourceMethod method, Object resourceInstance)
      throws InterceptionException {
    Interceptor interceptor = Interceptor.class.cast(container.instanceFor(type));
    if (interceptor == null) {
      throw new InterceptionException("Unable to instantiate interceptor for " + type.getName()
          + ": the container returned null.");
    }
    if (interceptor.accepts(method)) {
      logger.debug("Invoking interceptor {}", interceptor.getClass().getSimpleName());
      interceptor.intercept(stack, method, resourceInstance);
View Full Code Here

        }
      }

      stack.next(method, resourceInstance);
    } catch (IOException e) {
      throw new InterceptionException(e);
    }

  }
View Full Code Here

      Object resourceInstance) throws InterceptionException {
    try {
      request.setCharacterEncoding(UTF_8);
      response.setCharacterEncoding(UTF_8);
    } catch (UnsupportedEncodingException e) {
      throw new InterceptionException(e);
    }
    stack.next(method, resourceInstance);
  }
View Full Code Here

  public void couldntFind(RequestInfo request) {
    FilterChain chain = request.getChain();
    try {
      chain.doFilter(request.getRequest(), request.getResponse());
    } catch (IOException e) {
      throw new InterceptionException(e);
    } catch (ServletException e) {
      throw new InterceptionException(e);
    }
  }
View Full Code Here

    request.getResponse().addHeader(
        "Allow", allowedMethods.toString().replaceAll("\\[|\\]", ""));
    try {
      request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } catch (IOException e) {
      throw new InterceptionException(e);
    }
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.InterceptionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.