Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


    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


        }
      }

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

  }
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

    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 e) {
      throw new InterceptionException(e);
    } catch (MethodExecutorException e) {
      throwIfNotValidationException(e,
          new ApplicationLogicException("your controller raised an exception", e.getCause()));
    } catch (Exception e) {
      throwIfNotValidationException(e, new InterceptionException(e));
    }
  }
View Full Code Here

      return methodExecutor.invoke(stepMethod, interceptor, params);
    } catch (MethodExecutorException 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

        }
      }

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

  }
View Full Code Here

        buildURI(entry.getValue());
        scheduler.schedule(DefaultRequestScopedTask.class, entry.getValue(), entry.getKey());
      }
      handler.markAsScheduled();
    } catch (Exception e) {
      throw new InterceptionException(e);
    }
    stack.next(method, resourceInstance);
  }
View Full Code Here

  @Override
  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

            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.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (Exception e) {
      throwIfNotValidationException(e, new ApplicationLogicException(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.