You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2016/09/03 20:23:47 UTC
[24/51] [partial] maven-aether git commit: [MNG-6007] rename Aether
to Maven Artifact Resolver
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/selection/scope/transitive-of-transitive-of-root-exclusion-tree.txt
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/selection/scope/transitive-of-transitive-of-root-exclusion-tree.txt b/aether-impl/src/test/resources/artifact-descriptions/selection/scope/transitive-of-transitive-of-root-exclusion-tree.txt
deleted file mode 100644
index ef3dc74..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/selection/scope/transitive-of-transitive-of-root-exclusion-tree.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-gid:root:ext:ver root-scope
-+- gid:direct-of-root:ext:ver direct-of-root-scope
- +- gid:transitive-of-root:ext:ver transitive-of-root-scope
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_error.ini
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_error.ini b/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_error.ini
deleted file mode 100644
index 76d2ba6..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_error.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[dependencies]
-duplicate:transitive:ext:dependency
-git:aid:ext:ver
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_ver.ini
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_ver.ini b/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_ver.ini
deleted file mode 100644
index 5b1bcc9..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/subtree_comparison_ver.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[dependencies]
-duplicate:transitive:ext:dependency
-gid:aid:ext:ver
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_1.ini
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_1.ini b/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_1.ini
deleted file mode 100644
index cfdbaeb..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_1.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[dependencies]
-test:b:jar:1
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_2.ini
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_2.ini b/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_2.ini
deleted file mode 100644
index 0117b0f..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_a_2.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[dependencies]
-test:b:jar:2
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_b_2.ini
----------------------------------------------------------------------
diff --git a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_b_2.ini b/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_b_2.ini
deleted file mode 100644
index 04a3ff0..0000000
--- a/aether-impl/src/test/resources/artifact-descriptions/versionless-cycle/test_b_2.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[dependencies]
-test:a:jar:1
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/pom.xml
----------------------------------------------------------------------
diff --git a/aether-spi/pom.xml b/aether-spi/pom.xml
deleted file mode 100644
index fde2d34..0000000
--- a/aether-spi/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.aether</groupId>
- <artifactId>aether</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>aether-spi</artifactId>
-
- <name>Aether SPI</name>
- <description>
- The service provider interface for repository system implementations and repository connectors.
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.aether</groupId>
- <artifactId>aether-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactDownload.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactDownload.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactDownload.java
deleted file mode 100644
index 3d82ac1..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactDownload.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.ArtifactTransferException;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * A download of an artifact from a remote repository. A repository connector processing this download has to use
- * {@link #setException(ArtifactTransferException)} and {@link #setSupportedContexts(Collection)} (if applicable) to
- * report the results of the transfer.
- */
-public final class ArtifactDownload
- extends ArtifactTransfer
-{
-
- private boolean existenceCheck;
-
- private String checksumPolicy = "";
-
- private String context = "";
-
- private Collection<String> contexts;
-
- private List<RemoteRepository> repositories = Collections.emptyList();
-
- /**
- * Creates a new uninitialized download.
- */
- public ArtifactDownload()
- {
- // enables default constructor
- }
-
- /**
- * Creates a new download with the specified properties.
- *
- * @param artifact The artifact to download, may be {@code null}.
- * @param context The context in which this download is performed, may be {@code null}.
- * @param file The local file to download the artifact to, may be {@code null}.
- * @param checksumPolicy The checksum policy, may be {@code null}.
- */
- public ArtifactDownload( Artifact artifact, String context, File file, String checksumPolicy )
- {
- setArtifact( artifact );
- setRequestContext( context );
- setFile( file );
- setChecksumPolicy( checksumPolicy );
- }
-
- @Override
- public ArtifactDownload setArtifact( Artifact artifact )
- {
- super.setArtifact( artifact );
- return this;
- }
-
- /**
- * {@inheritDoc} <em>Note:</em> In case of {@link #isExistenceCheck()}, this method may return {@code null}.
- */
- @Override
- public File getFile()
- {
- return super.getFile();
- }
-
- @Override
- public ArtifactDownload setFile( File file )
- {
- super.setFile( file );
- return this;
- }
-
- /**
- * Indicates whether this transfer shall only verify the existence of the artifact in the remote repository rather
- * than actually downloading the file. Just like with an actual transfer, a connector is expected to signal the
- * non-existence of the artifact by associating an {@link org.eclipse.aether.transfer.ArtifactNotFoundException
- * ArtifactNotFoundException} with this download. <em>Note:</em> If an existence check is requested,
- * {@link #getFile()} may be {@code null}, i.e. the connector must not try to access the local file.
- *
- * @return {@code true} if only the artifact existence shall be verified, {@code false} to actually download the
- * artifact.
- */
- public boolean isExistenceCheck()
- {
- return existenceCheck;
- }
-
- /**
- * Controls whether this transfer shall only verify the existence of the artifact in the remote repository rather
- * than actually downloading the file.
- *
- * @param existenceCheck {@code true} if only the artifact existence shall be verified, {@code false} to actually
- * download the artifact.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactDownload setExistenceCheck( boolean existenceCheck )
- {
- this.existenceCheck = existenceCheck;
- return this;
- }
-
- /**
- * Gets the checksum policy for this transfer.
- *
- * @return The checksum policy, never {@code null}.
- */
- public String getChecksumPolicy()
- {
- return checksumPolicy;
- }
-
- /**
- * Sets the checksum policy for this transfer.
- *
- * @param checksumPolicy The checksum policy, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactDownload setChecksumPolicy( String checksumPolicy )
- {
- this.checksumPolicy = ( checksumPolicy != null ) ? checksumPolicy : "";
- return this;
- }
-
- /**
- * Gets the context of this transfer.
- *
- * @return The context id, never {@code null}.
- */
- public String getRequestContext()
- {
- return context;
- }
-
- /**
- * Sets the context of this transfer.
- *
- * @param context The context id, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactDownload setRequestContext( String context )
- {
- this.context = ( context != null ) ? context : "";
- return this;
- }
-
- /**
- * Gets the set of request contexts in which the artifact is generally available. Repository managers can indicate
- * that an artifact is available in more than the requested context to avoid future remote trips for the same
- * artifact in a different context.
- *
- * @return The set of requests context in which the artifact is available, never {@code null}.
- */
- public Collection<String> getSupportedContexts()
- {
- return ( contexts != null ) ? contexts : Collections.singleton( context );
- }
-
- /**
- * Sets the set of request contexts in which the artifact is generally available. Repository managers can indicate
- * that an artifact is available in more than the requested context to avoid future remote trips for the same
- * artifact in a different context. The set of supported contexts defaults to the original request context if not
- * overridden by the repository connector.
- *
- * @param contexts The set of requests context in which the artifact is available, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactDownload setSupportedContexts( Collection<String> contexts )
- {
- if ( contexts == null || contexts.isEmpty() )
- {
- this.contexts = Collections.singleton( context );
- }
- else
- {
- this.contexts = contexts;
- }
- return this;
- }
-
- /**
- * Gets the remote repositories that are being aggregated by the physically contacted remote repository (i.e. a
- * repository manager).
- *
- * @return The remote repositories being aggregated, never {@code null}.
- */
- public List<RemoteRepository> getRepositories()
- {
- return repositories;
- }
-
- /**
- * Sets the remote repositories that are being aggregated by the physically contacted remote repository (i.e. a
- * repository manager).
- *
- * @param repositories The remote repositories being aggregated, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactDownload setRepositories( List<RemoteRepository> repositories )
- {
- if ( repositories == null )
- {
- this.repositories = Collections.emptyList();
- }
- else
- {
- this.repositories = repositories;
- }
- return this;
- }
-
- @Override
- public ArtifactDownload setException( ArtifactTransferException exception )
- {
- super.setException( exception );
- return this;
- }
-
- @Override
- public ArtifactDownload setListener( TransferListener listener )
- {
- super.setListener( listener );
- return this;
- }
-
- @Override
- public ArtifactDownload setTrace( RequestTrace trace )
- {
- super.setTrace( trace );
- return this;
- }
-
- @Override
- public String toString()
- {
- return getArtifact() + " - " + ( isExistenceCheck() ? "?" : "" ) + getFile();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactTransfer.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactTransfer.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactTransfer.java
deleted file mode 100644
index 8399512..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactTransfer.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.transfer.ArtifactTransferException;
-
-/**
- * A download/upload of an artifact.
- *
- * @noextend This class is not intended to be extended by clients.
- */
-public abstract class ArtifactTransfer
- extends Transfer
-{
-
- private Artifact artifact;
-
- private File file;
-
- private ArtifactTransferException exception;
-
- ArtifactTransfer()
- {
- // hide
- }
-
- /**
- * Gets the artifact being transferred.
- *
- * @return The artifact being transferred or {@code null} if not set.
- */
- public Artifact getArtifact()
- {
- return artifact;
- }
-
- /**
- * Sets the artifact to transfer.
- *
- * @param artifact The artifact, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactTransfer setArtifact( Artifact artifact )
- {
- this.artifact = artifact;
- return this;
- }
-
- /**
- * Gets the local file the artifact is downloaded to or uploaded from. In case of a download, a connector should
- * first transfer the bytes to a temporary file and only overwrite the target file once the entire download is
- * completed such that an interrupted/failed download does not corrupt the current file contents.
- *
- * @return The local file or {@code null} if not set.
- */
- public File getFile()
- {
- return file;
- }
-
- /**
- * Sets the local file the artifact is downloaded to or uploaded from.
- *
- * @param file The local file, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactTransfer setFile( File file )
- {
- this.file = file;
- return this;
- }
-
- /**
- * Gets the exception that occurred during the transfer (if any).
- *
- * @return The exception or {@code null} if the transfer was successful.
- */
- public ArtifactTransferException getException()
- {
- return exception;
- }
-
- /**
- * Sets the exception that occurred during the transfer.
- *
- * @param exception The exception, may be {@code null} to denote a successful transfer.
- * @return This transfer for chaining, never {@code null}.
- */
- public ArtifactTransfer setException( ArtifactTransferException exception )
- {
- this.exception = exception;
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java
deleted file mode 100644
index f85539e..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/ArtifactUpload.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.transfer.ArtifactTransferException;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * An upload of an artifact to a remote repository. A repository connector processing this upload has to use
- * {@link #setException(ArtifactTransferException)} to report the results of the transfer.
- */
-public final class ArtifactUpload
- extends ArtifactTransfer
-{
-
- /**
- * Creates a new uninitialized upload.
- */
- public ArtifactUpload()
- {
- // enables default constructor
- }
-
- /**
- * Creates a new upload with the specified properties.
- *
- * @param artifact The artifact to upload, may be {@code null}.
- * @param file The local file to upload the artifact from, may be {@code null}.
- */
- public ArtifactUpload( Artifact artifact, File file )
- {
- setArtifact( artifact );
- setFile( file );
- }
-
- @Override
- public ArtifactUpload setArtifact( Artifact artifact )
- {
- super.setArtifact( artifact );
- return this;
- }
-
- @Override
- public ArtifactUpload setFile( File file )
- {
- super.setFile( file );
- return this;
- }
-
- @Override
- public ArtifactUpload setException( ArtifactTransferException exception )
- {
- super.setException( exception );
- return this;
- }
-
- @Override
- public ArtifactUpload setListener( TransferListener listener )
- {
- super.setListener( listener );
- return this;
- }
-
- @Override
- public ArtifactUpload setTrace( RequestTrace trace )
- {
- super.setTrace( trace );
- return this;
- }
-
- @Override
- public String toString()
- {
- return getArtifact() + " - " + getFile();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataDownload.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataDownload.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataDownload.java
deleted file mode 100644
index be3a2d0..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataDownload.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.MetadataTransferException;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * A download of metadata from a remote repository. A repository connector processing this download has to use
- * {@link #setException(MetadataTransferException)} to report the results of the transfer.
- */
-public final class MetadataDownload
- extends MetadataTransfer
-{
-
- private String checksumPolicy = "";
-
- private String context = "";
-
- private List<RemoteRepository> repositories = Collections.emptyList();
-
- /**
- * Creates a new uninitialized download.
- */
- public MetadataDownload()
- {
- // enables default constructor
- }
-
- /**
- * Creates a new download with the specified properties.
- *
- * @param metadata The metadata to download, may be {@code null}.
- * @param context The context in which this download is performed, may be {@code null}.
- * @param file The local file to download the metadata to, may be {@code null}.
- * @param checksumPolicy The checksum policy, may be {@code null}.
- */
- public MetadataDownload( Metadata metadata, String context, File file, String checksumPolicy )
- {
- setMetadata( metadata );
- setFile( file );
- setChecksumPolicy( checksumPolicy );
- setRequestContext( context );
- }
-
- @Override
- public MetadataDownload setMetadata( Metadata metadata )
- {
- super.setMetadata( metadata );
- return this;
- }
-
- @Override
- public MetadataDownload setFile( File file )
- {
- super.setFile( file );
- return this;
- }
-
- /**
- * Gets the checksum policy for this transfer.
- *
- * @return The checksum policy, never {@code null}.
- */
- public String getChecksumPolicy()
- {
- return checksumPolicy;
- }
-
- /**
- * Sets the checksum policy for this transfer.
- *
- * @param checksumPolicy The checksum policy, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataDownload setChecksumPolicy( String checksumPolicy )
- {
- this.checksumPolicy = ( checksumPolicy != null ) ? checksumPolicy : "";
- return this;
- }
-
- /**
- * Gets the context of this transfer.
- *
- * @return The context id, never {@code null}.
- */
- public String getRequestContext()
- {
- return context;
- }
-
- /**
- * Sets the request context of this transfer.
- *
- * @param context The context id, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataDownload setRequestContext( String context )
- {
- this.context = ( context != null ) ? context : "";
- return this;
- }
-
- /**
- * Gets the remote repositories that are being aggregated by the physically contacted remote repository (i.e. a
- * repository manager).
- *
- * @return The remote repositories being aggregated, never {@code null}.
- */
- public List<RemoteRepository> getRepositories()
- {
- return repositories;
- }
-
- /**
- * Sets the remote repositories that are being aggregated by the physically contacted remote repository (i.e. a
- * repository manager).
- *
- * @param repositories The remote repositories being aggregated, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataDownload setRepositories( List<RemoteRepository> repositories )
- {
- if ( repositories == null )
- {
- this.repositories = Collections.emptyList();
- }
- else
- {
- this.repositories = repositories;
- }
- return this;
- }
-
- @Override
- public MetadataDownload setException( MetadataTransferException exception )
- {
- super.setException( exception );
- return this;
- }
-
- @Override
- public MetadataDownload setListener( TransferListener listener )
- {
- super.setListener( listener );
- return this;
- }
-
- @Override
- public MetadataDownload setTrace( RequestTrace trace )
- {
- super.setTrace( trace );
- return this;
- }
-
- @Override
- public String toString()
- {
- return getMetadata() + " - " + getFile();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataTransfer.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataTransfer.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataTransfer.java
deleted file mode 100644
index 94eb46e..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataTransfer.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.transfer.MetadataTransferException;
-
-/**
- * A download/upload of metadata.
- *
- * @noextend This class is not intended to be extended by clients.
- */
-public abstract class MetadataTransfer
- extends Transfer
-{
-
- private Metadata metadata;
-
- private File file;
-
- private MetadataTransferException exception;
-
- MetadataTransfer()
- {
- // hide
- }
-
- /**
- * Gets the metadata being transferred.
- *
- * @return The metadata being transferred or {@code null} if not set.
- */
- public Metadata getMetadata()
- {
- return metadata;
- }
-
- /**
- * Sets the metadata to transfer.
- *
- * @param metadata The metadata, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataTransfer setMetadata( Metadata metadata )
- {
- this.metadata = metadata;
- return this;
- }
-
- /**
- * Gets the local file the metadata is downloaded to or uploaded from. In case of a download, a connector should
- * first transfer the bytes to a temporary file and only overwrite the target file once the entire download is
- * completed such that an interrupted/failed download does not corrupt the current file contents.
- *
- * @return The local file or {@code null} if not set.
- */
- public File getFile()
- {
- return file;
- }
-
- /**
- * Sets the local file the metadata is downloaded to or uploaded from.
- *
- * @param file The local file, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataTransfer setFile( File file )
- {
- this.file = file;
- return this;
- }
-
- /**
- * Gets the exception that occurred during the transfer (if any).
- *
- * @return The exception or {@code null} if the transfer was successful.
- */
- public MetadataTransferException getException()
- {
- return exception;
- }
-
- /**
- * Sets the exception that occurred during the transfer.
- *
- * @param exception The exception, may be {@code null} to denote a successful transfer.
- * @return This transfer for chaining, never {@code null}.
- */
- public MetadataTransfer setException( MetadataTransferException exception )
- {
- this.exception = exception;
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataUpload.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataUpload.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataUpload.java
deleted file mode 100644
index d992757..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/MetadataUpload.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.transfer.MetadataTransferException;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * An upload of metadata to a remote repository. A repository connector processing this upload has to use
- * {@link #setException(MetadataTransferException)} to report the results of the transfer.
- */
-public final class MetadataUpload
- extends MetadataTransfer
-{
-
- /**
- * Creates a new uninitialized upload.
- */
- public MetadataUpload()
- {
- // enables default constructor
- }
-
- /**
- * Creates a new upload with the specified properties.
- *
- * @param metadata The metadata to upload, may be {@code null}.
- * @param file The local file to upload the metadata from, may be {@code null}.
- */
- public MetadataUpload( Metadata metadata, File file )
- {
- setMetadata( metadata );
- setFile( file );
- }
-
- @Override
- public MetadataUpload setMetadata( Metadata metadata )
- {
- super.setMetadata( metadata );
- return this;
- }
-
- @Override
- public MetadataUpload setFile( File file )
- {
- super.setFile( file );
- return this;
- }
-
- @Override
- public MetadataUpload setException( MetadataTransferException exception )
- {
- super.setException( exception );
- return this;
- }
-
- @Override
- public MetadataUpload setListener( TransferListener listener )
- {
- super.setListener( listener );
- return this;
- }
-
- @Override
- public MetadataUpload setTrace( RequestTrace trace )
- {
- super.setTrace( trace );
- return this;
- }
-
- @Override
- public String toString()
- {
- return getMetadata() + " - " + getFile();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnector.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnector.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnector.java
deleted file mode 100644
index 51e0627..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnector.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Closeable;
-import java.util.Collection;
-
-/**
- * A connector for a remote repository. The connector is responsible for downloading/uploading of artifacts and metadata
- * from/to a remote repository.
- * <p>
- * If applicable, a connector should obey connect/request timeouts and other relevant settings from the
- * {@link org.eclipse.aether.RepositorySystemSession#getConfigProperties() configuration properties} of the repository
- * session it has been obtained for. However, a connector must not emit any events to the transfer listener configured
- * for the session. Instead, transfer events must be emitted only to the listener (if any) specified for a given
- * download/upload request.
- * <p>
- * <strong>Note:</strong> While a connector itself can use multiple threads internally to performs the transfers,
- * clients must not call a connector concurrently, i.e. connectors are generally not thread-safe.
- *
- * @see org.eclipse.aether.spi.connector.transport.TransporterProvider
- * @see org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider
- * @see org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider
- */
-public interface RepositoryConnector
- extends Closeable
-{
-
- /**
- * Performs the specified downloads. If a download fails, the connector stores the underlying exception in the
- * download object such that callers can inspect the result via {@link ArtifactDownload#getException()} and
- * {@link MetadataDownload#getException()}, respectively. If reasonable, a connector should continue to process the
- * remaining downloads after an error to retrieve as many items as possible. The connector may perform the transfers
- * concurrently and in any order.
- *
- * @param artifactDownloads The artifact downloads to perform, may be {@code null} or empty.
- * @param metadataDownloads The metadata downloads to perform, may be {@code null} or empty.
- */
- void get( Collection<? extends ArtifactDownload> artifactDownloads,
- Collection<? extends MetadataDownload> metadataDownloads );
-
- /**
- * Performs the specified uploads. If an upload fails, the connector stores the underlying exception in the upload
- * object such that callers can inspect the result via {@link ArtifactUpload#getException()} and
- * {@link MetadataUpload#getException()}, respectively. The connector may perform the transfers concurrently and in
- * any order.
- *
- * @param artifactUploads The artifact uploads to perform, may be {@code null} or empty.
- * @param metadataUploads The metadata uploads to perform, may be {@code null} or empty.
- */
- void put( Collection<? extends ArtifactUpload> artifactUploads, Collection<? extends MetadataUpload> metadataUploads );
-
- /**
- * Closes this connector and frees any network resources associated with it. Once closed, a connector must not be
- * used for further transfers, any attempt to do so would yield a {@link IllegalStateException} or similar. Closing
- * an already closed connector is harmless and has no effect.
- */
- void close();
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnectorFactory.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnectorFactory.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnectorFactory.java
deleted file mode 100644
index 0d401c4..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/RepositoryConnectorFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.NoRepositoryConnectorException;
-
-/**
- * A factory to create repository connectors. A repository connector is responsible for uploads/downloads to/from a
- * certain kind of remote repository. When the repository system needs a repository connector for a given remote
- * repository, it iterates the registered factories in descending order of their priority and calls
- * {@link #newInstance(RepositorySystemSession, RemoteRepository)} on them. The first connector returned by a factory
- * will then be used for the transfer.
- */
-public interface RepositoryConnectorFactory
-{
-
- /**
- * Tries to create a repository connector for the specified remote repository. Typically, a factory will inspect
- * {@link RemoteRepository#getProtocol()} and {@link RemoteRepository#getContentType()} to determine whether it can
- * handle a repository.
- *
- * @param session The repository system session from which to configure the connector, must not be {@code null}. In
- * particular, a connector must notify any {@link RepositorySystemSession#getTransferListener()} set for
- * the session and should obey the timeouts configured for the session.
- * @param repository The remote repository to create a connector for, must not be {@code null}.
- * @return The connector for the given repository, never {@code null}.
- * @throws NoRepositoryConnectorException If the factory cannot create a connector for the specified remote
- * repository.
- */
- RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository )
- throws NoRepositoryConnectorException;
-
- /**
- * The priority of this factory. When multiple factories can handle a given repository, factories with higher
- * priority are preferred over those with lower priority.
- *
- * @return The priority of this factory.
- */
- float getPriority();
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/Transfer.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/Transfer.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/Transfer.java
deleted file mode 100644
index fc77011..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/Transfer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.eclipse.aether.spi.connector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * An artifact/metadata transfer.
- *
- * @noextend This class is not intended to be extended by clients.
- */
-public abstract class Transfer
-{
-
- private TransferListener listener;
-
- private RequestTrace trace;
-
- Transfer()
- {
- // hide from public
- }
-
- /**
- * Gets the exception that occurred during the transfer (if any).
- *
- * @return The exception or {@code null} if the transfer was successful.
- */
- public abstract Exception getException();
-
- /**
- * Gets the listener that is to be notified during the transfer.
- *
- * @return The transfer listener or {@code null} if none.
- */
- public TransferListener getListener()
- {
- return listener;
- }
-
- /**
- * Sets the listener that is to be notified during the transfer.
- *
- * @param listener The transfer listener to notify, may be {@code null} if none.
- * @return This transfer for chaining, never {@code null}.
- */
- Transfer setListener( TransferListener listener )
- {
- this.listener = listener;
- return this;
- }
-
- /**
- * Gets the trace information that describes the higher level request/operation in which this transfer is issued.
- *
- * @return The trace information about the higher level operation or {@code null} if none.
- */
- public RequestTrace getTrace()
- {
- return trace;
- }
-
- /**
- * Sets the trace information that describes the higher level request/operation in which this transfer is issued.
- *
- * @param trace The trace information about the higher level operation, may be {@code null}.
- * @return This transfer for chaining, never {@code null}.
- */
- Transfer setTrace( RequestTrace trace )
- {
- this.trace = trace;
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicy.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicy.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicy.java
deleted file mode 100644
index eb1716d..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicy.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.eclipse.aether.spi.connector.checksum;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.transfer.ChecksumFailureException;
-
-/**
- * A checksum policy gets employed by repository connectors to validate the integrity of a downloaded file. For each
- * downloaded file, a checksum policy instance is obtained and presented with the available checksums to conclude
- * whether the download is valid or not. The following pseudo-code illustrates the usage of a checksum policy by a
- * repository connector in some more detail (the retry logic has been omitted for the sake of brevity):
- *
- * <pre>
- * void validateChecksums() throws ChecksumFailureException {
- * for (checksum : checksums) {
- * switch (checksum.state) {
- * case MATCH:
- * if (policy.onChecksumMatch(...)) {
- * return;
- * }
- * break;
- * case MISMATCH:
- * policy.onChecksumMismatch(...);
- * break;
- * case ERROR:
- * policy.onChecksumError(...);
- * break;
- * }
- * }
- * policy.onNoMoreChecksums();
- * }
- *
- * void downloadFile() throws Exception {
- * ...
- * policy = newChecksumPolicy();
- * try {
- * validateChecksums();
- * } catch (ChecksumFailureException e) {
- * if (!policy.onTransferChecksumFailure(...)) {
- * throw e;
- * }
- * }
- * }
- * </pre>
- *
- * Checksum policies might be stateful and are generally not thread-safe.
- */
-public interface ChecksumPolicy
-{
-
- /**
- * Bit flag indicating a checksum which is not part of the official repository layout/structure.
- */
- int KIND_UNOFFICIAL = 0x01;
-
- /**
- * Signals a match between the locally computed checksum value and the checksum value declared by the remote
- * repository.
- *
- * @param algorithm The name of the checksum algorithm being used, must not be {@code null}.
- * @param kind A bit field providing further details about the checksum. See the {@code KIND_*} constants in this
- * interface for possible bit flags.
- * @return {@code true} to accept the download as valid and stop further validation, {@code false} to continue
- * validation with the next checksum.
- */
- boolean onChecksumMatch( String algorithm, int kind );
-
- /**
- * Signals a mismatch between the locally computed checksum value and the checksum value declared by the remote
- * repository. A simple policy would just rethrow the provided exception. More sophisticated policies could update
- * their internal state and defer a conclusion until all available checksums have been processed.
- *
- * @param algorithm The name of the checksum algorithm being used, must not be {@code null}.
- * @param kind A bit field providing further details about the checksum. See the {@code KIND_*} constants in this
- * interface for possible bit flags.
- * @param exception The exception describing the checksum mismatch, must not be {@code null}.
- * @throws ChecksumFailureException If the checksum validation is to be failed. If the method returns normally,
- * validation continues with the next checksum.
- */
- void onChecksumMismatch( String algorithm, int kind, ChecksumFailureException exception )
- throws ChecksumFailureException;
-
- /**
- * Signals an error while computing the local checksum value or retrieving the checksum value from the remote
- * repository.
- *
- * @param algorithm The name of the checksum algorithm being used, must not be {@code null}.
- * @param kind A bit field providing further details about the checksum. See the {@code KIND_*} constants in this
- * interface for possible bit flags.
- * @param exception The exception describing the checksum error, must not be {@code null}.
- * @throws ChecksumFailureException If the checksum validation is to be failed. If the method returns normally,
- * validation continues with the next checksum.
- */
- void onChecksumError( String algorithm, int kind, ChecksumFailureException exception )
- throws ChecksumFailureException;
-
- /**
- * Signals that all available checksums have been processed.
- *
- * @throws ChecksumFailureException If the checksum validation is to be failed. If the method returns normally, the
- * download is assumed to be valid.
- */
- void onNoMoreChecksums()
- throws ChecksumFailureException;
-
- /**
- * Signals that the download is being retried after a previously thrown {@link ChecksumFailureException} that is
- * {@link ChecksumFailureException#isRetryWorthy() retry-worthy}. Policies that maintain internal state will usually
- * have to reset some of this state at this point to prepare for a new round of validation.
- */
- void onTransferRetry();
-
- /**
- * Signals that (even after a potential retry) checksum validation has failed. A policy could opt to merely log this
- * issue or insist on rejecting the downloaded file as unusable.
- *
- * @param exception The exception that was thrown from a prior call to
- * {@link #onChecksumMismatch(String, int, ChecksumFailureException)},
- * {@link #onChecksumError(String, int, ChecksumFailureException)} or {@link #onNoMoreChecksums()}.
- * @return {@code true} to accept the download nevertheless and let artifact resolution succeed, {@code false} to
- * reject the transferred file as unusable.
- */
- boolean onTransferChecksumFailure( ChecksumFailureException exception );
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicyProvider.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicyProvider.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicyProvider.java
deleted file mode 100644
index f502300..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/ChecksumPolicyProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.aether.spi.connector.checksum;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.TransferResource;
-
-/**
- * Assists repository connectors in applying checksum policies to downloaded resources.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface ChecksumPolicyProvider
-{
-
- /**
- * Retrieves the checksum policy with the specified identifier for use on the given remote resource.
- *
- * @param session The repository system session during which the request is made, must not be {@code null}.
- * @param repository The repository hosting the resource being transferred, must not be {@code null}.
- * @param resource The transfer resource on which the policy will be applied, must not be {@code null}.
- * @param policy The identifier of the policy to apply, must not be {@code null}.
- * @return The policy to apply or {@code null} if checksums should be ignored.
- */
- ChecksumPolicy newChecksumPolicy( RepositorySystemSession session, RemoteRepository repository,
- TransferResource resource, String policy );
-
- /**
- * Returns the least strict policy. A checksum policy is said to be less strict than another policy if it would
- * accept a downloaded resource in all cases where the other policy would reject the resource.
- *
- * @param session The repository system session during which the request is made, must not be {@code null}.
- * @param policy1 A policy to compare, must not be {@code null}.
- * @param policy2 A policy to compare, must not be {@code null}.
- * @return The least strict policy among the two input policies.
- */
- String getEffectiveChecksumPolicy( RepositorySystemSession session, String policy1, String policy2 );
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/package-info.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/package-info.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/package-info.java
deleted file mode 100644
index 94d0653..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/checksum/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * The support infrastructure for repository connectors to apply checksum policies when validating the integrity of
- * downloaded files.
- */
-package org.eclipse.aether.spi.connector.checksum;
-
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java
deleted file mode 100644
index 7ae69ac..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package org.eclipse.aether.spi.connector.layout;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.URI;
-import java.util.List;
-import java.util.Locale;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * The layout for a remote repository whose artifacts/metadata can be addressed via URIs.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- */
-public interface RepositoryLayout
-{
-
- /**
- * A descriptor for a checksum file. This descriptor simply associates the location of a checksum file with the
- * underlying algorithm used to calculate/verify it. Checksum algorithms are denoted by names as used with
- * {@link java.security.MessageDigest#getInstance(String)}, e.g. {@code "SHA-1"} or {@code "MD5"}.
- */
- static final class Checksum
- {
-
- private final String algorithm;
-
- private final URI location;
-
- /**
- * Creates a new checksum file descriptor with the specified algorithm and location. The method
- * {@link #forLocation(URI, String)} is usually more convenient though.
- *
- * @param algorithm The algorithm used to calculate the checksum, must not be {@code null}.
- * @param location The relative URI to the checksum file within a repository, must not be {@code null}.
- */
- public Checksum( String algorithm, URI location )
- {
- verify( algorithm, location );
- this.algorithm = algorithm;
- this.location = location;
- }
-
- /**
- * Creates a checksum file descriptor for the specified artifact/metadata location and algorithm. The location
- * of the checksum file itself is derived from the supplied resource URI by appending the file extension
- * corresponding to the algorithm. The file extension in turn is derived from the algorithm name by stripping
- * out any hyphen ('-') characters and lower-casing the name, e.g. "SHA-1" is mapped to ".sha1".
- *
- * @param location The relative URI to the artifact/metadata whose checksum file is being obtained, must not be
- * {@code null} and must not have a query or fragment part.
- * @param algorithm The algorithm used to calculate the checksum, must not be {@code null}.
- * @return The checksum file descriptor, never {@code null}.
- */
- public static Checksum forLocation( URI location, String algorithm )
- {
- verify( algorithm, location );
- if ( location.getRawQuery() != null )
- {
- throw new IllegalArgumentException( "resource location must not have query parameters: " + location );
- }
- if ( location.getRawFragment() != null )
- {
- throw new IllegalArgumentException( "resource location must not have a fragment: " + location );
- }
- String extension = '.' + algorithm.replace( "-", "" ).toLowerCase( Locale.ENGLISH );
- return new Checksum( algorithm, URI.create( location.toString() + extension ) );
- }
-
- private static void verify( String algorithm, URI location )
- {
- if ( algorithm == null || algorithm.length() <= 0 )
- {
- throw new IllegalArgumentException( "checksum algorithm has not been specified" );
- }
- if ( location == null )
- {
- throw new IllegalArgumentException( "checksum location has not been specified" );
- }
- if ( location.isAbsolute() )
- {
- throw new IllegalArgumentException( "checksum location must be relative" );
- }
- }
-
- /**
- * Gets the name of the algorithm that is used to calculate the checksum.
- *
- * @return The algorithm name, never {@code null}.
- * @see java.security.MessageDigest#getInstance(String)
- */
- public String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Gets the location of the checksum file with a remote repository. The URI is relative to the root directory of
- * the repository.
- *
- * @return The relative URI to the checksum file, never {@code null}.
- */
- public URI getLocation()
- {
- return location;
- }
-
- @Override
- public String toString()
- {
- return location + " (" + algorithm + ")";
- }
-
- }
-
- /**
- * Gets the location within a remote repository where the specified artifact resides. The URI is relative to the
- * root directory of the repository.
- *
- * @param artifact The artifact to get the URI for, must not be {@code null}.
- * @param upload {@code false} if the artifact is being downloaded, {@code true} if the artifact is being uploaded.
- * @return The relative URI to the artifact, never {@code null}.
- */
- URI getLocation( Artifact artifact, boolean upload );
-
- /**
- * Gets the location within a remote repository where the specified metadata resides. The URI is relative to the
- * root directory of the repository.
- *
- * @param metadata The metadata to get the URI for, must not be {@code null}.
- * @param upload {@code false} if the metadata is being downloaded, {@code true} if the metadata is being uploaded.
- * @return The relative URI to the metadata, never {@code null}.
- */
- URI getLocation( Metadata metadata, boolean upload );
-
- /**
- * Gets the checksums files that a remote repository keeps to help detect data corruption during transfers of the
- * specified artifact.
- *
- * @param artifact The artifact to get the checksum files for, must not be {@code null}.
- * @param upload {@code false} if the checksums are being downloaded/verified, {@code true} if the checksums are
- * being uploaded/created.
- * @param location The relative URI to the artifact within the repository as previously obtained from
- * {@link #getLocation(Artifact, boolean)}, must not be {@code null}.
- * @return The checksum files for the given artifact, possibly empty but never {@code null}.
- */
- List<Checksum> getChecksums( Artifact artifact, boolean upload, URI location );
-
- /**
- * Gets the checksums files that a remote repository keeps to help detect data corruption during transfers of the
- * specified metadata.
- *
- * @param metadata The metadata to get the checksum files for, must not be {@code null}.
- * @param upload {@code false} if the checksums are being downloaded/verified, {@code true} if the checksums are
- * being uploaded/created.
- * @param location The relative URI to the metadata within the repository as previously obtained from
- * {@link #getLocation(Metadata, boolean)}, must not be {@code null}.
- * @return The checksum files for the given metadata, possibly empty but never {@code null}.
- */
- List<Checksum> getChecksums( Metadata metadata, boolean upload, URI location );
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutFactory.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutFactory.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutFactory.java
deleted file mode 100644
index 8aa71d7..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.aether.spi.connector.layout;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.NoRepositoryLayoutException;
-
-/**
- * A factory to obtain repository layouts. A repository layout is responsible to map an artifact or some metadata to a
- * URI relative to the repository root where the resource resides. When the repository system needs to access a given
- * remote repository, it iterates the registered factories in descending order of their priority and calls
- * {@link #newInstance(RepositorySystemSession, RemoteRepository)} on them. The first layout returned by a factory will
- * then be used for transferring artifacts/metadata.
- */
-public interface RepositoryLayoutFactory
-{
-
- /**
- * Tries to create a repository layout for the specified remote repository. Typically, a factory will inspect
- * {@link RemoteRepository#getContentType()} to determine whether it can handle a repository.
- *
- * @param session The repository system session from which to configure the layout, must not be {@code null}.
- * @param repository The remote repository to create a layout for, must not be {@code null}.
- * @return The layout for the given repository, never {@code null}.
- * @throws NoRepositoryLayoutException If the factory cannot create a repository layout for the specified remote
- * repository.
- */
- RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepository repository )
- throws NoRepositoryLayoutException;
-
- /**
- * The priority of this factory. When multiple factories can handle a given repository, factories with higher
- * priority are preferred over those with lower priority.
- *
- * @return The priority of this factory.
- */
- float getPriority();
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutProvider.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutProvider.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutProvider.java
deleted file mode 100644
index 5cdf53b..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayoutProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.aether.spi.connector.layout;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.transfer.NoRepositoryLayoutException;
-
-/**
- * Retrieves a repository layout from the installed layout factories.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface RepositoryLayoutProvider
-{
-
- /**
- * Tries to retrieve a repository layout for the specified remote repository.
- *
- * @param session The repository system session from which to configure the layout, must not be {@code null}.
- * @param repository The remote repository to create a layout for, must not be {@code null}.
- * @return The layout for the given repository, never {@code null}.
- * @throws NoRepositoryLayoutException If none of the installed layout factories can provide a repository layout for
- * the specified remote repository.
- */
- RepositoryLayout newRepositoryLayout( RepositorySystemSession session, RemoteRepository repository )
- throws NoRepositoryLayoutException;
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/package-info.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/package-info.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/package-info.java
deleted file mode 100644
index 2b36f7c..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/layout/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * The contract to locate URI-based resources using custom repository layouts. By implementing a
- * {@link org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory} and registering it with the repository
- * system, an application enables access to remote repositories that use new content types/layouts.
- */
-package org.eclipse.aether.spi.connector.layout;
-
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/package-info.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/package-info.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/package-info.java
deleted file mode 100644
index f31a2a8..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * The contract to access artifacts/metadata in remote repositories. By implementing a
- * {@link org.eclipse.aether.spi.connector.RepositoryConnectorFactory} and registering it with the repository system,
- * an application can enable access to arbitrary remote repositories. It should be noted that a repository connector is
- * powerful yet burdensome to implement. In many cases, implementing a
- * {@link org.eclipse.aether.spi.connector.transport.TransporterFactory} or
- * {@link org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory} will be sufficient and easier to access a
- * custom remote repository.
- */
-package org.eclipse.aether.spi.connector;
-
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java
----------------------------------------------------------------------
diff --git a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java b/aether-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java
deleted file mode 100644
index acad985..0000000
--- a/aether-spi/src/main/java/org/eclipse/aether/spi/connector/transport/AbstractTransporter.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package org.eclipse.aether.spi.connector.transport;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.eclipse.aether.transfer.TransferCancelledException;
-
-/**
- * A skeleton implementation for custom transporters.
- */
-public abstract class AbstractTransporter
- implements Transporter
-{
-
- private final AtomicBoolean closed;
-
- /**
- * Enables subclassing.
- */
- protected AbstractTransporter()
- {
- closed = new AtomicBoolean();
- }
-
- public void peek( PeekTask task )
- throws Exception
- {
- failIfClosed( task );
- implPeek( task );
- }
-
- /**
- * Implements {@link #peek(PeekTask)}, gets only called if the transporter has not been closed.
- *
- * @param task The existence check to perform, must not be {@code null}.
- * @throws Exception If the existence of the specified resource could not be confirmed.
- */
- protected abstract void implPeek( PeekTask task )
- throws Exception;
-
- public void get( GetTask task )
- throws Exception
- {
- failIfClosed( task );
- implGet( task );
- }
-
- /**
- * Implements {@link #get(GetTask)}, gets only called if the transporter has not been closed.
- *
- * @param task The download to perform, must not be {@code null}.
- * @throws Exception If the transfer failed.
- */
- protected abstract void implGet( GetTask task )
- throws Exception;
-
- /**
- * Performs stream-based I/O for the specified download task and notifies the configured transport listener.
- * Subclasses might want to invoke this utility method from within their {@link #implGet(GetTask)} to avoid
- * boilerplate I/O code.
- *
- * @param task The download to perform, must not be {@code null}.
- * @param is The input stream to download the data from, must not be {@code null}.
- * @param close {@code true} if the supplied input stream should be automatically closed, {@code false} to leave the
- * stream open.
- * @param length The size in bytes of the downloaded resource or {@code -1} if unknown, not to be confused with the
- * length of the supplied input stream which might be smaller if the download is resumed.
- * @param resume {@code true} if the download resumes from {@link GetTask#getResumeOffset()}, {@code false} if the
- * download starts at the first byte of the resource.
- * @throws IOException If the transfer encountered an I/O error.
- * @throws TransferCancelledException If the transfer was cancelled.
- */
- protected void utilGet( GetTask task, InputStream is, boolean close, long length, boolean resume )
- throws IOException, TransferCancelledException
- {
- OutputStream os = null;
- try
- {
- os = task.newOutputStream( resume );
- task.getListener().transportStarted( resume ? task.getResumeOffset() : 0, length );
- copy( os, is, task.getListener() );
- os.close();
- os = null;
-
- if ( close )
- {
- is.close();
- is = null;
- }
- }
- finally
- {
- try
- {
- if ( os != null )
- {
- os.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed
- }
- finally
- {
- try
- {
- if ( close && is != null )
- {
- is.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed
- }
- }
- }
- }
-
- public void put( PutTask task )
- throws Exception
- {
- failIfClosed( task );
- implPut( task );
- }
-
- /**
- * Implements {@link #put(PutTask)}, gets only called if the transporter has not been closed.
- *
- * @param task The upload to perform, must not be {@code null}.
- * @throws Exception If the transfer failed.
- */
- protected abstract void implPut( PutTask task )
- throws Exception;
-
- /**
- * Performs stream-based I/O for the specified upload task and notifies the configured transport listener.
- * Subclasses might want to invoke this utility method from within their {@link #implPut(PutTask)} to avoid
- * boilerplate I/O code.
- *
- * @param task The upload to perform, must not be {@code null}.
- * @param os The output stream to upload the data to, must not be {@code null}.
- * @param close {@code true} if the supplied output stream should be automatically closed, {@code false} to leave
- * the stream open.
- * @throws IOException If the transfer encountered an I/O error.
- * @throws TransferCancelledException If the transfer was cancelled.
- */
- protected void utilPut( PutTask task, OutputStream out, boolean close )
- throws IOException, TransferCancelledException
- {
- InputStream in = null;
- try
- {
- in = task.newInputStream();
- task.getListener().transportStarted( 0, task.getDataLength() );
- copy( out, in, task.getListener() );
-
- if ( close )
- {
- out.close();
- }
- else
- {
- out.flush();
- }
-
- out = null;
-
- in.close();
- in = null;
- }
- finally
- {
- try
- {
- if ( close && out != null )
- {
- out.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed
- }
- finally
- {
- try
- {
- if ( in != null )
- {
- in.close();
- }
- }
- catch ( final IOException e )
- {
- // Suppressed
- }
- }
- }
- }
-
- public void close()
- {
- if ( closed.compareAndSet( false, true ) )
- {
- implClose();
- }
- }
-
- /**
- * Implements {@link #close()}, gets only called if the transporter has not already been closed.
- */
- protected abstract void implClose();
-
- private void failIfClosed( TransportTask task )
- {
- if ( closed.get() )
- {
- throw new IllegalStateException( "transporter closed, cannot execute task " + task );
- }
- }
-
- private static void copy( OutputStream os, InputStream is, TransportListener listener )
- throws IOException, TransferCancelledException
- {
- ByteBuffer buffer = ByteBuffer.allocate( 1024 * 32 );
- byte[] array = buffer.array();
- for ( int read = is.read( array ); read >= 0; read = is.read( array ) )
- {
- os.write( array, 0, read );
- buffer.rewind();
- buffer.limit( read );
- listener.transportProgressed( buffer );
- }
- }
-
-}