private void checkStatus(ClientResponse response, ClientResponse.Status status, String operation, String entityType, String path, ResponseStatus expected) { if (!expected.isExpected(status)) { if (status == ClientResponse.Status.NOT_FOUND) { throw new ResourceNotFoundException("Could not " + operation + " " + entityType + " at " + path, extractErrorFields(response)); } if (status == ClientResponse.Status.FORBIDDEN) { throw new ForbiddenUserException("User is not allowed to " + operation + " " + entityType + " at " + path, extractErrorFields(response)); } throw new FailedRequestException("failed to " + operation + " " + entityType + " at " + path + ": " + status.getReasonPhrase(), extractErrorFields(response)); } }
+ type, extractErrorFields(response)); if (status == ClientResponse.Status.NOT_FOUND) throw new ResourceNotFoundException(type + " not found for delete", extractErrorFields(response)); if (status != ClientResponse.Status.NO_CONTENT) throw new FailedRequestException("delete failed: " + status.getReasonPhrase(), extractErrorFields(response));
+ type, extractErrorFields(response)); if (status != ClientResponse.Status.NO_CONTENT) throw new FailedRequestException("delete failed: " + status.getReasonPhrase(), extractErrorFields(response)); response.close();
throw new ForbiddenUserException( "User is not allowed to check the existence of documents", extractErrorFields(response)); else throw new FailedRequestException( "Document existence check failed: " + status.getReasonPhrase(), extractErrorFields(response));
throw new ForbiddenUserException( "User is not allowed to open transactions", extractErrorFields(response)); if (status != ClientResponse.Status.SEE_OTHER) throw new FailedRequestException("transaction open failed: " + status.getReasonPhrase(), extractErrorFields(response));
throw new ForbiddenUserException( "User is not allowed to complete transaction with " + result, extractErrorFields(response)); if (status != ClientResponse.Status.NO_CONTENT) throw new FailedRequestException("transaction " + result + " failed: " + status.getReasonPhrase(), extractErrorFields(response));
throw new ForbiddenUserException( "User is not allowed to get suggestions", extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
} else if (status == ClientResponse.Status.FORBIDDEN) throw new ForbiddenUserException("User is not allowed to read " + type, extractErrorFields(response)); else throw new FailedRequestException(type + " read failed: " + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
FailedRequest failure = extractErrorFields(response); if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) throw new FailedRequestException( FailedRequest failure = extractErrorFields(response); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) throw new FailedRequestException( + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
+ type, extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
extractErrorFields(response)); + status.getReasonPhrase(), extractErrorFields(response));
throw new ResourceNotFoundException( "Could not read non-existent document", extractErrorFields(response)); if (status == ClientResponse.Status.FORBIDDEN) throw new ForbiddenUserException( "User is not allowed to read documents", extractErrorFields(response)); if (status == ClientResponse.Status.NOT_MODIFIED) { response.close(); && status != ClientResponse.Status.PARTIAL_CONTENT) throw new FailedRequestException("read failed: " + status.getReasonPhrase(), extractErrorFields(response));
FailedRequest failure = extractErrorFields(response); if (failure.getMessageCode().equals("RESTAPI-CONTENTNOVERSION")) throw new FailedRequestException( FailedRequest failure = extractErrorFields(response); if (failure.getMessageCode().equals("RESTAPI-CONTENTWRONGVERSION")) throw new FailedRequestException( && status != ClientResponse.Status.NO_CONTENT) { throw new FailedRequestException("write failed: " + status.getReasonPhrase(), extractErrorFields(response));
throw new ResourceNotFoundException( "Could not read non-existent document", extractErrorFields(response)); if (status == ClientResponse.Status.FORBIDDEN) throw new ForbiddenUserException( "User is not allowed to read documents", extractErrorFields(response)); if (status == ClientResponse.Status.NOT_MODIFIED) { response.close(); + status.getReasonPhrase(), extractErrorFields(response));
+ type, extractErrorFields(response)); if (status == ClientResponse.Status.NOT_FOUND) throw new ResourceNotFoundException(type + " not found for write", extractErrorFields(response)); boolean statusOk = false; for (ClientResponse.Status expectedStatus : expectedStatuses) { + status.getReasonPhrase(), extractErrorFields(response));