Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


    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


                        } 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

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

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

        } catch (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

        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

        }
      }

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

  }
View Full Code Here

   */
  @Test
  public void withRootException() {
  final Exception e = new IllegalStateException();
  when(mapper.findByException(e)).thenReturn(mockRecorder);
  doThrow(new InterceptionException(e)).when(stack).next(method, instance);

  interceptor.intercept(stack, method, instance);
  verify(mockRecorder).replay(result);
  }
View Full Code Here

   */
  @Test
  public void whenNotFoundException() {
  final Exception e = new IllegalArgumentException();
  when(mapper.findByException(e)).thenReturn(null);
  doThrow(new InterceptionException(e)).when(stack).next(method, instance);

  try {
    interceptor.intercept(stack, method, instance);
    fail("Should throw InterceptionException");
  } catch (InterceptionException e2) {
View Full Code Here

    boolean hasAfterMethod = hasAnnotatedMethod(AfterCall.class, originalType, methods);
    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

  @Override
  public void validate(Class<?> originalType, MirrorList<Method> methods) {
    Method accepts = invoker.findMethod(methods, Accepts.class, originalType);

    if (accepts != null && !isBooleanReturn(accepts.getReturnType())) {
      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
      propagateIfInstanceOf(e.getCause(), ApplicationLogicException.class);
      throw new InterceptionException(e.getCause());
    }
  }
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.