private void checkStatus(Response response, int status, String operation, String entityType, String path, ResponseStatus expected) { if (!expected.isExpected(status)) { FailedRequest failure = extractErrorFields(response); if (status == STATUS_NOT_FOUND) { throw new ResourceNotFoundException("Could not " + operation + " " + entityType + " at " + path, failure); } if ("RESTAPI-CONTENTNOVERSION".equals(failure.getMessageCode())) { throw new FailedRequestException("Content version required to " + operation + " " + entityType + " at " + path, failure); } else if (status == STATUS_FORBIDDEN) { throw new ForbiddenUserException("User is not allowed to " + operation + " " + entityType + " at " + path, failure); } throw new FailedRequestException("failed to " + operation + " " + entityType + " at " + path + ": " + getReasonPhrase(response), failure); } }
if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) throw new FailedRequestException( "Content version required to delete document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) throw new FailedRequestException( "Content version must match to delete document", failure); else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) throw new FailedRequestException( "Empty request body sent to server", failure);
if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) { throw new FailedRequestException( "Content version required to delete document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) { throw new FailedRequestException( "Content version must match to delete document", failure); } else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) { throw new FailedRequestException( "Empty request body sent to server", failure);
if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) throw new FailedRequestException( "Content version required to write document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) throw new FailedRequestException( "Content version must match to write document", failure); else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) throw new FailedRequestException( "Empty request body sent to server", failure);
if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) { throw new FailedRequestException( "Content version required to write document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) { throw new FailedRequestException( "Content version must match to write document", failure); } else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) { throw new FailedRequestException( "Empty request body sent to server", failure);
if (status == ClientResponse.Status.FORBIDDEN) { FailedRequest failure = extractErrorFields(response); if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) throw new FailedRequestException( "Content version required to write document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) throw new FailedRequestException( "Content version must match to write document", failure); else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) throw new FailedRequestException( "Empty request body sent to server", failure);
if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) { throw new FailedRequestException( "Content version required to write document", failure); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) { throw new FailedRequestException( "Content version must match to write document", failure); } else if (failure.getMessageCode().equals("RESTAPI-EMPTYBODY")) { throw new FailedRequestException( "Empty request body sent to server", failure);
} catch (FailedRequestException e) { exception = e.toString(); statusCode = e.getFailedRequest().getMessageCode(); expCode = e.getFailedRequest().getStatusCode();
assertEquals("Bad Request", e.getFailedRequest().getStatus()); assertEquals("RESTAPI-INVALIDCONTENT", e.getFailedRequest() .getMessageCode());