Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


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


  public void couldntFind(FilterChain chain, MutableRequest request, MutableResponse response) {
    event.fire(new ControllerNotFound());
    try {
      chain.doFilter(request, response);
    } catch (IOException | ServletException e) {
      throw new InterceptionException(e);
    }
  }
View Full Code Here

    boolean hasAroundMethod = hasAnnotatedMethod(AroundCall.class, originalType, methods);
    boolean hasBeforeMethod = hasAnnotatedMethod(BeforeCall.class, originalType, methods);

    if (!hasAfterMethod && !hasAroundMethod && !hasBeforeMethod) {

      throw new InterceptionException(format("Interceptor %s must "
        + "declare at least one method whith @AfterCall, @AroundCall "
        + "or @BeforeCall annotation", originalType.getCanonicalName()));
    }
  }
View Full Code Here

    Method accepts = invoker.findMethod(methods, Accepts.class, originalType);

    if (accepts != null && !accepts.getReturnType().equals(Boolean.class)
        && !accepts.getReturnType().equals(boolean.class)) {
      throw new InterceptionException(format("@%s method must return "
        + "  boolean", Accepts.class.getSimpleName()));
    }
  }
View Full Code Here

      return new Mirror().on(interceptor).invoke().method(stepMethod).withArgs(params);
    } catch (Exception e) {
      // we dont wanna wrap it if it is a simple controller business logic
      // exception
      Throwables.propagateIfInstanceOf(e.getCause(), ApplicationLogicException.class);
      throw new InterceptionException(e.getCause());
    }
  }
View Full Code Here

      }
    } catch (IllegalStateException e) {
      reportSizeLimitExceeded(e);

    } catch (IOException | ServletException e) {
      throw new InterceptionException(e);
    }

    for (String paramName : params.keySet()) {
      Collection<String> paramValues = params.get(paramName);
      parameters.setParameter(paramName, paramValues.toArray(new String[paramValues.size()]));
View Full Code Here

  public void execute(InterceptorStack stack, ControllerMethod method, Object controllerInstance)
      throws InterceptionException {
    Interceptor interceptor = (Interceptor) 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, controllerInstance);
View Full Code Here

    if(doNotAcceptAfter) after = new DoNothingStepExecutor();
    if(doNotAcceptAround) around = new StackNextExecutor(container);
    if(doNotAcceptBefore) before = new DoNothingStepExecutor();

    if (doNotAcceptAfter && doNotAcceptAround && doNotAcceptBefore) {
      throw new InterceptionException("Interceptor " + interceptorClass.getCanonicalName() + " must declare " +
        "at least one method whith @AfterCall, @AroundCall or @BeforeCall annotation");
    }

    CustomAcceptsExecutor customAcceptsExecutor = new CustomAcceptsExecutor(stepInvoker, container, find(CustomAcceptsFailCallback.class), interceptorClass);
    InterceptorAcceptsExecutor interceptorAcceptsExecutor = new InterceptorAcceptsExecutor(stepInvoker, parametersResolver, find(Accepts.class), interceptorClass);
View Full Code Here

            validator.onErrorUse(nothing());
          } catch (ValidationException e) {
            log.debug("Some validation errors occured: {}", e.getErrors());
          }
        }
        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, controllerInstance);
     
    } catch (IllegalArgumentException | IllegalAccessException e) {
      throw new InterceptionException(e);
     
    } catch (InvocationTargetException e) {
      Throwable cause = e.getCause();
      if (cause instanceof ValidationException) {
        // fine... already parsed
View Full Code Here

    try (OutputStream output = response.getOutputStream()) {
      Download download = resolveDownload(result);
      download.write(response);
      output.flush();
    } 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.