Examples of PreconditionFailedException


Examples of br.com.caelum.restfulie.http.error.PreconditionFailedException

      throw new GoneException("Http error " + code
          + " when executing request");
    }

    if (code == 412) {
      throw new PreconditionFailedException("Http error " + code
          + " when executing request");
    }

    if (code == 402 || code == 406 || code == 408 || code == 411
        || (code >= 413 && code <= 499)) {
View Full Code Here

Examples of br.gov.frameworkdemoiselle.PreconditionFailedException

  public void insertFailed() throws Exception {
    HttpPost request;
    CloseableHttpResponse response;
    Bookmark bookmark;
    Set<PreconditionFailedException.Violation> violations;
    PreconditionFailedException expected;

    bookmark = new Bookmark();
    bookmark.setDescription("Google");
    bookmark.setLink("http://google.com");
    request = new HttpPost(url + "/bookmark");
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    response = client.execute(request);
    response.close();
    assertEquals(SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());

    bookmark = new Bookmark();
    request = new HttpPost(url + "/bookmark");
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<PreconditionFailedException.Violation>>() {
        });
    expected = new PreconditionFailedException();
    expected.addViolation("description", "não pode ser nulo");
    expected.addViolation("link", "não pode ser nulo");
    assertEquals(expected.getViolations(), violations);

    bookmark = new Bookmark();
    bookmark.setDescription("Google");
    bookmark.setLink("http: // google . com");
    request = new HttpPost(url + "/bookmark");
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<PreconditionFailedException.Violation>>() {
        });
    expected = new PreconditionFailedException().addViolation("link", "formato inválido");
    assertEquals(expected.getViolations(), violations);

    bookmark = new Bookmark();
    bookmark.setId(Long.valueOf(123456789));
    bookmark.setDescription("Test");
    bookmark.setLink("http://test.com");
View Full Code Here

Examples of br.gov.frameworkdemoiselle.PreconditionFailedException

    CloseableHttpResponse response = createSample();
    response.close();
    Long id = parseEntity(response.getEntity(), Long.class);
    Bookmark bookmark;
    Set<PreconditionFailedException.Violation> violations;
    PreconditionFailedException expected;

    bookmark = new Bookmark();
    bookmark.setDescription("Google");
    bookmark.setLink("http://google.com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    response = client.execute(request);
    response.close();
    assertEquals(SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());

    bookmark = new Bookmark();
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<PreconditionFailedException.Violation>>() {
        });
    expected = new PreconditionFailedException();
    expected.addViolation("description", "não pode ser nulo");
    expected.addViolation("link", "não pode ser nulo");
    assertEquals(expected.getViolations(), violations);

    bookmark = new Bookmark();
    bookmark.setDescription("Google");
    bookmark.setLink("http: // google . com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<PreconditionFailedException.Violation>>() {
        });
    expected = new PreconditionFailedException().addViolation("link", "formato inválido");
    assertEquals(expected.getViolations(), violations);

    bookmark = new Bookmark();
    bookmark.setId(Long.valueOf(123456789));
    bookmark.setDescription("Test");
    bookmark.setLink("http://test.com");
View Full Code Here

Examples of br.gov.frameworkdemoiselle.PreconditionFailedException

@Provider
public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {

  @Override
  public Response toResponse(ConstraintViolationException exception) {
    PreconditionFailedException failed = new PreconditionFailedException();

    for (Iterator<ConstraintViolation<?>> iter = exception.getConstraintViolations().iterator(); iter.hasNext();) {
      ConstraintViolation<?> violation = iter.next();
      failed.addViolation(violation.getPropertyPath().toString(), violation.getMessage());
    }

    return Response.status(PRECONDITION_FAILED).entity(failed.getViolations()).build();
  }
View Full Code Here

Examples of com.amazonaws.services.cloudfront.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here

Examples of com.amazonaws.services.cloudfront.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here

Examples of com.amazonaws.services.cloudfront.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here

Examples of com.amazonaws.services.cloudfront.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here

Examples of com.amazonaws.services.cloudfront_2012_03_15.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here

Examples of com.amazonaws.services.cloudfront_2012_03_15.model.PreconditionFailedException

        // marshaller understands.
        String errorCode = parseErrorCode(node);
        if (errorCode == null || !errorCode.equals("PreconditionFailed"))
            return null;

        PreconditionFailedException e = (PreconditionFailedException)super.unmarshall(node);
       
        return e;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.