maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From micha...@apache.org
Subject maven-resolver git commit: [MRESOLVER-2] Add repository id to TransferResource
Date Sun, 16 Oct 2016 18:26:39 GMT
Repository: maven-resolver
Updated Branches:
  refs/heads/master 534d71762 -> 11b359e18


[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/11b359e1
Tree: http://git-wip-us.apache.org/repos/asf/maven-resolver/tree/11b359e1
Diff: http://git-wip-us.apache.org/repos/asf/maven-resolver/diff/11b359e1

Branch: refs/heads/master
Commit: 11b359e188f3b1d25bb6bda60195e7a47ca45bfc
Parents: 534d717
Author: Michael Osipov <michaelo@apache.org>
Authored: Sun Oct 16 20:26:04 2016 +0200
Committer: Michael Osipov <michaelo@apache.org>
Committed: Sun Oct 16 20:26:04 2016 +0200

----------------------------------------------------------------------
 .../aether/transfer/TransferResource.java       | 45 +++++++++++++++-----
 .../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, 41 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/11b359e1/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..3395f38 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,7 +47,8 @@ public final class TransferResource
 
     /**
      * 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
@@ -53,8 +56,18 @@ public final class TransferResource
      * @param file The source/target file involved in the transfer, may be {@code null}.
      * @param trace The trace information, may be {@code null}.
      */
-    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 +102,19 @@ 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}.
+     */
+    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 +124,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 +135,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 +147,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 +157,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 +170,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 +180,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 +196,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 +207,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/11b359e1/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/11b359e1/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/11b359e1/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/11b359e1/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/11b359e1/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/11b359e1/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" );
     }
 


Mime
View raw message