Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


                validationParameters[0] = newErrors;
                System.arraycopy(parameters, 0, validationParameters, 1, parameters.length);
                try {
                    validationMethod.invoke(resourceInstance, validationParameters);
                } catch (IllegalArgumentException e) {
                    throw new InterceptionException("Unable to validate.", e);
                } catch (IllegalAccessException e) {
                    throw new InterceptionException("Unable to validate.", e);
                } catch (InvocationTargetException e) {
                    throw new InterceptionException("Unable to validate.", e.getCause());
                }
                for (Message msg : convertionErrors) {
                    errors.add(new FixedMessage(msg.getCategory(), msg.getMessage(), msg.getCategory()));
                }
                for (org.vraptor.i18n.ValidationMessage msg : newErrors) {
View Full Code Here


                        } else {
                            throw new IllegalArgumentException("Unsupported validation message type: " + msg.getClass().getName());
                        }
                    }
                } catch (GettingException e) {
                    throw new InterceptionException(
                            "Unable to validate objects due to an exception during validation.", e);
                }
            }
        }
        stack.next(method, resourceInstance);
View Full Code Here

        for (int i = 0; i < names.length; i++) {
            if (names[i].equals(param) || names[i].equals(Info.capitalize(param))) {
                return values[i];
            }
        }
        throw new InterceptionException("Unable to find param for hibernate validator: '" + path + "'");
    }
View Full Code Here

    public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance)
            throws InterceptionException {
        boolean isViewless = method.getMethod().isAnnotationPresent(Viewless.class);
    if (!isViewless && info.isAjax()) {
            if (!method.getMethod().isAnnotationPresent(Remotable.class)) {
                throw new InterceptionException("Unable to make an ajax result in a non-remotable method.");
            }
            int depth = method.getMethod().getAnnotation(Remotable.class).depth();
            JsonOutjecter outjecter = (JsonOutjecter) info.getOutjecter();
            CharSequence output = new JSONSerializer(depth).serialize(outjecter.contents());
            response.setCharacterEncoding(UTF8);
            response.setContentType("application/json");

            try {
                PrintWriter writer = response.getWriter();
                writer.append(output);
                writer.flush();
                writer.close();
            } catch (IOException e) {
                throw new InterceptionException(e);
            }
        } else {
            stack.next(method, resourceInstance);
        }
    }
View Full Code Here

                Object result = outject.invoke(resourceInstance);
                String name = helper.nameForGetter(outject);
                logger.debug("Outjecting {} as {}", name, result);
                outjecter.include(name, result);
            } catch (IllegalArgumentException e) {
                throw new InterceptionException("Unable to outject value for " + outject.getName(), e);
            } catch (IllegalAccessException e) {
                throw new InterceptionException("Unable to outject value for " + outject.getName(), e);
            } catch (InvocationTargetException e) {
                throw new InterceptionException("Unable to outject value for " + outject.getName(), e.getCause());
            }
        }
    }
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)) {
        this.info.setResult(result);
        Type returnType = reflectionMethod.getGenericReturnType();
        outjectResultEvent.fire(new OutjectResultEvent(returnType));
      }
      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

  @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

      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

    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.