private void mergeMetadata( RepositorySystemSession session, RequestTrace trace, Versions versions, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) { try { Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE ); Metadata repoMetadata = metadataReader.read( metadata.getFile(), options ); mergeMetadata( versions, repoMetadata, repository ); } catch ( IOException e ) { invalidMetadata( session, trace, metadata, repository, e ); } } }
private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request, RequestTrace trace, String pluginGroup, org.eclipse.aether.metadata.Metadata metadata, ArtifactRepository repository ) { if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() ) { try { Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE ); Metadata pluginGroupMetadata = metadataReader.read( metadata.getFile(), options ); List<org.apache.maven.artifact.repository.metadata.Plugin> plugins = pluginGroupMetadata.getPlugins(); if ( plugins != null ) { for ( org.apache.maven.artifact.repository.metadata.Plugin plugin : plugins ) { if ( request.getPrefix().equals( plugin.getPrefix() ) ) { return new DefaultPluginPrefixResult( pluginGroup, plugin.getArtifactId(), repository ); } } } } catch ( IOException e ) { invalidMetadata( request.getRepositorySession(), trace, metadata, repository, e ); } } return null; }
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, VersionRangeResult result ) { Versioning versioning = null; try { if ( metadata != null ) { try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) ) { syncContext.acquire( null, Collections.singleton( metadata ) ); if ( metadata.getFile() != null && metadata.getFile().exists() ) { try ( final InputStream in = new FileInputStream( metadata.getFile() ) ) { versioning = new MetadataXpp3Reader().read( in, false ).getVersioning(); } } } } } catch ( Exception e ) { invalidMetadata( session, trace, metadata, repository, e ); result.addException( e ); } return ( versioning != null ) ? versioning : new Versioning(); }
/** * Indicates whether the requested metadata was resolved. Note that the metadata might have been successfully * resolved (from the local cache) despite {@link #getException()} indicating a transfer error while trying to * refetch the metadata from the remote repository. * * @return {@code true} if the metadata was resolved, {@code false} otherwise. * @see Metadata#getFile() */ public boolean isResolved() { return getMetadata() != null && getMetadata().getFile() != null; }
/** * Indicates whether the requested metadata was resolved. Note that the metadata might have been successfully * resolved (from the local cache) despite {@link #getException()} indicating a transfer error while trying to * refetch the metadata from the remote repository. * * @return {@code true} if the metadata was resolved, {@code false} otherwise. * @see Metadata#getFile() */ public boolean isResolved() { return getMetadata() != null && getMetadata().getFile() != null; }
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, VersionRangeResult result ) { Versioning versioning = null; try { if ( metadata != null ) { try ( SyncContext syncContext = syncContextFactory.newInstance( session, true ) ) { syncContext.acquire( null, Collections.singleton( metadata ) ); if ( metadata.getFile() != null && metadata.getFile().exists() ) { try ( final InputStream in = new FileInputStream( metadata.getFile() ) ) { versioning = new MetadataXpp3Reader().read( in, false ).getVersioning(); } } } } } catch ( Exception e ) { invalidMetadata( session, trace, metadata, repository, e ); result.addException( e ); } return ( versioning != null ) ? versioning : new Versioning(); }
public void XtestCloseAfterMetadataUpload() throws Exception { Metadata metadata = metadata("metadata"); List<MetadataUpload> uploads = Arrays.asList(new MetadataUpload(metadata, metadata.getFile())); connector().put(null, uploads); connector().close(); }
public void testClosedPut() throws Exception { connector().close(); Metadata metadata = metadata("metadata"); List<MetadataUpload> uploads = Arrays.asList(new MetadataUpload(metadata, metadata.getFile())); try { connector().put(null, uploads); fail("We should have thrown an IllegalStateException!"); } catch (Exception e) { // // We expect an exception // } }
public void testMetadataUpload() throws Exception { String content = "metadata"; addExpectation("gid/aid/version/maven-metadata.xml", content); addExpectation("gid/aid/version/maven-metadata.xml.sha1", sha1(content)); addExpectation("gid/aid/version/maven-metadata.xml.md5", md5(content)); Metadata metadata = metadata(content); List<MetadataUpload> uploads = Arrays.asList(new MetadataUpload(metadata, metadata.getFile())); connector().put(null, uploads); assertExpectations(); }
public void IGNOREtestMetadataWithZeroBytesFile() throws Exception { String content = ""; addExpectation("gid/aid/version/maven-metadata.xml", content); addExpectation("gid/aid/version/maven-metadata.xml.sha1", sha1(content)); addExpectation("gid/aid/version/maven-metadata.xml.md5", md5(content)); Metadata metadata = metadata(content); List<MetadataUpload> uploads = Arrays.asList(new MetadataUpload(metadata, metadata.getFile())); connector().put(null, uploads); assertExpectations(); }
public File getFile() { File ret = null; if ( metadataTransfer != null ) { ret = metadataTransfer.getFile(); } else if ( artifactTransfer != null ) { ret = artifactTransfer.getFile(); } if ( ret == null ) { if ( metadataTransfer != null ) { ret = metadataTransfer.getMetadata().getFile(); } else if ( artifactTransfer != null ) { ret = artifactTransfer.getArtifact().getFile(); } } return ret; }
/** * Compares this metadata with the specified object. * * @param obj The object to compare this metadata against, may be {@code null}. * @return {@code true} if and only if the specified object is another {@link Metadata} with equal coordinates, * type, nature, properties and file, {@code false} otherwise. */ @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } else if ( !( obj instanceof Metadata ) ) { return false; } Metadata that = (Metadata) obj; return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() ) && getVersion().equals( that.getVersion() ) && getType().equals( that.getType() ) && getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() ) && eq( getProperties(), that.getProperties() ); }
private void metadataResolved( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_RESOLVED ); event.setTrace( trace ); event.setMetadata( metadata ); event.setRepository( repository ); event.setException( exception ); event.setFile( metadata.getFile() ); repositoryEventDispatcher.dispatch( event.build() ); }
private void metadataResolved( RepositorySystemSession session, RequestTrace trace, Metadata metadata, ArtifactRepository repository, Exception exception ) { RepositoryEvent.Builder event = new RepositoryEvent.Builder( session, EventType.METADATA_RESOLVED ); event.setTrace( trace ); event.setMetadata( metadata ); event.setRepository( repository ); event.setException( exception ); event.setFile( metadata.getFile() ); repositoryEventDispatcher.dispatch( event.build() ); }
/** * Compares this metadata with the specified object. * * @param obj The object to compare this metadata against, may be {@code null}. * @return {@code true} if and only if the specified object is another {@link Metadata} with equal coordinates, * type, nature, properties and file, {@code false} otherwise. */ @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } else if ( !( obj instanceof Metadata ) ) { return false; } Metadata that = (Metadata) obj; return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() ) && getVersion().equals( that.getVersion() ) && getType().equals( that.getType() ) && getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() ) && eq( getProperties(), that.getProperties() ); }