protected boolean exists(final Location location, final String uri) { try { final ClientResponse response = getNexusClient().uri(uri).head(); if (!ClientResponse.Status.OK.equals(response.getClientResponseStatus())) { if (ClientResponse.Status.NOT_FOUND.equals(response.getClientResponseStatus())) { return false; } throw getNexusClient() .convert( new ContextAwareUniformInterfaceException(response) { @Override public String getMessage(final int status) { if (status == Response.Status.NOT_FOUND.getStatusCode()) { return String.format("Inexistent path: %s", location); } return null; } }); } return true; } catch (ClientHandlerException e) { throw getNexusClient().convert(e); } }
private void throwIf404(final ClientResponse response) { if (ClientResponse.Status.NOT_FOUND.equals(response.getClientResponseStatus())) { throw new NexusClientNotFoundException( response.getClientResponseStatus().getReasonPhrase(), getResponseBody(response)); } }