Repository: maven-resolver Updated Branches: refs/heads/master 3fc53c052 -> d55d218cf
[MRESOLVER-2] Add repository id to TransferResource Project: http://git-wip-us.apache.org/repos/asf/maven-resolver/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-resolver/commit/d55d218c Tree: http://git-wip-us.apache.org/repos/asf/maven-resolver/tree/d55d218c Diff: http://git-wip-us.apache.org/repos/asf/maven-resolver/diff/d55d218c Branch: refs/heads/master Commit: d55d218cf31e4d3f89e9a9117254f082dcbc5d44 Parents: 3fc53c0 Author: Michael Osipov <micha...@apache.org> Authored: Sun Oct 16 20:26:04 2016 +0200 Committer: Michael Osipov <micha...@apache.org> Committed: Sun May 7 18:51:35 2017 +0200 ---------------------------------------------------------------------- .../aether/transfer/TransferResource.java | 68 ++++++++++++++++---- .../aether/transfer/TransferEventTest.java | 2 +- .../basic/BasicRepositoryConnector.java | 2 +- .../impl/DefaultChecksumPolicyProviderTest.java | 2 +- .../internal/impl/FailChecksumPolicyTest.java | 2 +- .../impl/RecordingRepositoryConnector.java | 4 +- .../internal/impl/WarnChecksumPolicyTest.java | 2 +- 7 files changed, 64 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java b/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java index cbe0230..1fecdad 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferResource.java @@ -29,6 +29,8 @@ import org.eclipse.aether.RequestTrace; public final class TransferResource { + private final String repositoryId; + private final String repositoryUrl; private final String resourceName; @@ -45,16 +47,48 @@ public final class TransferResource /** * Creates a new transfer resource with the specified properties. - * + * + * @param repositoryUrl The base URL of the repository, may be {@code null} or empty if unknown. If not empty, a + * trailing slash will automatically be added if missing. + * @param resourceName The relative path to the resource within the repository, may be {@code null}. A leading slash + * (if any) will be automatically removed. + * @param file The source/target file involved in the transfer, may be {@code null}. + * @param trace The trace information, may be {@code null}. + * + * @deprecated As of 1.1.0, replaced by {@link #TransferResource(java.lang.String, java.lang.String, + * java.lang.String, java.io.File, org.eclipse.aether.RequestTrace)} + */ + @Deprecated + public TransferResource( String repositoryUrl, String resourceName, File file, RequestTrace trace ) + { + this( null, repositoryUrl, resourceName, file, trace ); + } + + /** + * Creates a new transfer resource with the specified properties. + * + * @param repositoryId The ID of the repository used to transfer the resource, may be {@code null} or empty if unknown. * @param repositoryUrl The base URL of the repository, may be {@code null} or empty if unknown. If not empty, a * trailing slash will automatically be added if missing. * @param resourceName The relative path to the resource within the repository, may be {@code null}. A leading slash * (if any) will be automatically removed. * @param file The source/target file involved in the transfer, may be {@code null}. * @param trace The trace information, may be {@code null}. + * + * @since 1.1.0 */ - public TransferResource( String repositoryUrl, String resourceName, File file, RequestTrace trace ) + public TransferResource( String repositoryId, String repositoryUrl, String resourceName, + File file, RequestTrace trace ) { + if ( repositoryId == null || repositoryId.length() <= 0 ) + { + this.repositoryId = ""; + } + else + { + this.repositoryId = repositoryId; + } + if ( repositoryUrl == null || repositoryUrl.length() <= 0 ) { this.repositoryUrl = ""; @@ -89,9 +123,21 @@ public final class TransferResource } /** + * The ID of the repository, e.g., "central". + * + * @return The ID of the repository or an empty string if unknown, never {@code null}. + * + * @since 1.1.0 + */ + public String getRepositoryId() + { + return repositoryId; + } + + /** * The base URL of the repository, e.g. "http://repo1.maven.org/maven2/". Unless the URL is unknown, it will be * terminated by a trailing slash. - * + * * @return The base URL of the repository or an empty string if unknown, never {@code null}. */ public String getRepositoryUrl() @@ -101,7 +147,7 @@ public final class TransferResource /** * The path of the resource relative to the repository's base URL, e.g. "org/apache/maven/maven/3.0/maven-3.0.pom". - * + * * @return The path of the resource, never {@code null}. */ public String getResourceName() @@ -112,7 +158,7 @@ public final class TransferResource /** * Gets the local file being uploaded or downloaded. When the repository system merely checks for the existence of a * remote resource, no local file will be involved in the transfer. - * + * * @return The source/target file involved in the transfer or {@code null} if none. */ public File getFile() @@ -124,7 +170,7 @@ public final class TransferResource * The size of the resource in bytes. Note that the size of a resource during downloads might be unknown to the * client which is usually the case when transfers employ compression like gzip. In general, the content length is * not known until the transfer has {@link TransferListener#transferStarted(TransferEvent) started}. - * + * * @return The size of the resource in bytes or a negative value if unknown. */ public long getContentLength() @@ -134,7 +180,7 @@ public final class TransferResource /** * Sets the size of the resource in bytes. - * + * * @param contentLength The size of the resource in bytes or a negative value if unknown. * @return This resource for chaining, never {@code null}. */ @@ -147,7 +193,7 @@ public final class TransferResource /** * Gets the byte offset within the resource from which the download starts. A positive offset indicates a previous * download attempt is being resumed, {@code 0} means the transfer starts at the first byte. - * + * * @return The zero-based index of the first byte being transferred, never negative. */ public long getResumeOffset() @@ -157,7 +203,7 @@ public final class TransferResource /** * Sets the byte offset within the resource at which the download starts. - * + * * @param resumeOffset The zero-based index of the first byte being transferred, must not be negative. * @return This resource for chaining, never {@code null}. */ @@ -173,7 +219,7 @@ public final class TransferResource /** * Gets the timestamp when the transfer of this resource was started. - * + * * @return The timestamp when the transfer of this resource was started. */ public long getTransferStartTime() @@ -184,7 +230,7 @@ public final class TransferResource /** * Gets the trace information that describes the higher level request/operation during which this resource is * transferred. - * + * * @return The trace information about the higher level operation or {@code null} if none. */ public RequestTrace getTrace() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-api/src/test/java/org/eclipse/aether/transfer/TransferEventTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/test/java/org/eclipse/aether/transfer/TransferEventTest.java b/maven-resolver-api/src/test/java/org/eclipse/aether/transfer/TransferEventTest.java index 0ce6249..7d4c070 100644 --- a/maven-resolver-api/src/test/java/org/eclipse/aether/transfer/TransferEventTest.java +++ b/maven-resolver-api/src/test/java/org/eclipse/aether/transfer/TransferEventTest.java @@ -34,7 +34,7 @@ import org.junit.Test; public class TransferEventTest { - private static TransferResource res = new TransferResource( "file://nil", "void", null, null ); + private static TransferResource res = new TransferResource( "none", "file://nil", "void", null, null ); private static RepositorySystemSession session = new DefaultRepositorySystemSession(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java index 27f2285..4d8a8cf 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java @@ -305,7 +305,7 @@ final class BasicRepositoryConnector private TransferResource newTransferResource( URI path, File file, RequestTrace trace ) { - return new TransferResource( repository.getUrl(), path.toString(), file, trace ); + return new TransferResource( repository.getId(), repository.getUrl(), path.toString(), file, trace ); } private TransferEvent.Builder newEventBuilder( TransferResource resource, boolean upload, boolean peek ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java index 82318e5..542e3ea 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultChecksumPolicyProviderTest.java @@ -51,7 +51,7 @@ public class DefaultChecksumPolicyProviderTest session = TestUtils.newSession(); provider = new DefaultChecksumPolicyProvider(); repository = new RemoteRepository.Builder( "test", "default", "file:/void" ).build(); - resource = new TransferResource( repository.getUrl(), "file.txt", null, null ); + resource = new TransferResource( repository.getId(), repository.getUrl(), "file.txt", null, null ); } @After http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/FailChecksumPolicyTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/FailChecksumPolicyTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/FailChecksumPolicyTest.java index f36e0a0..296f829 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/FailChecksumPolicyTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/FailChecksumPolicyTest.java @@ -37,7 +37,7 @@ public class FailChecksumPolicyTest @Before public void setup() { - policy = new FailChecksumPolicy( null, new TransferResource( "file:/dev/null", "file.txt", null, null ) ); + policy = new FailChecksumPolicy( null, new TransferResource( "null", "file:/dev/null", "file.txt", null, null ) ); exception = new ChecksumFailureException( "test" ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/RecordingRepositoryConnector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/RecordingRepositoryConnector.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/RecordingRepositoryConnector.java index bbb78bf..80a347a 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/RecordingRepositoryConnector.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/RecordingRepositoryConnector.java @@ -194,7 +194,7 @@ class RecordingRepositoryConnector return; } TransferEvent.Builder event = - new TransferEvent.Builder( session, new TransferResource( null, null, null, transfer.getTrace() ) ); + new TransferEvent.Builder( session, new TransferResource( null, null, null, null, transfer.getTrace() ) ); event.setType( TransferEvent.EventType.INITIATED ); listener.transferInitiated( event.build() ); } @@ -208,7 +208,7 @@ class RecordingRepositoryConnector return; } TransferEvent.Builder event = - new TransferEvent.Builder( session, new TransferResource( null, null, null, transfer.getTrace() ) ); + new TransferEvent.Builder( session, new TransferResource( null, null, null, null, transfer.getTrace() ) ); event.setException( transfer.getException() ); if ( transfer.getException() != null ) { http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/d55d218c/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/WarnChecksumPolicyTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/WarnChecksumPolicyTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/WarnChecksumPolicyTest.java index 78fd807..7f64e06 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/WarnChecksumPolicyTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/WarnChecksumPolicyTest.java @@ -37,7 +37,7 @@ public class WarnChecksumPolicyTest @Before public void setup() { - policy = new WarnChecksumPolicy( null, new TransferResource( "file:/dev/null", "file.txt", null, null ) ); + policy = new WarnChecksumPolicy( null, new TransferResource( "null", "file:/dev/null", "file.txt", null, null ) ); exception = new ChecksumFailureException( "test" ); }