public NexusClientNotFoundException convertIf404( final UniformInterfaceException e ) { final ClientResponse response = e.getResponse(); if ( ClientResponse.Status.NOT_FOUND.equals( response.getClientResponseStatus() ) ) { return new NexusClientNotFoundException( getMessageIfPresent( ClientResponse.Status.NOT_FOUND.getStatusCode(), e ), response.getClientResponseStatus().getReasonPhrase(), getResponseBody( response ) ); } return null; }
@Override public String getMetadataPath(final String repositoryId, final MetadataType metadataType) throws IOException { try { final String url = ensureUrlEndsWithSlash(repositoryId); final String location = getLocationOfMetadata(url, metadataType); if (location != null) { return "/" + location; } throw new NexusClientNotFoundException( "Could not find metadata type '" + metadataType.getType() + "'", null ); } catch (UniformInterfaceException e) { throw getNexusClient().convert(e); } catch (ClientHandlerException e) { throw getNexusClient().convert(e); } }
@Override public String getMetadataUrl(final String repositoryId, final MetadataType metadataType) throws IOException { try { final String url = ensureUrlEndsWithSlash(repositoryId); final String location = getLocationOfMetadata(url, metadataType); if (location != null) { return url + location; } throw new NexusClientNotFoundException( "Could not find metadata type '" + metadataType.getType() + "'", null ); } catch (UniformInterfaceException e) { throw getNexusClient().convert(e); } catch (ClientHandlerException e) { throw getNexusClient().convert(e); } }
@Override public <T> T getMetadata(final String repositoryId, final MetadataType metadataType, final Class<T> returnType) throws IOException { try { final String url = ensureUrlEndsWithSlash(repositoryId); final String location = getLocationOfMetadata(url, metadataType); if (location != null) { return handleResponse( getNexusClient().getClient().resource(url + location).get(ClientResponse.class), returnType, metadataType.getCompression() ); } throw new NexusClientNotFoundException( "Could not find metadata type '" + metadataType.getType() + "'", null ); } catch (UniformInterfaceException e) { throw getNexusClient().convert(e); } catch (ClientHandlerException e) { throw getNexusClient().convert(e); } }
@Override public <T> T getMetadata(final String repositoryId, final String version, final MetadataType metadataType, final Class<T> returnType) throws IOException { try { final String url = getNexusClient().resolveServicePath("yum/repos/" + repositoryId + "/" + version + "/"); final String location = getLocationOfMetadata(url, metadataType); if (location != null) { return handleResponse( getNexusClient().getClient().resource(url + location).get(ClientResponse.class), returnType, metadataType.getCompression() ); } throw new NexusClientNotFoundException( "Could not find metadata type '" + metadataType.getType() + "'", null ); } catch (UniformInterfaceException e) { throw getNexusClient().convert(e); } catch (ClientHandlerException e) { throw getNexusClient().convert(e); } }