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); } }
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)); } }