Package org.springframework.web

Examples of org.springframework.web.HttpRequestMethodNotSupportedException


      throws Exception {

    final RepositoryInvoker invoker = repoRequest.getInvoker();

    if (!invoker.exposesSave()) {
      throw new HttpRequestMethodNotSupportedException(HttpMethod.DELETE.name());
    }

    Function<ReferencedProperty, ResourceSupport> handler = new Function<ReferencedProperty, ResourceSupport>() {

      @Override
View Full Code Here


      String propertyPath, Function<ReferencedProperty, ResourceSupport> handler, HttpMethod method) throws Exception {

    RepositoryInvoker invoker = repoRequest.getInvoker();

    if (!invoker.exposesFindOne()) {
      throw new HttpRequestMethodNotSupportedException(method.name());
    }

    Object domainObj = invoker.invokeFindOne(id);

    if (null == domainObj) {
View Full Code Here

      for (HttpMethod supportedMethod : supportedMethods) {
        stringMethods.add(supportedMethod.name());
      }

      throw new HttpRequestMethodNotSupportedException(httpMethod.name(), stringMethods);
    }
  }
View Full Code Here

  @Override
  public void handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    if (!"POST".equals(request.getMethod())) {
      throw new HttpRequestMethodNotSupportedException(request.getMethod(),
          new String[] {"POST"}, "BurlapServiceExporter only supports POST requests");
    }

    try {
      invoke(request.getInputStream(), response.getOutputStream());
View Full Code Here

        }
        return targetHandlerMethods.get(bestMappingMatch);
      }
      else {
        if (!allowedMethods.isEmpty()) {
          throw new HttpRequestMethodNotSupportedException(request.getMethod(), StringUtils.toStringArray(allowedMethods));
        }
        throw new NoSuchRequestHandlingMethodException(lookupPath, request.getMethod(), request.getParameterMap());
      }
    }
View Full Code Here

      throws ServletException {

    // Check whether we should support the request method.
    String method = request.getMethod();
    if (this.supportedMethods != null && !this.supportedMethods.contains(method)) {
      throw new HttpRequestMethodNotSupportedException(
          method, StringUtils.toStringArray(this.supportedMethods));
    }

    // Check whether a session is required.
    if (this.requireSession) {
View Full Code Here

    if (!ServletAnnotationMappingUtils.checkRequestMethod(mappedMethods, request)) {
      String[] supportedMethods = new String[mappedMethods.length];
      for (int i = 0; i < mappedMethods.length; i++) {
        supportedMethods[i] = mappedMethods[i].name();
      }
      throw new HttpRequestMethodNotSupportedException(request.getMethod(), supportedMethods);
    }

    String[] mappedParams = mapping.params();
    if (!ServletAnnotationMappingUtils.checkParameters(mappedParams, request)) {
      throw new UnsatisfiedServletRequestParameterException(mappedParams, request.getParameterMap());
View Full Code Here

    if (patternMatches.isEmpty()) {
      return null;
    }
    else if (patternAndMethodMatches.isEmpty() && !allowedMethods.isEmpty()) {
      throw new HttpRequestMethodNotSupportedException(request.getMethod(), allowedMethods);
    }

    Set<MediaType> consumableMediaTypes;
    Set<MediaType> producibleMediaTypes;
    Set<String> paramConditions;
View Full Code Here

  }

  @Test
  public void httpRequestMethodNotSupported() {
    List<String> supported = Arrays.asList("POST", "DELETE");
    Exception ex = new HttpRequestMethodNotSupportedException("GET", supported);

    ResponseEntity<Object> responseEntity = testException(ex);
    assertEquals(EnumSet.of(HttpMethod.POST, HttpMethod.DELETE), responseEntity.getHeaders().getAllow());

  }
View Full Code Here

    assertEquals("Invalid status code", 404, response.getStatus());
  }

  @Test
  public void handleHttpRequestMethodNotSupported() {
    HttpRequestMethodNotSupportedException ex =
        new HttpRequestMethodNotSupportedException("GET", new String[]{"POST", "PUT"});
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 405, response.getStatus());
    assertEquals("Invalid Allow header", "POST, PUT", response.getHeader("Allow"));
View Full Code Here

TOP

Related Classes of org.springframework.web.HttpRequestMethodNotSupportedException

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.