aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-06-13 20:21:51 +0200
committerMartin Stockhammer <martin_s@apache.org>2020-06-13 20:21:51 +0200
commit628e67094518645923c0b12504cf6925b9e2c839 (patch)
tree144d851d8ea14b5a52528c7249e0b02428442db9 /archiva-modules/archiva-base
parenta548587e47dec678af021f428c80f08ddc728177 (diff)
downloadarchiva-628e67094518645923c0b12504cf6925b9e2c839.tar.gz
archiva-628e67094518645923c0b12504cf6925b9e2c839.zip
Cleanup of APIs
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java16
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyHandler.java81
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaItemSelector.java17
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java17
4 files changed, 17 insertions, 114 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java
index f6c9259a3..42dd67fc0 100644
--- a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java
+++ b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java
@@ -66,22 +66,6 @@ public interface RepositoryProxyHandler
* If the artifact is found, it is downloaded and placed into the source repository
* filesystem.
*
- * @deprecated Replaced by {@link #fetchFromProxies(ManagedRepository, Artifact)}
- * @param repository the source repository to use. (must be a managed repository)
- * @param artifact the artifact to fetch.
- * @return the file that was obtained, or null if no content was obtained
- * @throws ProxyDownloadException if there was a problem fetching the content from the target repositories.
- */
- StorageAsset fetchFromProxies( ManagedRepository repository, ArtifactReference artifact )
- throws ProxyDownloadException;
-
- /**
- * Performs the artifact fetch operation against the target repositories
- * of the provided source repository.
- * <p>
- * If the artifact is found, it is downloaded and placed into the source repository
- * filesystem.
- *
* @param repository the source repository to use. (must be a managed repository)
* @param artifact the artifact to fetch.
* @return the file that was obtained, or null if no content was obtained
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyHandler.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyHandler.java
index 2373fb938..99ca6ca2f 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyHandler.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyHandler.java
@@ -62,7 +62,6 @@ import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
@@ -275,86 +274,6 @@ public abstract class DefaultRepositoryProxyHandler implements RepositoryProxyHa
}
@Override
- public StorageAsset fetchFromProxies( ManagedRepository repository, ArtifactReference artifact )
- throws ProxyDownloadException
- {
- StorageAsset localFile = null;
- Map<String, Exception> previousExceptions = new LinkedHashMap<>();
- try
- {
- localFile = toLocalFile( repository, artifact );
- }
- catch ( LayoutException e )
- {
- previousExceptions.put( "LayoutException", e );
- throw new ProxyDownloadException( "Could not convert to BasicRepositoryContentLayout " + e.getMessage( ), previousExceptions);
- }
-
- Properties requestProperties = new Properties();
- requestProperties.setProperty( "filetype", "artifact" );
- requestProperties.setProperty( "version", artifact.getVersion() );
- requestProperties.setProperty( "managedRepositoryId", repository.getId() );
-
- List<ProxyConnector> connectors = getProxyConnectors( repository );
- for ( ProxyConnector connector : connectors )
- {
- if ( !connector.isEnabled() )
- {
- continue;
- }
-
- RemoteRepository targetRepository = connector.getTargetRepository();
- requestProperties.setProperty( "remoteRepositoryId", targetRepository.getId() );
-
- String targetPath = targetRepository.getContent().toPath( artifact );
-
- if ( SystemUtils.IS_OS_WINDOWS )
- {
- // toPath use system PATH_SEPARATOR so on windows url are \ which doesn't work very well :-)
- targetPath = PathUtil.separatorsToUnix( targetPath );
- }
-
- try
- {
- StorageAsset downloadedFile =
- transferFile( connector, targetRepository, targetPath, repository, localFile, requestProperties,
- true );
-
- if ( fileExists(downloadedFile) )
- {
- log.debug( "Successfully transferred: {}", downloadedFile.getPath() );
- return downloadedFile;
- }
- }
- catch ( NotFoundException e )
- {
- log.debug( "Artifact {} not found on repository \"{}\".", Keys.toKey( artifact ),
- targetRepository.getId() );
- }
- catch ( NotModifiedException e )
- {
- log.debug( "Artifact {} not updated on repository \"{}\".", Keys.toKey( artifact ),
- targetRepository.getId() );
- }
- catch ( ProxyException e )
- {
- validatePolicies( this.downloadErrorPolicies, connector.getPolicies(), requestProperties, artifact,
- targetRepository.getContent(), localFile, e, previousExceptions );
- }
- }
-
- if ( !previousExceptions.isEmpty() )
- {
- throw new ProxyDownloadException( "Failures occurred downloading from some remote repositories",
- previousExceptions );
- }
-
- log.debug( "Exhausted all target repositories, artifact {} not found.", Keys.toKey( artifact ) );
-
- return null;
- }
-
- @Override
public StorageAsset fetchFromProxies( ManagedRepository repository, String path )
{
StorageAsset localFile = repository.getAsset( path );
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaItemSelector.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaItemSelector.java
index cb5063087..e36ca2c97 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaItemSelector.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaItemSelector.java
@@ -92,6 +92,23 @@ public class ArchivaItemSelector implements ItemSelector
return this;
}
+ public Builder withSelector(ItemSelector givenSelector) {
+ selector.namespace = givenSelector.getNamespace( );
+ selector.projectId = givenSelector.getProjectId( );
+ selector.version = givenSelector.getVersion( );
+ selector.extension = givenSelector.getExtension( );
+ selector.artifactId = givenSelector.getArtifactId( );
+ selector.artifactVersion = givenSelector.getArtifactVersion( );
+ selector.recurse = givenSelector.recurse( );
+ for (Map.Entry<String, String> att : givenSelector.getAttributes().entrySet()) {
+ selector.setAttribute( att.getKey( ), att.getValue( ) );
+ }
+ selector.type = givenSelector.getType( );
+ selector.classifier = givenSelector.getClassifier( );
+ selector.includeRelatedArtifacts = givenSelector.includeRelatedArtifacts( );
+ return this;
+ }
+
public Builder withNamespace( String namespace )
{
if (namespace!=null)
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java
index fe964b945..14a14db4c 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java
@@ -48,23 +48,6 @@ public class ArtifactUtil
*
* @param repository The repository, where the artifact is stored.
* @param artifactReference The artifact reference.
- * @return The absolute path to the artifact.
- * @throws RepositoryException
- */
- public Path getArtifactPath( ManagedRepository repository, ArtifactReference artifactReference ) throws RepositoryException
- {
- final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
- final String artifactPath;
- artifactPath = content.toPath( artifactReference );
- return Paths.get( repository.getLocation( ) ).resolve( artifactPath );
- }
-
- /**
- * Returns the physical location of a given artifact in the repository. There is no check for the
- * existence of the returned file.
- *
- * @param repository The repository, where the artifact is stored.
- * @param artifactReference The artifact reference.
* @return The asset representation of the artifact.
* @throws RepositoryException
*/