mirror of https://github.com/apache/archiva.git
Refactoring of content interfaces. Adding layout for repository content.
This commit is contained in:
parent
ac25c7a86f
commit
6d7a510dea
|
@ -31,9 +31,10 @@ import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
|||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.components.registry.Registry;
|
||||
import org.apache.archiva.components.registry.RegistryListener;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -124,7 +125,8 @@ public class SimpleArtifactConsumer
|
|||
try
|
||||
{
|
||||
ManagedRepositoryContent repositoryContent = repository.getContent();
|
||||
ArtifactReference artifact = repositoryContent.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = repositoryContent.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
repositorySession.getRepository().getArtifacts( repositorySession, repository.getId(), artifact.getGroupId(),
|
||||
artifact.getArtifactId(), artifact.getVersion() );
|
||||
|
|
|
@ -27,14 +27,16 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
|
|||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryNotFoundException;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.metadata.base.MetadataTools;
|
||||
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
@ -42,10 +44,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -90,7 +88,7 @@ public class MetadataUpdaterConsumer
|
|||
|
||||
private ManagedRepositoryContent repository;
|
||||
|
||||
private Path repositoryDir;
|
||||
private StorageAsset repositoryDir;
|
||||
|
||||
private List<String> includes = new ArrayList<>( 0 );
|
||||
|
||||
|
@ -127,7 +125,7 @@ public class MetadataUpdaterConsumer
|
|||
if (this.repository==null) {
|
||||
throw new RepositoryNotFoundException( "Repository content not found: "+repoConfig.getId() );
|
||||
}
|
||||
this.repositoryDir = Paths.get( repository.getRepoRoot( ) );
|
||||
this.repositoryDir = repository.getRepository().getAsset( "" );
|
||||
this.scanStartTimestamp = System.currentTimeMillis( );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
|
@ -176,7 +174,7 @@ public class MetadataUpdaterConsumer
|
|||
{
|
||||
try
|
||||
{
|
||||
ArtifactReference artifact = repository.toArtifactReference( path );
|
||||
ArtifactReference artifact = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
|
||||
updateVersionMetadata( artifact, path );
|
||||
updateProjectMetadata( artifact, path );
|
||||
}
|
||||
|
@ -204,9 +202,9 @@ public class MetadataUpdaterConsumer
|
|||
{
|
||||
String metadataPath = this.metadataTools.toPath( projectRef );
|
||||
|
||||
Path projectMetadata = this.repositoryDir.resolve( metadataPath );
|
||||
StorageAsset projectMetadata = this.repositoryDir.resolve( metadataPath );
|
||||
|
||||
if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata).toMillis() >= this.scanStartTimestamp ) )
|
||||
if ( projectMetadata.exists() && ( projectMetadata.getModificationTime().toEpochMilli() >= this.scanStartTimestamp ) )
|
||||
{
|
||||
// This metadata is up to date. skip it.
|
||||
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) );
|
||||
|
@ -221,12 +219,6 @@ public class MetadataUpdaterConsumer
|
|||
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
|
||||
"Unable to write project metadata for artifact [" + path + "]: " + e.getMessage( ) );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
log.warn( "Project metadata not written due to IO warning: ", e );
|
||||
triggerConsumerWarning( TYPE_METADATA_IO,
|
||||
"Project metadata not written due to IO warning: " + e.getMessage( ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVersionMetadata( ArtifactReference artifact, String path )
|
||||
|
@ -240,9 +232,9 @@ public class MetadataUpdaterConsumer
|
|||
{
|
||||
String metadataPath = this.metadataTools.toPath( versionRef );
|
||||
|
||||
Path projectMetadata = this.repositoryDir.resolve( metadataPath );
|
||||
StorageAsset projectMetadata = this.repositoryDir.resolve( metadataPath );
|
||||
|
||||
if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata ).toMillis() >= this.scanStartTimestamp ) )
|
||||
if ( projectMetadata.exists() && ( projectMetadata.getModificationTime().toEpochMilli() >= this.scanStartTimestamp ) )
|
||||
{
|
||||
// This metadata is up to date. skip it.
|
||||
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( versionRef ) );
|
||||
|
@ -258,12 +250,6 @@ public class MetadataUpdaterConsumer
|
|||
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
|
||||
"Unable to write version metadata for artifact [" + path + "]: " + e.getMessage( ) );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
log.warn( "Version metadata not written due to IO warning: ", e );
|
||||
triggerConsumerWarning( TYPE_METADATA_IO,
|
||||
"Version metadata not written due to IO warning: " + e.getMessage( ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -24,10 +24,8 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
|
|||
import org.apache.archiva.metadata.model.facets.AuditEvent;
|
||||
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
|
||||
import org.apache.archiva.metadata.repository.*;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
|
|
@ -28,10 +28,10 @@ import org.apache.archiva.model.ArtifactReference;
|
|||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
|
@ -40,11 +40,9 @@ import org.apache.archiva.repository.content.Version;
|
|||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.apache.archiva.repository.metadata.base.MetadataTools;
|
||||
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -93,15 +91,16 @@ public class CleanupReleasedSnapshotsRepositoryPurge
|
|||
{
|
||||
try
|
||||
{
|
||||
Path artifactFile = Paths.get( repository.getRepoRoot( ), path );
|
||||
StorageAsset artifactFile = repository.getRepository( ).getAsset( "" ).resolve( path );
|
||||
BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
if ( !Files.exists(artifactFile) )
|
||||
if ( !artifactFile.exists() )
|
||||
{
|
||||
// Nothing to do here, file doesn't exist, skip it.
|
||||
return;
|
||||
}
|
||||
|
||||
ArtifactReference artifactRef = repository.toArtifactReference( path );
|
||||
ArtifactReference artifactRef = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
|
||||
|
||||
if ( !VersionUtil.isSnapshot( artifactRef.getVersion( ) ) )
|
||||
{
|
||||
|
@ -124,7 +123,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
|
|||
|
||||
if ( repo.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ))
|
||||
{
|
||||
ManagedRepositoryContent repoContent = repo.getContent();
|
||||
BaseRepositoryContentLayout repoContent = repo.getContent().getLayout( BaseRepositoryContentLayout.class );
|
||||
Project proj = repoContent.getProject( selector );
|
||||
for ( Version version : repoContent.getVersions( proj ) )
|
||||
{
|
||||
|
@ -150,13 +149,13 @@ public class CleanupReleasedSnapshotsRepositoryPurge
|
|||
if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion( ) ) ) )
|
||||
{
|
||||
versionRef.setVersion( artifactRef.getVersion( ) );
|
||||
repository.deleteVersion( versionRef );
|
||||
layout.deleteVersion( versionRef );
|
||||
|
||||
for ( RepositoryListener listener : listeners )
|
||||
{
|
||||
listener.deleteArtifact( metadataRepository, repository.getId( ), artifactRef.getGroupId( ),
|
||||
artifactRef.getArtifactId( ), artifactRef.getVersion( ),
|
||||
artifactFile.getFileName().toString() );
|
||||
artifactFile.getName() );
|
||||
}
|
||||
metadataRepository.removeProjectVersion( repositorySession, repository.getId( ),
|
||||
artifactRef.getGroupId( ), artifactRef.getArtifactId( ), artifactRef.getVersion( ) );
|
||||
|
|
|
@ -23,15 +23,12 @@ import org.apache.archiva.common.utils.VersionComparator;
|
|||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
@ -100,7 +97,7 @@ public class DaysOldRepositoryPurge
|
|||
.build( );
|
||||
|
||||
List<String> artifactVersions;
|
||||
try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector )){
|
||||
try( Stream<? extends Artifact> stream = repository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector )){
|
||||
artifactVersions = stream.map( a -> a.getArtifactVersion( ) )
|
||||
.filter( StringUtils::isNotEmpty )
|
||||
.distinct()
|
||||
|
@ -142,7 +139,7 @@ public class DaysOldRepositoryPurge
|
|||
// Is this a generic snapshot "1.0-SNAPSHOT" ?
|
||||
if ( VersionUtil.isGenericSnapshot( version ) )
|
||||
{
|
||||
List<? extends Artifact> artifactList = repository.getArtifacts( artifactSelector );
|
||||
List<? extends Artifact> artifactList = repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( artifactSelector );
|
||||
if ( artifactList.size()>0 && artifactList.get(0).getAsset().getModificationTime( ).toEpochMilli( ) < olderThanThisDate.getTimeInMillis( ) )
|
||||
{
|
||||
artifactsToDelete.addAll( artifactList );
|
||||
|
@ -155,7 +152,7 @@ public class DaysOldRepositoryPurge
|
|||
|
||||
if ( timestampCal.getTimeInMillis( ) < olderThanThisDate.getTimeInMillis( ) )
|
||||
{
|
||||
artifactsToDelete.addAll( repository.getArtifacts( artifactSelector ) );
|
||||
artifactsToDelete.addAll( repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( artifactSelector ) );
|
||||
}
|
||||
}
|
||||
} catch ( IllegalArgumentException e ) {
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.apache.archiva.metadata.repository.RepositorySession;
|
|||
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
||||
import org.apache.archiva.components.registry.Registry;
|
||||
import org.apache.archiva.components.registry.RegistryListener;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
|
|
|
@ -23,22 +23,15 @@ import org.apache.archiva.common.utils.VersionComparator;
|
|||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -88,7 +81,7 @@ public class RetentionCountRepositoryPurge
|
|||
|
||||
|
||||
List<String> versions;
|
||||
try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector) ){
|
||||
try( Stream<? extends Artifact> stream = repository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector) ){
|
||||
versions = stream.map( a -> a.getArtifactVersion( ) )
|
||||
.filter( StringUtils::isNotEmpty )
|
||||
.distinct()
|
||||
|
@ -119,7 +112,7 @@ public class RetentionCountRepositoryPurge
|
|||
{
|
||||
break;
|
||||
}
|
||||
List<? extends Artifact> delArtifacts = repository.getArtifacts( selectorBuilder.withArtifactVersion( version ).build( ) );
|
||||
List<? extends Artifact> delArtifacts = repository.getLayout( BaseRepositoryContentLayout.class ).getArtifacts( selectorBuilder.withArtifactVersion( version ).build( ) );
|
||||
if (delArtifacts!=null && delArtifacts.size()>0)
|
||||
{
|
||||
artifactsToDelete.addAll( delArtifacts );
|
||||
|
|
|
@ -23,9 +23,9 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
|
|||
import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator;
|
||||
import org.apache.archiva.repository.base.BasicManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryContentProvider;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
|
|
|
@ -43,6 +43,8 @@ import org.apache.archiva.proxy.model.ProxyConnector;
|
|||
import org.apache.archiva.proxy.model.ProxyFetchResult;
|
||||
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
|
||||
import org.apache.archiva.components.taskqueue.TaskQueueException;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
|
@ -141,7 +143,17 @@ public abstract class DefaultRepositoryProxyHandler implements RepositoryProxyHa
|
|||
public StorageAsset fetchFromProxies( ManagedRepository repository, ArtifactReference artifact )
|
||||
throws ProxyDownloadException
|
||||
{
|
||||
StorageAsset localFile = toLocalFile( repository, artifact );
|
||||
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" );
|
||||
|
@ -149,7 +161,6 @@ public abstract class DefaultRepositoryProxyHandler implements RepositoryProxyHa
|
|||
requestProperties.setProperty( "managedRepositoryId", repository.getId() );
|
||||
|
||||
List<ProxyConnector> connectors = getProxyConnectors( repository );
|
||||
Map<String, Exception> previousExceptions = new LinkedHashMap<>();
|
||||
for ( ProxyConnector connector : connectors )
|
||||
{
|
||||
if ( !connector.isEnabled() )
|
||||
|
@ -399,9 +410,9 @@ public abstract class DefaultRepositoryProxyHandler implements RepositoryProxyHa
|
|||
}
|
||||
}
|
||||
|
||||
private StorageAsset toLocalFile(ManagedRepository repository, ArtifactReference artifact )
|
||||
private StorageAsset toLocalFile(ManagedRepository repository, ArtifactReference artifact ) throws LayoutException
|
||||
{
|
||||
return repository.getContent().toFile( artifact );
|
||||
return repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toFile( artifact );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,440 @@
|
|||
package org.apache.archiva.repository;
|
||||
|
||||
/*
|
||||
* 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.apache.archiva.model.ArchivaArtifact;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.Namespace;
|
||||
import org.apache.archiva.repository.content.Project;
|
||||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Layout interface for interacting with a managed repository in an abstract way,
|
||||
* without the need for processing based on filesystem paths, or working with the database.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface BaseRepositoryContentLayout extends RepositoryContent, ManagedRepositoryContent, ManagedRepositoryContentLayout
|
||||
{
|
||||
|
||||
/// ***************** New generation interface **********************
|
||||
|
||||
|
||||
/**
|
||||
* Returns the namespace for the given selected coordinates. The selector must specify a namespace. All other
|
||||
* coordinates are ignored.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
*
|
||||
* @param namespaceSelector the selectory with the namespace coordinates
|
||||
* @return the namespace
|
||||
* @throws ItemNotFoundException if the item does not exist
|
||||
* @throws ContentAccessException if the item cannot be accessed
|
||||
* @throws IllegalArgumentException if the selector has no namespace specified
|
||||
*/
|
||||
Namespace getNamespace( ItemSelector namespaceSelector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the project for the given coordinates.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>projectId</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
* Additional coordinates will be ignored.
|
||||
*
|
||||
* @param projectSelector
|
||||
* @return the project instance
|
||||
* @throws ItemNotFoundException if the project does not exist
|
||||
* @throws ContentAccessException if the item cannot be accessed
|
||||
* @throws IllegalArgumentException if the selector does not specify the required coordinates
|
||||
*/
|
||||
Project getProject( ItemSelector projectSelector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the version for the given coordinates.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>projectId</li>
|
||||
* <li>version</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
*
|
||||
* Additional coordinates will be ignored.
|
||||
*
|
||||
* @param versionCoordinates
|
||||
* @return the version object
|
||||
* @throws ItemNotFoundException
|
||||
* @throws ContentAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
Version getVersion(ItemSelector versionCoordinates) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the artifact object for the given coordinates.
|
||||
*
|
||||
* Normally the following coordinates should be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>artifactVersion and or version</li>
|
||||
* <li>artifactId or projectId</li>
|
||||
* </ul>
|
||||
* If the coordinates do not provide enough information for selecting a artifact, a {@link IllegalArgumentException} will be thrown
|
||||
* It depends on the repository type, what exactly is returned for a given set of coordinates. Some repository type
|
||||
* may have different required and optional coordinates. For further information please check the documentation for the
|
||||
* type specific implementations.
|
||||
*
|
||||
* The following coordinates are optional and may further specify the artifact to return.
|
||||
* <ul>
|
||||
* <li>classifier</li>
|
||||
* <li>type</li>
|
||||
* <li>extension</li>
|
||||
* </ul>
|
||||
*
|
||||
* The method always returns a artifact object, if the coordinates are valid. It does not guarantee that the artifact
|
||||
* exists. To check if there is really a physical representation of the artifact, use the <code>{@link Artifact#exists()}</code>
|
||||
* method of the artifact.
|
||||
* For upload and data retrieval use the methods of the {@link StorageAsset} reference returned in the artifact.
|
||||
*
|
||||
*
|
||||
* @param selector the selector with the artifact coordinates
|
||||
* @return a artifact object
|
||||
* @throws IllegalArgumentException if the selector coordinates do not specify a artifact
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Artifact getArtifact(ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the artifacts that match the given selector. It is up to the repository implementation
|
||||
* what artifacts are returned for a given set of coordinates.
|
||||
*
|
||||
* @param selector the selector for the artifacts
|
||||
* @return a list of artifacts.
|
||||
* @throws IllegalArgumentException if the specified coordinates cannot be found in the repository
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Returns the artifacts that match the given selector. It is up to the repository implementation
|
||||
* what artifacts are returned for a given set of coordinates.
|
||||
*
|
||||
* The returned stream is autoclosable and should always closed after using it.
|
||||
*
|
||||
* There is no guarantee about the order of the returned artifacts
|
||||
*
|
||||
* @param selector the selector for the artifacts
|
||||
* @return a stream with artifact elements.
|
||||
* @throws ItemNotFoundException if the specified coordinates cannot be found in the repository
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Stream<? extends Artifact> newArtifactStream( ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the projects that are part of the given namespace.
|
||||
*
|
||||
* @param namespace the namespace
|
||||
* @return the list of projects or a empty list, if there are no projects for the given namespace.
|
||||
*/
|
||||
List<? extends Project> getProjects( Namespace namespace) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Returns the list of projects that match the given selector. The selector must at least specify a
|
||||
* a namespace.
|
||||
*
|
||||
* @param selector the selector
|
||||
* @return the list of projects that match the selector. A empty list of not project matches.
|
||||
* @throws ContentAccessException if the access to the storage backend failed
|
||||
* @throws IllegalArgumentException if the selector does not contain sufficient data for selecting projects
|
||||
*/
|
||||
List<? extends Project> getProjects( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Return the existing versions of the given project.
|
||||
*
|
||||
* @param project the project
|
||||
* @return a list of versions or a empty list, if not versions are available for the specified project
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
List<? extends Version> getVersions( Project project) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the versions that match the given selector. The selector must at least specify a namespace and a projectId.
|
||||
*
|
||||
* @param selector the item selector. At least namespace and projectId must be set.
|
||||
* @return the list of version or a empty list, if no version matches the selector
|
||||
* @throws ContentAccessException if the access to the backend failed
|
||||
* @throws IllegalArgumentException if the selector does not contain enough information for selecting versions
|
||||
*/
|
||||
List<? extends Version> getVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns all found artifact versions that can be found for the given selector. The selector must specify at least
|
||||
* a project.
|
||||
*
|
||||
* @param selector the item selector that must specify at least a project
|
||||
* @return the list of artifact versions
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
* @throws IllegalArgumentException if the selector does not have project information
|
||||
*/
|
||||
List<String> getArtifactVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Return all the artifacts of a given content item (namespace, project, version)
|
||||
*
|
||||
* @param item the item
|
||||
* @return a list of artifacts or a empty list, if no artifacts are available for the specified item
|
||||
*/
|
||||
List<? extends Artifact> getArtifacts( ContentItem item) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Return a stream of artifacts that are part of the given content item. The returned stream is
|
||||
* auto closable. There is no guarantee about the order of returned artifacts.
|
||||
*
|
||||
* As the stream may access IO resources, you should always use call this method inside try-with-resources or
|
||||
* make sure, that the stream is closed after using it.
|
||||
*
|
||||
* @param item the item from where the artifacts should be returned
|
||||
* @return a stream of artifacts. The stream is auto closable. You should always make sure, that the stream
|
||||
* is closed after use.
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Stream<? extends Artifact> newArtifactStream( ContentItem item ) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Copies the artifact to the given destination coordinates
|
||||
*
|
||||
* @param sourceFile the path to the source file
|
||||
* @param destination the coordinates of the destination
|
||||
* @throws IllegalArgumentException if the destination is not valid
|
||||
*/
|
||||
void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException, ContentAccessException;
|
||||
|
||||
|
||||
/// ***************** End of new generation interface **********************
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the version reference for the given coordinates.
|
||||
* @param groupId the group id
|
||||
* @param artifactId the artifact id
|
||||
* @param version the version number
|
||||
* @return a version reference
|
||||
*/
|
||||
VersionedReference toVersion( String groupId, String artifactId, String version );
|
||||
|
||||
|
||||
/**
|
||||
* Return the version reference that matches exactly the version string of the artifact
|
||||
*
|
||||
* @param artifactReference The artifact reference
|
||||
* @return the version reference
|
||||
*/
|
||||
VersionedReference toVersion( ArtifactReference artifactReference);
|
||||
|
||||
|
||||
/**
|
||||
* Delete from the managed repository all files / directories associated with the
|
||||
* provided version reference.
|
||||
*
|
||||
* @param reference the version reference to delete.
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteVersion( VersionedReference reference )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* delete a specified artifact from the repository
|
||||
*
|
||||
* @param artifactReference
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteArtifact( ArtifactReference artifactReference )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param groupId
|
||||
* @throws ContentNotFoundException
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
void deleteGroupId( String groupId )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param namespace groupId for maven
|
||||
* @param projectId artifactId for maven
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteProject( String namespace, String projectId )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a project
|
||||
* @param reference
|
||||
*/
|
||||
void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Gather up the list of related artifacts to the ArtifactReference provided.
|
||||
* This typically includes the pom files, and those things with
|
||||
* classifiers (such as doc, source code, test libs, etc...). Even if the classifier
|
||||
* is set in the artifact reference, it may return artifacts with different classifiers.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
|
||||
* </p>
|
||||
*
|
||||
* @param reference the reference to work off of.
|
||||
* @return the list of ArtifactReferences for related artifacts, if
|
||||
* @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
|
||||
*/
|
||||
List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
|
||||
throws ContentNotFoundException, LayoutException, ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns all artifacts that belong to a given version
|
||||
* @param reference the version reference
|
||||
* @return the list of artifacts or a empty list
|
||||
*/
|
||||
List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Convenience method to get the repository (on disk) root directory.
|
||||
* </p>
|
||||
* <p>
|
||||
* Equivalent to calling <code>.getRepository().getLocation()</code>
|
||||
* </p>
|
||||
*
|
||||
* @return the repository (on disk) root directory.
|
||||
*/
|
||||
String getRepoRoot();
|
||||
|
||||
/**
|
||||
* Determines if the artifact referenced exists in the repository.
|
||||
*
|
||||
* @param reference the artifact reference to check for.
|
||||
* @return true if the artifact referenced exists.
|
||||
*/
|
||||
boolean hasContent( ArtifactReference reference ) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Determines if the version reference exists in the repository.
|
||||
*
|
||||
* @param reference the version reference to check for.
|
||||
* @return true if the version referenced exists.
|
||||
*/
|
||||
boolean hasContent( VersionedReference reference ) throws ContentAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given an {@link ArtifactReference}, return the file reference to the artifact.
|
||||
*
|
||||
* @param reference the artifact reference to use.
|
||||
* @return the relative path to the artifact.
|
||||
*/
|
||||
StorageAsset toFile( VersionedReference reference );
|
||||
|
||||
/**
|
||||
* Given an {@link ArtifactReference}, return the file reference to the artifact.
|
||||
*
|
||||
* @param reference the artifact reference to use.
|
||||
* @return the relative path to the artifact.
|
||||
*/
|
||||
StorageAsset toFile( ArtifactReference reference );
|
||||
|
||||
/**
|
||||
* Given an {@link ArchivaArtifact}, return the file reference to the artifact.
|
||||
*
|
||||
* @param reference the archiva artifact to use.
|
||||
* @return the relative path to the artifact.
|
||||
*/
|
||||
StorageAsset toFile( ArchivaArtifact reference );
|
||||
|
||||
/**
|
||||
* Given a {@link ProjectReference}, return the path to the metadata for
|
||||
* the project.
|
||||
*
|
||||
* @param reference the reference to use.
|
||||
* @return the path to the metadata file, or null if no metadata is appropriate.
|
||||
*/
|
||||
String toMetadataPath( ProjectReference reference );
|
||||
|
||||
/**
|
||||
* Given a {@link VersionedReference}, return the path to the metadata for
|
||||
* the specific version of the project.
|
||||
*
|
||||
* @param reference the reference to use.
|
||||
* @return the path to the metadata file, or null if no metadata is appropriate.
|
||||
*/
|
||||
String toMetadataPath( VersionedReference reference );
|
||||
|
||||
/**
|
||||
* Given an {@link ArchivaArtifact}, return the relative path to the artifact.
|
||||
*
|
||||
* @param reference the archiva artifact to use.
|
||||
* @return the relative path to the artifact.
|
||||
*/
|
||||
String toPath( ArchivaArtifact reference );
|
||||
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ public interface EditableManagedRepository extends EditableRepository, ManagedRe
|
|||
* Sets the content
|
||||
* @param content
|
||||
*/
|
||||
void setContent(ManagedRepositoryContent content);
|
||||
void setContent( ManagedRepositoryContent content);
|
||||
|
||||
/**
|
||||
* Adds an active release scheme. Release schemes may be combined.
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
package org.apache.archiva.repository;
|
||||
|
||||
/*
|
||||
* 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.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public interface GenericManagedRepositoryContent
|
||||
{
|
||||
/**
|
||||
* Delete all items that match the given selector. The type and number of deleted items
|
||||
* depend on the specific selector:
|
||||
* <ul>
|
||||
* <li>namespace: the complete namespace is deleted (recursively if the recurse flag is set)</li>
|
||||
* <li>project: the complete project and all contained versions are deleted</li>
|
||||
* <li>version: the version inside the project is deleted (project is required)</li>
|
||||
* <li>artifactId: all artifacts that match the id (project and version are required)</li>
|
||||
* <li>artifactVersion: all artifacts that match the version (project and version are required)</li>
|
||||
* <li></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param selector the item selector that selects the artifacts to delete
|
||||
* @param consumer a consumer of the items that will be called after deletion
|
||||
* @returns the list of items that are deleted
|
||||
* @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
|
||||
* to the artifacts failed
|
||||
* @throws IllegalArgumentException if the selector does not specify valid artifacts to delete
|
||||
*/
|
||||
void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Removes the specified content item and if the item is a container or directory,
|
||||
* all content stored under the given item.
|
||||
*
|
||||
* @param item the item.
|
||||
* @throws ItemNotFoundException if the item cannot be found
|
||||
* @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
|
||||
* to the artifacts failed
|
||||
*/
|
||||
void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException;
|
||||
|
||||
/**
|
||||
* Returns a item for the given selector. The type of the returned item depends on the
|
||||
* selector.
|
||||
*
|
||||
* @param selector the item selector
|
||||
* @return the content item that matches the given selector
|
||||
* @throws ContentAccessException if an error occured while accessing the backend
|
||||
* @throws IllegalArgumentException if the selector does not select a valid content item
|
||||
*/
|
||||
ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a stream of items that match the given selector. It may return a stream of mixed types,
|
||||
* like namespaces, projects, versions and artifacts. It will not select a specific type.
|
||||
* The selector can specify the '*' pattern for all fields.
|
||||
* The returned elements will be provided by depth first.
|
||||
*
|
||||
* @param selector the item selector that specifies the items
|
||||
* @return the stream of content items
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
* @throws IllegalArgumentException if a illegal coordinate combination was provided
|
||||
*/
|
||||
Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the item that matches the given path. The item at the path must not exist.
|
||||
*
|
||||
* @param path the path string that points to the item
|
||||
* @return the content item if the path is a valid item path
|
||||
* @throws LayoutException if the path is not valid for the repository layout
|
||||
*/
|
||||
ContentItem toItem( String path ) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Returns the item that matches the given asset path. The asset must not exist.
|
||||
*
|
||||
* @param assetPath the path to the artifact or directory
|
||||
* @return the item, if it is a valid path for the repository layout
|
||||
* @throws LayoutException if the path is not valid for the repository
|
||||
*/
|
||||
ContentItem toItem( StorageAsset assetPath ) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Returns true, if the selector coordinates point to a existing item in the repository.
|
||||
*
|
||||
* @param selector the item selector
|
||||
* @return <code>true</code>, if there exists such a item, otherwise <code>false</code>
|
||||
*/
|
||||
boolean hasContent( ItemSelector selector );
|
||||
|
||||
/**
|
||||
* Returns the parent of the item.
|
||||
* @param item the current item
|
||||
* @return the parent item, or <code>null</code> if no such item exists
|
||||
*/
|
||||
ContentItem getParent(ContentItem item);
|
||||
|
||||
/**
|
||||
* Returns the list of children items.
|
||||
* @param item the current item
|
||||
* @return the list of children, or a empty list, if no children exist
|
||||
*/
|
||||
List<? extends ContentItem> getChildren( ContentItem item);
|
||||
|
||||
/**
|
||||
* Tries to apply the given characteristic to the content item. If the layout does not allow this,
|
||||
* it will throw a <code>LayoutException</code>.
|
||||
*
|
||||
* @param clazz the characteristic class to apply
|
||||
* @param item the content item
|
||||
* @param <T> The characteristic
|
||||
* @return the applied characteristic
|
||||
*/
|
||||
<T extends ContentItem> T applyCharacteristic(Class<T> clazz, ContentItem item) throws LayoutException;
|
||||
}
|
|
@ -9,8 +9,7 @@ package org.apache.archiva.repository;
|
|||
* "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
|
||||
*
|
||||
* 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
|
||||
|
@ -19,312 +18,29 @@ package org.apache.archiva.repository;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.model.ArchivaArtifact;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.Namespace;
|
||||
import org.apache.archiva.repository.content.Project;
|
||||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
|
||||
* without the need for processing based on filesystem paths, or working with the database.
|
||||
*
|
||||
* This interface
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public interface ManagedRepositoryContent extends RepositoryContent, GenericManagedRepositoryContent
|
||||
public interface ManagedRepositoryContent
|
||||
{
|
||||
|
||||
/// ***************** New generation interface **********************
|
||||
|
||||
|
||||
/**
|
||||
* Returns the namespace for the given selected coordinates. The selector must specify a namespace. All other
|
||||
* coordinates are ignored.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
* Returns the path of the given item.
|
||||
*
|
||||
* @param namespaceSelector the selectory with the namespace coordinates
|
||||
* @return the namespace
|
||||
* @throws ItemNotFoundException if the item does not exist
|
||||
* @throws ContentAccessException if the item cannot be accessed
|
||||
* @throws IllegalArgumentException if the selector has no namespace specified
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
Namespace getNamespace( ItemSelector namespaceSelector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the project for the given coordinates.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>projectId</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
* Additional coordinates will be ignored.
|
||||
*
|
||||
* @param projectSelector
|
||||
* @return the project instance
|
||||
* @throws ItemNotFoundException if the project does not exist
|
||||
* @throws ContentAccessException if the item cannot be accessed
|
||||
* @throws IllegalArgumentException if the selector does not specify the required coordinates
|
||||
*/
|
||||
Project getProject( ItemSelector projectSelector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the version for the given coordinates.
|
||||
* The following coordinates must be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>projectId</li>
|
||||
* <li>version</li>
|
||||
* </ul>
|
||||
* If not, a {@link IllegalArgumentException} will be thrown.
|
||||
*
|
||||
* Additional coordinates will be ignored.
|
||||
*
|
||||
* @param versionCoordinates
|
||||
* @return the version object
|
||||
* @throws ItemNotFoundException
|
||||
* @throws ContentAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
Version getVersion(ItemSelector versionCoordinates) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the artifact object for the given coordinates.
|
||||
*
|
||||
* Normally the following coordinates should be set at the given selector:
|
||||
* <ul>
|
||||
* <li>namespace</li>
|
||||
* <li>artifactVersion and or version</li>
|
||||
* <li>artifactId or projectId</li>
|
||||
* </ul>
|
||||
* If the coordinates do not provide enough information for selecting a artifact, a {@link IllegalArgumentException} will be thrown
|
||||
* It depends on the repository type, what exactly is returned for a given set of coordinates. Some repository type
|
||||
* may have different required and optional coordinates. For further information please check the documentation for the
|
||||
* type specific implementations.
|
||||
*
|
||||
* The following coordinates are optional and may further specify the artifact to return.
|
||||
* <ul>
|
||||
* <li>classifier</li>
|
||||
* <li>type</li>
|
||||
* <li>extension</li>
|
||||
* </ul>
|
||||
*
|
||||
* The method always returns a artifact object, if the coordinates are valid. It does not guarantee that the artifact
|
||||
* exists. To check if there is really a physical representation of the artifact, use the <code>{@link Artifact#exists()}</code>
|
||||
* method of the artifact.
|
||||
* For upload and data retrieval use the methods of the {@link StorageAsset} reference returned in the artifact.
|
||||
*
|
||||
*
|
||||
* @param selector the selector with the artifact coordinates
|
||||
* @return a artifact object
|
||||
* @throws IllegalArgumentException if the selector coordinates do not specify a artifact
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Artifact getArtifact(ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the artifacts that match the given selector. It is up to the repository implementation
|
||||
* what artifacts are returned for a given set of coordinates.
|
||||
*
|
||||
* @param selector the selector for the artifacts
|
||||
* @return a list of artifacts.
|
||||
* @throws IllegalArgumentException if the specified coordinates cannot be found in the repository
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Returns the artifacts that match the given selector. It is up to the repository implementation
|
||||
* what artifacts are returned for a given set of coordinates.
|
||||
*
|
||||
* The returned stream is autoclosable and should always closed after using it.
|
||||
*
|
||||
* There is no guarantee about the order of the returned artifacts
|
||||
*
|
||||
* @param selector the selector for the artifacts
|
||||
* @return a stream with artifact elements.
|
||||
* @throws ItemNotFoundException if the specified coordinates cannot be found in the repository
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Stream<? extends Artifact> newArtifactStream( ItemSelector selector) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the projects that are part of the given namespace.
|
||||
*
|
||||
* @param namespace the namespace
|
||||
* @return the list of projects or a empty list, if there are no projects for the given namespace.
|
||||
*/
|
||||
List<? extends Project> getProjects( Namespace namespace) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Returns the list of projects that match the given selector. The selector must at least specify a
|
||||
* a namespace.
|
||||
*
|
||||
* @param selector the selector
|
||||
* @return the list of projects that match the selector. A empty list of not project matches.
|
||||
* @throws ContentAccessException if the access to the storage backend failed
|
||||
* @throws IllegalArgumentException if the selector does not contain sufficient data for selecting projects
|
||||
*/
|
||||
List<? extends Project> getProjects( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Return the existing versions of the given project.
|
||||
*
|
||||
* @param project the project
|
||||
* @return a list of versions or a empty list, if not versions are available for the specified project
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
List<? extends Version> getVersions( Project project) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Return the versions that match the given selector. The selector must at least specify a namespace and a projectId.
|
||||
*
|
||||
* @param selector the item selector. At least namespace and projectId must be set.
|
||||
* @return the list of version or a empty list, if no version matches the selector
|
||||
* @throws ContentAccessException if the access to the backend failed
|
||||
* @throws IllegalArgumentException if the selector does not contain enough information for selecting versions
|
||||
*/
|
||||
List<? extends Version> getVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns all found artifact versions that can be found for the given selector. The selector must specify at least
|
||||
* a project.
|
||||
*
|
||||
* @param selector the item selector that must specify at least a project
|
||||
* @return the list of artifact versions
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
* @throws IllegalArgumentException if the selector does not have project information
|
||||
*/
|
||||
List<String> getArtifactVersions( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Return all the artifacts of a given content item (namespace, project, version)
|
||||
*
|
||||
* @param item the item
|
||||
* @return a list of artifacts or a empty list, if no artifacts are available for the specified item
|
||||
*/
|
||||
List<? extends Artifact> getArtifacts( ContentItem item) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Return a stream of artifacts that are part of the given content item. The returned stream is
|
||||
* auto closable. There is no guarantee about the order of returned artifacts.
|
||||
*
|
||||
* As the stream may access IO resources, you should always use call this method inside try-with-resources or
|
||||
* make sure, that the stream is closed after using it.
|
||||
*
|
||||
* @param item the item from where the artifacts should be returned
|
||||
* @return a stream of artifacts. The stream is auto closable. You should always make sure, that the stream
|
||||
* is closed after use.
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
*/
|
||||
Stream<? extends Artifact> newArtifactStream( ContentItem item ) throws ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Copies the artifact to the given destination coordinates
|
||||
*
|
||||
* @param sourceFile the path to the source file
|
||||
* @param destination the coordinates of the destination
|
||||
* @throws IllegalArgumentException if the destination is not valid
|
||||
*/
|
||||
void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException, ContentAccessException;
|
||||
|
||||
|
||||
/// ***************** End of new generation interface **********************
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the version reference for the given coordinates.
|
||||
* @param groupId the group id
|
||||
* @param artifactId the artifact id
|
||||
* @param version the version number
|
||||
* @return a version reference
|
||||
*/
|
||||
VersionedReference toVersion( String groupId, String artifactId, String version );
|
||||
|
||||
|
||||
/**
|
||||
* Return the version reference that matches exactly the version string of the artifact
|
||||
*
|
||||
* @param artifactReference The artifact reference
|
||||
* @return the version reference
|
||||
*/
|
||||
VersionedReference toVersion( ArtifactReference artifactReference);
|
||||
|
||||
|
||||
/**
|
||||
* Delete from the managed repository all files / directories associated with the
|
||||
* provided version reference.
|
||||
*
|
||||
* @param reference the version reference to delete.
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteVersion( VersionedReference reference )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* delete a specified artifact from the repository
|
||||
*
|
||||
* @param artifactReference
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteArtifact( ArtifactReference artifactReference )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param groupId
|
||||
* @throws ContentNotFoundException
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
void deleteGroupId( String groupId )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param namespace groupId for maven
|
||||
* @param projectId artifactId for maven
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteProject( String namespace, String projectId )
|
||||
throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a project
|
||||
* @param reference
|
||||
*/
|
||||
void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
|
||||
|
||||
String toPath( ContentItem item );
|
||||
|
||||
|
||||
|
||||
|
@ -341,45 +57,86 @@ public interface ManagedRepositoryContent extends RepositoryContent, GenericMana
|
|||
String getId();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Gather up the list of related artifacts to the ArtifactReference provided.
|
||||
* This typically includes the pom files, and those things with
|
||||
* classifiers (such as doc, source code, test libs, etc...). Even if the classifier
|
||||
* is set in the artifact reference, it may return artifacts with different classifiers.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
|
||||
* </p>
|
||||
* Delete all items that match the given selector. The type and number of deleted items
|
||||
* depend on the specific selector:
|
||||
* <ul>
|
||||
* <li>namespace: the complete namespace is deleted (recursively if the recurse flag is set)</li>
|
||||
* <li>project: the complete project and all contained versions are deleted</li>
|
||||
* <li>version: the version inside the project is deleted (project is required)</li>
|
||||
* <li>artifactId: all artifacts that match the id (project and version are required)</li>
|
||||
* <li>artifactVersion: all artifacts that match the version (project and version are required)</li>
|
||||
* <li></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param reference the reference to work off of.
|
||||
* @return the list of ArtifactReferences for related artifacts, if
|
||||
* @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
|
||||
* @param selector the item selector that selects the artifacts to delete
|
||||
* @param consumer a consumer of the items that will be called after deletion
|
||||
* @returns the list of items that are deleted
|
||||
* @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
|
||||
* to the artifacts failed
|
||||
* @throws IllegalArgumentException if the selector does not specify valid artifacts to delete
|
||||
*/
|
||||
List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
|
||||
throws ContentNotFoundException, LayoutException, ContentAccessException;
|
||||
|
||||
void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns all artifacts that belong to a given version
|
||||
* @param reference the version reference
|
||||
* @return the list of artifacts or a empty list
|
||||
* Removes the specified content item and if the item is a container or directory,
|
||||
* all content stored under the given item.
|
||||
*
|
||||
* @param item the item.
|
||||
* @throws ItemNotFoundException if the item cannot be found
|
||||
* @throws ContentAccessException if the deletion was not possible or only partly successful, because the access
|
||||
* to the artifacts failed
|
||||
*/
|
||||
List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
|
||||
|
||||
|
||||
|
||||
void deleteItem( ContentItem item ) throws ItemNotFoundException, ContentAccessException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Convenience method to get the repository (on disk) root directory.
|
||||
* </p>
|
||||
* <p>
|
||||
* Equivalent to calling <code>.getRepository().getLocation()</code>
|
||||
* </p>
|
||||
* Returns a item for the given selector. The type of the returned item depends on the
|
||||
* selector.
|
||||
*
|
||||
* @return the repository (on disk) root directory.
|
||||
* @param selector the item selector
|
||||
* @return the content item that matches the given selector
|
||||
* @throws ContentAccessException if an error occured while accessing the backend
|
||||
* @throws IllegalArgumentException if the selector does not select a valid content item
|
||||
*/
|
||||
String getRepoRoot();
|
||||
ContentItem getItem( ItemSelector selector ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a stream of items that match the given selector. It may return a stream of mixed types,
|
||||
* like namespaces, projects, versions and artifacts. It will not select a specific type.
|
||||
* The selector can specify the '*' pattern for all fields.
|
||||
* The returned elements will be provided by depth first.
|
||||
*
|
||||
* @param selector the item selector that specifies the items
|
||||
* @return the stream of content items
|
||||
* @throws ContentAccessException if the access to the underlying storage failed
|
||||
* @throws IllegalArgumentException if a illegal coordinate combination was provided
|
||||
*/
|
||||
Stream<? extends ContentItem> newItemStream( ItemSelector selector, boolean parallel ) throws ContentAccessException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the item that matches the given path. The item at the path must not exist.
|
||||
*
|
||||
* @param path the path string that points to the item
|
||||
* @return the content item if the path is a valid item path
|
||||
* @throws LayoutException if the path is not valid for the repository layout
|
||||
*/
|
||||
ContentItem toItem( String path ) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Returns the item that matches the given asset path. The asset must not exist.
|
||||
*
|
||||
* @param assetPath the path to the artifact or directory
|
||||
* @return the item, if it is a valid path for the repository layout
|
||||
* @throws LayoutException if the path is not valid for the repository
|
||||
*/
|
||||
ContentItem toItem( StorageAsset assetPath ) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Returns true, if the selector coordinates point to a existing item in the repository.
|
||||
*
|
||||
* @param selector the item selector
|
||||
* @return <code>true</code>, if there exists such a item, otherwise <code>false</code>
|
||||
*/
|
||||
boolean hasContent( ItemSelector selector );
|
||||
|
||||
/**
|
||||
* Get the repository configuration associated with this
|
||||
|
@ -389,23 +146,6 @@ public interface ManagedRepositoryContent extends RepositoryContent, GenericMana
|
|||
*/
|
||||
ManagedRepository getRepository();
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the artifact referenced exists in the repository.
|
||||
*
|
||||
* @param reference the artifact reference to check for.
|
||||
* @return true if the artifact referenced exists.
|
||||
*/
|
||||
boolean hasContent( ArtifactReference reference ) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Determines if the version reference exists in the repository.
|
||||
*
|
||||
* @param reference the version reference to check for.
|
||||
* @return true if the version referenced exists.
|
||||
*/
|
||||
boolean hasContent( VersionedReference reference ) throws ContentAccessException;
|
||||
|
||||
/**
|
||||
* Set the repository configuration to associate with this
|
||||
* repository content.
|
||||
|
@ -415,54 +155,43 @@ public interface ManagedRepositoryContent extends RepositoryContent, GenericMana
|
|||
void setRepository( ManagedRepository repo );
|
||||
|
||||
/**
|
||||
* Given an {@link ArtifactReference}, return the file reference to the artifact.
|
||||
*
|
||||
* @param reference the artifact reference to use.
|
||||
* @return the relative path to the artifact.
|
||||
* Returns the parent of the item.
|
||||
* @param item the current item
|
||||
* @return the parent item, or <code>null</code> if no such item exists
|
||||
*/
|
||||
StorageAsset toFile( VersionedReference reference );
|
||||
ContentItem getParent(ContentItem item);
|
||||
|
||||
/**
|
||||
* Given an {@link ArtifactReference}, return the file reference to the artifact.
|
||||
*
|
||||
* @param reference the artifact reference to use.
|
||||
* @return the relative path to the artifact.
|
||||
* Returns the list of children items.
|
||||
* @param item the current item
|
||||
* @return the list of children, or a empty list, if no children exist
|
||||
*/
|
||||
StorageAsset toFile( ArtifactReference reference );
|
||||
List<? extends ContentItem> getChildren( ContentItem item);
|
||||
|
||||
/**
|
||||
* Given an {@link ArchivaArtifact}, return the file reference to the artifact.
|
||||
* Tries to apply the given characteristic to the content item. If the layout does not allow this,
|
||||
* it will throw a <code>LayoutException</code>.
|
||||
*
|
||||
* @param reference the archiva artifact to use.
|
||||
* @return the relative path to the artifact.
|
||||
* @param clazz the characteristic class to apply
|
||||
* @param item the content item
|
||||
* @param <T> The characteristic
|
||||
* @return the applied characteristic
|
||||
*/
|
||||
StorageAsset toFile( ArchivaArtifact reference );
|
||||
<T extends ContentItem> T applyCharacteristic(Class<T> clazz, ContentItem item) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Given a {@link ProjectReference}, return the path to the metadata for
|
||||
* the project.
|
||||
*
|
||||
* @param reference the reference to use.
|
||||
* @return the path to the metadata file, or null if no metadata is appropriate.
|
||||
* Returns the given layout from the content.
|
||||
* @param clazz The layout class
|
||||
* @param <T> the layout class
|
||||
* @return the specific layout
|
||||
* @throws LayoutException if the repository does not support this layout type
|
||||
*/
|
||||
String toMetadataPath( ProjectReference reference );
|
||||
<T extends ManagedRepositoryContentLayout> T getLayout(Class<T> clazz) throws LayoutException;
|
||||
|
||||
/**
|
||||
* Given a {@link VersionedReference}, return the path to the metadata for
|
||||
* the specific version of the project.
|
||||
*
|
||||
* @param reference the reference to use.
|
||||
* @return the path to the metadata file, or null if no metadata is appropriate.
|
||||
* Returns <code>true</code>, if the specific layout is supported by this content.
|
||||
* @param clazz the layout class
|
||||
* @return <code>true</code>, if the layout is supported, otherwise <code>false</code>
|
||||
*/
|
||||
String toMetadataPath( VersionedReference reference );
|
||||
|
||||
/**
|
||||
* Given an {@link ArchivaArtifact}, return the relative path to the artifact.
|
||||
*
|
||||
* @param reference the archiva artifact to use.
|
||||
* @return the relative path to the artifact.
|
||||
*/
|
||||
String toPath( ArchivaArtifact reference );
|
||||
|
||||
|
||||
<T extends ManagedRepositoryContentLayout> boolean supportsLayout(Class<T> clazz);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package org.apache.archiva.repository;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Basic interface for content layouts.
|
||||
* A content layout provides specific content item instances for the content structure like Namespace,
|
||||
* Project, Version and their relationships.
|
||||
*
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public interface ManagedRepositoryContentLayout
|
||||
{
|
||||
ManagedRepositoryContent getGenericContent();
|
||||
}
|
|
@ -21,6 +21,7 @@ package org.apache.archiva.repository;
|
|||
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public interface RepositoryContentProvider
|
|||
* @return a new instance
|
||||
* @throws RepositoryException if the layout is not supported, or a error occured during initialization
|
||||
*/
|
||||
ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException;
|
||||
ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException;
|
||||
|
||||
/**
|
||||
* Creates a generic content object.
|
||||
|
|
|
@ -112,7 +112,7 @@ public interface RepositoryRequestInfo
|
|||
String getLayout( String requestPath );
|
||||
|
||||
/**
|
||||
* Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
|
||||
* Adjust the requestedPath to conform to the native layout of the provided {@link BaseRepositoryContentLayout}.
|
||||
*
|
||||
* @param requestPath the incoming requested path.
|
||||
* @return the adjusted (to native) path.
|
||||
|
|
|
@ -19,9 +19,8 @@ package org.apache.archiva.repository.content;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.repository.ItemConversionException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.UnsupportedConversionException;
|
||||
import org.apache.archiva.repository.ItemConversionException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class AbstractManagedRepository extends AbstractRepository imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setContent(ManagedRepositoryContent content) {
|
||||
public void setContent( ManagedRepositoryContent content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@ import org.apache.archiva.repository.content.Project;
|
|||
import org.apache.archiva.repository.content.base.builder.ProjectOptBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.ProjectWithIdBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithAssetBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithNamespaceBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithNamespaceObjectBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithProjectBuilder;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.archiva.repository.content.Project;
|
|||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.content.base.builder.VersionOptBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithAssetBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithNamespaceBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithProjectBuilder;
|
||||
import org.apache.archiva.repository.content.base.builder.WithVersionBuilder;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
|
|
@ -19,8 +19,10 @@ package org.apache.archiva.repository.content.base;
|
|||
*/
|
||||
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
|
@ -52,7 +54,15 @@ public class ArtifactUtil
|
|||
public Path getArtifactPath( ManagedRepository repository, ArtifactReference artifactReference ) throws RepositoryException
|
||||
{
|
||||
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
|
||||
final String artifactPath = content.toPath( artifactReference );
|
||||
final String artifactPath;
|
||||
try
|
||||
{
|
||||
artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
|
||||
}
|
||||
return Paths.get( repository.getLocation( ) ).resolve( artifactPath );
|
||||
}
|
||||
|
||||
|
@ -68,7 +78,15 @@ public class ArtifactUtil
|
|||
public StorageAsset getArtifactAsset( ManagedRepository repository, ArtifactReference artifactReference ) throws RepositoryException
|
||||
{
|
||||
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
|
||||
final String artifactPath = content.toPath( artifactReference );
|
||||
final String artifactPath;
|
||||
try
|
||||
{
|
||||
artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
|
||||
}
|
||||
return repository.getAsset( artifactPath );
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.apache.archiva.repository.content.base;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ItemConversionException;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
@ -40,8 +40,9 @@ import org.apache.archiva.model.VersionedReference;
|
|||
import org.apache.archiva.components.registry.Registry;
|
||||
import org.apache.archiva.components.registry.RegistryListener;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
|
@ -160,7 +161,7 @@ public class MetadataTools
|
|||
.withArtifactId( reference.getArtifactId( ) )
|
||||
.withVersion( reference.getVersion( ) )
|
||||
.build( );
|
||||
try(Stream<? extends Artifact> stream = managedRepository.newArtifactStream( selector )) {
|
||||
try(Stream<? extends Artifact> stream = managedRepository.getLayout( BaseRepositoryContentLayout.class ).newArtifactStream( selector )) {
|
||||
foundVersions = stream.map( a -> a.getArtifactVersion( ) )
|
||||
.filter( StringUtils::isNotEmpty )
|
||||
.collect( Collectors.toSet( ) );
|
||||
|
@ -533,6 +534,7 @@ public class MetadataTools
|
|||
|
||||
StorageAsset metadataFile = managedRepository.getRepository().getAsset( toPath( reference ) );
|
||||
ArchivaRepositoryMetadata existingMetadata = readMetadataFile( managedRepository, metadataFile );
|
||||
BaseRepositoryContentLayout layout = managedRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
long lastUpdated = getExistingLastUpdated( existingMetadata );
|
||||
|
||||
|
@ -548,8 +550,8 @@ public class MetadataTools
|
|||
Set<String> allVersions = null;
|
||||
try
|
||||
{
|
||||
Project project = managedRepository.getProject( selector );
|
||||
allVersions = managedRepository.getVersions( project ).stream()
|
||||
Project project = layout.getProject( selector );
|
||||
allVersions = layout.getVersions( project ).stream()
|
||||
.map( v -> v.getVersion() ).collect( Collectors.toSet());
|
||||
}
|
||||
catch ( org.apache.archiva.repository.ContentAccessException e )
|
||||
|
@ -923,7 +925,7 @@ public class MetadataTools
|
|||
* @throws IOException if the versioned reference is invalid (example: doesn't exist, or isn't a directory)
|
||||
* @throws LayoutException
|
||||
*/
|
||||
public ArtifactReference getFirstArtifact( ManagedRepositoryContent managedRepository,
|
||||
public ArtifactReference getFirstArtifact( BaseRepositoryContentLayout managedRepository,
|
||||
VersionedReference reference )
|
||||
throws LayoutException, IOException
|
||||
{
|
||||
|
|
|
@ -25,10 +25,12 @@ import org.apache.archiva.model.ProjectReference;
|
|||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentAccessException;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ItemDeleteStatus;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
|
@ -48,7 +50,7 @@ import java.util.stream.Stream;
|
|||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
@Service("managedRepositoryContent#mock")
|
||||
public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
||||
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
|
||||
{
|
||||
private ManagedRepository repository;
|
||||
|
||||
|
@ -205,6 +207,18 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
|
||||
{
|
||||
|
@ -243,6 +257,12 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath( ContentItem item )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId( )
|
||||
{
|
||||
|
@ -351,4 +371,9 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent getGenericContent( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.archiva.repository.mock;
|
|||
*/
|
||||
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.Repository;
|
||||
|
@ -63,7 +63,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException {
|
||||
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
|
||||
return new ManagedRepositoryContentMock();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.util.stream.Stream;
|
|||
/**
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
||||
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
|
||||
{
|
||||
private static final String PATH_SEPARATOR = "/";
|
||||
private static final String GROUP_SEPARATOR = ".";
|
||||
|
@ -205,6 +205,18 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
|
||||
{
|
||||
|
@ -253,6 +265,12 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath( ContentItem item )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId( )
|
||||
{
|
||||
|
@ -575,4 +593,9 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent getGenericContent( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.archiva.policies.ChecksumPolicy;
|
|||
import org.apache.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.policies.urlcache.UrlFailureCache;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.easymock.EasyMock;
|
||||
|
@ -42,8 +43,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
|
||||
/**
|
||||
* CacheFailuresTransferTest
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CacheFailuresTransferTest
|
||||
extends AbstractProxyTestCase
|
||||
|
@ -55,7 +54,7 @@ public class CacheFailuresTransferTest
|
|||
UrlFailureCache urlFailureCache;
|
||||
|
||||
@Test
|
||||
public void testGetWithCacheFailuresOn()
|
||||
public void testGetWithCacheFailuresOn( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
|
||||
|
@ -64,7 +63,8 @@ public class CacheFailuresTransferTest
|
|||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
|
||||
|
@ -72,34 +72,34 @@ public class CacheFailuresTransferTest
|
|||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
|
||||
|
||||
EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
|
||||
|
||||
wagonMockControl.replay();
|
||||
wagonMockControl.replay( );
|
||||
|
||||
//noinspection UnusedAssignment
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
wagonMockControl.verify();
|
||||
wagonMockControl.verify( );
|
||||
|
||||
// Second attempt to download same artifact use cache
|
||||
wagonMockControl.reset();
|
||||
wagonMockControl.replay();
|
||||
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
wagonMockControl.verify();
|
||||
wagonMockControl.reset( );
|
||||
wagonMockControl.replay( );
|
||||
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
wagonMockControl.verify( );
|
||||
|
||||
assertNotDownloaded( downloadedFile);
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertNoTempFiles( expectedFile );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWithCacheFailuresOff()
|
||||
public void testGetWithCacheFailuresOff( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
|
||||
|
@ -108,7 +108,8 @@ public class CacheFailuresTransferTest
|
|||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
|
||||
|
@ -117,69 +118,70 @@ public class CacheFailuresTransferTest
|
|||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
|
||||
EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
|
||||
EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
|
||||
wagonMockControl.replay();
|
||||
wagonMockControl.replay( );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
wagonMockControl.verify();
|
||||
wagonMockControl.verify( );
|
||||
|
||||
// Second attempt to download same artifact DOES NOT use cache
|
||||
wagonMockControl.reset();
|
||||
wagonMockControl.reset( );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
|
||||
EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
|
||||
EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
|
||||
|
||||
wagonMockControl.replay();
|
||||
wagonMockControl.replay( );
|
||||
|
||||
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
wagonMockControl.verify();
|
||||
wagonMockControl.verify( );
|
||||
|
||||
assertNotDownloaded( downloadedFile);
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertNoTempFiles( expectedFile );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWhenInBothProxiedButFirstCacheFailure()
|
||||
public void testGetWhenInBothProxiedButFirstCacheFailure( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
Path expectedFile = managedDefaultDir.resolve(path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
Files.deleteIfExists(expectedFile);
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
Files.deleteIfExists( expectedFile );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
String url = PathUtil.toUrl( REPOPATH_PROXIED1 + "/" + path );
|
||||
|
||||
// Intentionally set failure on url in proxied1 (for test)
|
||||
UrlFailureCache failurlCache = lookupUrlFailureCache();
|
||||
UrlFailureCache failurlCache = lookupUrlFailureCache( );
|
||||
failurlCache.cacheFailure( url );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
// Validate that file actually came from proxied2 (as intended).
|
||||
Path proxied2File = Paths.get( REPOPATH_PROXIED2, path );
|
||||
assertNotNull(downloadedFile);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied2File );
|
||||
assertNotNull( downloadedFile );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied2File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
}
|
||||
|
||||
protected UrlFailureCache lookupUrlFailureCache()
|
||||
protected UrlFailureCache lookupUrlFailureCache( )
|
||||
throws Exception
|
||||
{
|
||||
assertNotNull( "URL Failure Cache cannot be null.", urlFailureCache );
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.archiva.policies.CachedFailuresPolicy;
|
|||
import org.apache.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.easymock.EasyMock;
|
||||
|
@ -41,439 +42,454 @@ import static org.junit.Assert.assertNull;
|
|||
|
||||
/**
|
||||
* ChecksumTransferTest
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ChecksumTransferTest
|
||||
extends AbstractProxyTestCase
|
||||
{
|
||||
@Test
|
||||
public void testGetChecksumWhenConnectorIsDisabled()
|
||||
public void testGetChecksumWhenConnectorIsDisabled( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
assertNull( downloadedFile );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumBothCorrect()
|
||||
public void testGetChecksumBothCorrect( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
|
||||
"e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
|
||||
"e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumCorrectSha1NoMd5()
|
||||
public void testGetChecksumCorrectSha1NoMd5( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
|
||||
null );
|
||||
null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumNoSha1CorrectMd5()
|
||||
public void testGetChecksumNoSha1CorrectMd5( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWithNoChecksumsUsingIgnoredSetting()
|
||||
public void testGetWithNoChecksumsUsingIgnoredSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, null, null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumBadSha1BadMd5IgnoredSetting()
|
||||
public void testGetChecksumBadSha1BadMd5IgnoredSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumBadSha1BadMd5FailSetting()
|
||||
public void testGetChecksumBadSha1BadMd5FailSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertChecksums( expectedFile, null, null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumBadSha1BadMd5FixSetting()
|
||||
public void testGetChecksumBadSha1BadMd5FixSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "4ec20a12dc91557330bd0b39d1805be5e329ae56 get-checksum-both-bad-1.0.jar",
|
||||
"a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
|
||||
"a292491a35925465e693a44809a078b5 get-checksum-both-bad-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingFailSetting()
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingFailSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertChecksums( expectedFile, null, null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumNoSha1CorrectMd5UsingFailSetting()
|
||||
public void testGetChecksumNoSha1CorrectMd5UsingFailSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
// This is a success situation. No SHA1 with a Good MD5.
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWithNoChecksumsUsingFailSetting()
|
||||
public void testGetWithNoChecksumsUsingFailSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertChecksums( expectedFile, null, null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting()
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
|
||||
"invalid checksum file" );
|
||||
"invalid checksum file" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingFixSetting()
|
||||
public void testGetChecksumCorrectSha1BadMd5UsingFixSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
|
||||
"c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
|
||||
"c35f3b76268b73a4ba617f6f275c49ab get-checksum-sha1-bad-md5-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumNoSha1CorrectMd5UsingFixSetting()
|
||||
public void testGetChecksumNoSha1CorrectMd5UsingFixSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb get-checksum-md5-only-1.0.jar",
|
||||
"f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
|
||||
"f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWithNoChecksumsUsingFixSetting()
|
||||
public void testGetWithNoChecksumsUsingFixSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar",
|
||||
"3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
|
||||
"3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChecksumNotFoundOnRemote()
|
||||
public void testGetChecksumNotFoundOnRemote( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
FileUtils.deleteDirectory( expectedFile.getParent() );
|
||||
assertFalse( Files.exists(expectedFile.getParent()) );
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
FileUtils.deleteDirectory( expectedFile.getParent( ) );
|
||||
assertFalse( Files.exists( expectedFile.getParent( ) ) );
|
||||
assertFalse( Files.exists( expectedFile ) );
|
||||
|
||||
saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "http://bad.machine.com/repo/", "default" );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
|
||||
EasyMock.expectLastCall().once();
|
||||
wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) );
|
||||
EasyMock.expectLastCall( ).once( );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ));
|
||||
EasyMock.expectLastCall().once();
|
||||
wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class ) );
|
||||
EasyMock.expectLastCall( ).once( );
|
||||
|
||||
wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ));
|
||||
EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once();
|
||||
wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class ) );
|
||||
EasyMock.expectLastCall( ).andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once( );
|
||||
|
||||
wagonMockControl.replay();
|
||||
wagonMockControl.replay( );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
wagonMockControl.verify();
|
||||
wagonMockControl.verify( );
|
||||
|
||||
// Do what the mock doesn't do.
|
||||
Path proxyPath = Paths.get( REPOPATH_PROXIED1, path ).toAbsolutePath();
|
||||
Path localPath = managedDefaultDir.resolve( path ).toAbsolutePath();
|
||||
Files.copy( proxyPath, localPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.copy( proxyPath.resolveSibling( proxyPath.getFileName() + ".sha1" ),
|
||||
localPath.resolveSibling( localPath.getFileName() + ".sha1" ), StandardCopyOption.REPLACE_EXISTING );
|
||||
Path proxyPath = Paths.get( REPOPATH_PROXIED1, path ).toAbsolutePath( );
|
||||
Path localPath = managedDefaultDir.resolve( path ).toAbsolutePath( );
|
||||
Files.copy( proxyPath, localPath, StandardCopyOption.REPLACE_EXISTING );
|
||||
Files.copy( proxyPath.resolveSibling( proxyPath.getFileName( ) + ".sha1" ),
|
||||
localPath.resolveSibling( localPath.getFileName( ) + ".sha1" ), StandardCopyOption.REPLACE_EXISTING );
|
||||
|
||||
// Test results.
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
|
||||
null );
|
||||
null );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
|
||||
|
@ -484,23 +500,24 @@ public class ChecksumTransferTest
|
|||
|
||||
setManagedOlderThanRemote( expectedFile, remoteFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
// There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
|
||||
assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting()
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFailSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
|
||||
|
@ -511,13 +528,14 @@ public class ChecksumTransferTest
|
|||
|
||||
setManagedOlderThanRemote( expectedFile, remoteFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
assertNotDownloaded( downloadedFile );
|
||||
assertNoTempFiles( expectedFile );
|
||||
|
@ -528,29 +546,30 @@ public class ChecksumTransferTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting()
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting( )
|
||||
throws Exception
|
||||
{
|
||||
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
|
||||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
Path remoteFile = Paths.get( REPOPATH_PROXIED1, path );
|
||||
|
||||
setManagedOlderThanRemote( expectedFile, remoteFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository( ), artifact );
|
||||
|
||||
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath(), proxied1File );
|
||||
Path proxied1File = Paths.get( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile.getFilePath( ), proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4 get-bad-local-checksum-1.0.jar",
|
||||
"46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );
|
||||
"46fdd6ca55bf1d7a7eb0c858f41e0ccd get-bad-local-checksum-1.0.jar" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.proxy;
|
|||
*/
|
||||
|
||||
import org.apache.archiva.policies.*;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
@ -596,8 +597,9 @@ public class ErrorHandlingTest
|
|||
StorageAsset downloadedFile = null;
|
||||
try
|
||||
{
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toArtifactReference( path ) );
|
||||
layout.toArtifactReference( path ) );
|
||||
fail( "Proxy should not have succeeded" );
|
||||
}
|
||||
catch ( ProxyDownloadException e )
|
||||
|
@ -637,8 +639,10 @@ public class ErrorHandlingTest
|
|||
wagonMockControl.replay();
|
||||
|
||||
// Attempt the proxy fetch.
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toArtifactReference( path ) );
|
||||
layout.toArtifactReference( path ) );
|
||||
|
||||
wagonMockControl.verify();
|
||||
return downloadedFile;
|
||||
|
|
|
@ -219,9 +219,10 @@ public class HttpProxyTransferTest
|
|||
|
||||
managedDefaultRepository = repositoryRegistry.getManagedRepository(MANAGED_ID).getContent();
|
||||
|
||||
Path expectedFile = Paths.get( managedDefaultRepository.getRepoRoot() ).resolve( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
Path expectedFile = managedDefaultRepository.getRepository().getAsset( "" ).resolve( path ).getFilePath();
|
||||
Files.deleteIfExists( expectedFile );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Attempt the proxy fetch.
|
||||
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.archiva.policies.CachedFailuresPolicy;
|
|||
import org.apache.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -55,7 +56,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Ensure file isn't present first.
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
@ -77,7 +81,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Ensure file isn't present first.
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
@ -138,7 +145,9 @@ public class ManagedDefaultTransferTest
|
|||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
|
||||
|
@ -218,7 +227,10 @@ public class ManagedDefaultTransferTest
|
|||
setManagedNewerThanRemote( expectedFile, remoteFile );
|
||||
|
||||
long originalModificationTime = Files.getLastModifiedTime( expectedFile).toMillis();
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
|
||||
|
@ -263,7 +275,9 @@ public class ManagedDefaultTransferTest
|
|||
// Set the managed file to be newer than remote file.
|
||||
setManagedOlderThanRemote( expectedFile, remoteFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
|
||||
|
@ -294,7 +308,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
Files.setLastModifiedTime( expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS ));
|
||||
|
@ -319,7 +336,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
|
@ -350,7 +370,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
|
@ -374,7 +397,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
|
@ -398,7 +424,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
|
@ -432,7 +461,10 @@ public class ManagedDefaultTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve( path );
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertNotExistsInManagedDefaultRepo( expectedFile );
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.archiva.policies.CachedFailuresPolicy;
|
|||
import org.apache.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.metadata.base.MetadataTools;
|
||||
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.archiva.repository.metadata.base.RepositoryMetadataWriter;
|
||||
|
@ -128,8 +129,9 @@ public class MetadataTransferTest
|
|||
|
||||
ProjectReference metadata = createProjectReference( requestedResource );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toMetadataPath(
|
||||
layout.toMetadataPath(
|
||||
metadata ) ).getFile();
|
||||
|
||||
assertNull( "Should not have downloaded a file.", downloadedFile );
|
||||
|
@ -991,8 +993,10 @@ public class MetadataTransferTest
|
|||
|
||||
ProjectReference metadata = createProjectReference( requestedResource );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toMetadataPath(
|
||||
layout.toMetadataPath(
|
||||
metadata ) ).getFile();
|
||||
|
||||
assertNotNull( "Should have downloaded a file.", downloadedFile );
|
||||
|
@ -1017,8 +1021,9 @@ public class MetadataTransferTest
|
|||
Path expectedFile = managedDefaultDir.resolve(requestedResource);
|
||||
ProjectReference metadata = createProjectReference( requestedResource );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toMetadataPath(
|
||||
layout.toMetadataPath(
|
||||
metadata ) ).getFile();
|
||||
|
||||
assertNull( downloadedFile );
|
||||
|
@ -1038,8 +1043,9 @@ public class MetadataTransferTest
|
|||
|
||||
VersionedReference metadata = createVersionedReference( requestedResource );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toMetadataPath(
|
||||
layout.toMetadataPath(
|
||||
metadata ) ).getFile();
|
||||
|
||||
assertNotNull( "Should have downloaded a file.", downloadedFile );
|
||||
|
@ -1064,8 +1070,9 @@ public class MetadataTransferTest
|
|||
Path expectedFile = managedDefaultDir.resolve(requestedResource);
|
||||
VersionedReference metadata = createVersionedReference( requestedResource );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies( managedDefaultRepository.getRepository(),
|
||||
managedDefaultRepository.toMetadataPath(
|
||||
layout.toMetadataPath(
|
||||
metadata ) ).getFile();
|
||||
|
||||
assertNull( downloadedFile );
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.archiva.policies.CachedFailuresPolicy;
|
|||
import org.apache.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -52,7 +53,8 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
Files.deleteIfExists(expectedFile);
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
|
@ -73,7 +75,9 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
Files.deleteIfExists(expectedFile);
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
|
@ -96,7 +100,9 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
Files.setLastModifiedTime( expectedFile, FileTime.from( getPastDate().getTime(), TimeUnit.MILLISECONDS ));
|
||||
|
@ -122,8 +128,10 @@ public class SnapshotTransferTest
|
|||
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
|
||||
|
||||
setManagedNewerThanRemote( expectedFile, remoteFile );
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
|
||||
|
@ -211,7 +219,8 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
|
||||
|
@ -239,8 +248,10 @@ public class SnapshotTransferTest
|
|||
|
||||
setManagedNewerThanRemote( expectedFile, remoteFile, 12000000 );
|
||||
long expectedTimestamp = Files.getLastModifiedTime( expectedFile ).toMillis();
|
||||
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false);
|
||||
|
@ -260,7 +271,10 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
Files.deleteIfExists(expectedFile);
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
|
@ -286,7 +300,10 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
Files.deleteIfExists(expectedFile);
|
||||
assertFalse( Files.exists(expectedFile) );
|
||||
|
@ -312,7 +329,10 @@ public class SnapshotTransferTest
|
|||
setupTestableManagedRepository( path );
|
||||
|
||||
Path expectedFile = managedDefaultDir.resolve(path);
|
||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||
|
||||
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifact = layout.toArtifactReference( path );
|
||||
|
||||
assertTrue( Files.exists(expectedFile) );
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ import java.util.stream.Stream;
|
|||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
@Service("managedRepositoryContent#mock")
|
||||
public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
||||
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent
|
||||
{
|
||||
private static final String PATH_SEPARATOR = "/";
|
||||
private static final String GROUP_SEPARATOR = ".";
|
||||
|
@ -209,6 +209,18 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArtifact( Path sourceFile, Artifact destination ) throws IllegalArgumentException
|
||||
{
|
||||
|
@ -257,6 +269,12 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath( ContentItem item )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId( )
|
||||
{
|
||||
|
@ -579,4 +597,9 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent getGenericContent( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException {
|
||||
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
|
||||
return new ManagedRepositoryContentMock(repository);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.repository.maven.content;
|
|||
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.Maven2RepositoryPathTranslator;
|
||||
import org.apache.archiva.model.ArchivaArtifact;
|
||||
|
@ -208,6 +209,8 @@ public abstract class AbstractDefaultRepositoryContent implements RepositoryCont
|
|||
reference.getClassifier(), reference.getType() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String formatAsDirectory( String directory )
|
||||
{
|
||||
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
|
||||
|
|
|
@ -24,24 +24,23 @@ import org.apache.archiva.configuration.FileTypes;
|
|||
import org.apache.archiva.metadata.maven.MavenMetadataReader;
|
||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||
import org.apache.archiva.model.ArchivaArtifact;
|
||||
import org.apache.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentAccessException;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.EditableManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ItemDeleteStatus;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ArtifactType;
|
||||
import org.apache.archiva.repository.content.BaseArtifactTypes;
|
||||
import org.apache.archiva.repository.content.BaseDataItemTypes;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.DataItem;
|
||||
import org.apache.archiva.repository.content.DataItemType;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.Namespace;
|
||||
|
@ -55,7 +54,6 @@ import org.apache.archiva.repository.content.base.ArchivaVersion;
|
|||
import org.apache.archiva.repository.content.base.builder.ArtifactOptBuilder;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.DefaultArtifactMappingProvider;
|
||||
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.archiva.repository.storage.RepositoryStorage;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.archiva.repository.storage.util.StorageUtil;
|
||||
|
@ -64,7 +62,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Name;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
|
@ -74,7 +71,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -87,7 +83,7 @@ import java.util.stream.Stream;
|
|||
*/
|
||||
public class ManagedDefaultRepositoryContent
|
||||
extends AbstractDefaultRepositoryContent
|
||||
implements ManagedRepositoryContent
|
||||
implements BaseRepositoryContentLayout
|
||||
{
|
||||
|
||||
// attribute flag that marks version objects that point to a snapshot artifact version
|
||||
|
@ -479,6 +475,12 @@ public class ManagedDefaultRepositoryContent
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent getGenericContent( )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// Simple object to hold artifact information
|
||||
private class ArtifactInfo
|
||||
{
|
||||
|
@ -1204,6 +1206,22 @@ public class ManagedDefaultRepositoryContent
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> T getLayout( Class<T> clazz ) throws LayoutException
|
||||
{
|
||||
if (clazz.isAssignableFrom( this.getClass() )) {
|
||||
return (T) this;
|
||||
} else {
|
||||
throw new LayoutException( "Cannot convert to layout " + clazz );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ManagedRepositoryContentLayout> boolean supportsLayout( Class<T> clazz )
|
||||
{
|
||||
return clazz.isAssignableFrom( this.getClass( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the file to the artifact destination
|
||||
*/
|
||||
|
@ -1274,6 +1292,10 @@ public class ManagedDefaultRepositoryContent
|
|||
return toVersion( artifactReference.getGroupId( ), artifactReference.getArtifactId( ), artifactReference.getVersion( ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath( ContentItem item ) {
|
||||
return item.getAsset( ).getPath( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVersion( VersionedReference ref ) throws ContentNotFoundException, ContentAccessException
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.archiva.common.filelock.FileLockManager;
|
|||
import org.apache.archiva.configuration.FileTypes;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.Repository;
|
||||
|
@ -98,7 +98,7 @@ public class MavenContentProvider implements RepositoryContentProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException
|
||||
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository ) throws RepositoryException
|
||||
{
|
||||
if (!supports( repository.getType() )) {
|
||||
throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
|
||||
|
@ -118,7 +118,7 @@ public class MavenContentProvider implements RepositoryContentProvider
|
|||
if (!supports( repository.getType() )) {
|
||||
throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );
|
||||
}
|
||||
if (repository instanceof ManagedRepository && ManagedRepositoryContent.class.isAssignableFrom( clazz ) ) {
|
||||
if (repository instanceof ManagedRepository && BaseRepositoryContentLayout.class.isAssignableFrom( clazz ) ) {
|
||||
return (T) this.createManagedContent( (ManagedRepository) repository );
|
||||
} else if (repository instanceof RemoteRepository && RemoteRepository.class.isAssignableFrom( clazz )) {
|
||||
return (T) this.createRemoteContent( (RemoteRepository) repository );
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.archiva.model.ArtifactReference;
|
|||
import org.apache.archiva.repository.*;
|
||||
import org.apache.archiva.repository.content.PathParser;
|
||||
import org.apache.archiva.repository.features.RepositoryFeature;
|
||||
import org.apache.archiva.repository.maven.content.DefaultPathParser;
|
||||
import org.apache.archiva.repository.metadata.base.MetadataTools;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -244,7 +243,7 @@ public class MavenRepositoryRequestInfo implements RepositoryRequestInfo
|
|||
}
|
||||
|
||||
/**
|
||||
* Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
|
||||
* Adjust the requestedPath to conform to the native layout of the provided {@link BaseRepositoryContentLayout}.
|
||||
*
|
||||
* @param requestedPath the incoming requested path.
|
||||
* @return the adjusted (to native) path.
|
||||
|
@ -281,7 +280,7 @@ public class MavenRepositoryRequestInfo implements RepositoryRequestInfo
|
|||
|
||||
// Treat as an artifact reference.
|
||||
ArtifactReference ref = toArtifactReference( referencedResource );
|
||||
String adjustedPath = repository.getContent().toPath( ref );
|
||||
String adjustedPath = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( ref );
|
||||
return adjustedPath + supportfile;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ import org.apache.archiva.metadata.maven.MavenMetadataReader;
|
|||
import org.apache.archiva.maven2.model.TreeEntry;
|
||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||
import org.apache.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
|
@ -48,6 +50,7 @@ import org.eclipse.aether.collection.CollectResult;
|
|||
import org.eclipse.aether.collection.DependencyCollectionException;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.graph.DependencyVisitor;
|
||||
import org.jsoup.Connection;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -156,7 +159,14 @@ public class Maven3DependencyTreeBuilder
|
|||
// FIXME take care of relative path
|
||||
ResolveRequest resolveRequest = new ResolveRequest();
|
||||
resolveRequest.dependencyVisitor = dependencyVisitor;
|
||||
resolveRequest.localRepoDir = repository.getContent().getRepoRoot();
|
||||
try
|
||||
{
|
||||
resolveRequest.localRepoDir = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).getRepoRoot();
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new DependencyTreeBuilderException( "Could not convert to layout " + e.getMessage( ), e );
|
||||
}
|
||||
resolveRequest.groupId = groupId;
|
||||
resolveRequest.artifactId = artifactId;
|
||||
resolveRequest.version = version;
|
||||
|
|
|
@ -585,7 +585,15 @@ public class Maven2RepositoryStorage
|
|||
proxyHandler.fetchFromProxies(managedRepository, pomReference);
|
||||
|
||||
// Open and read the POM from the managed repo
|
||||
StorageAsset pom = managedRepository.getContent().toFile(pomReference);
|
||||
StorageAsset pom = null;
|
||||
try
|
||||
{
|
||||
pom = managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toFile(pomReference);
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new ProxyDownloadException( "Cannot convert layout ", new HashMap<>( ) );
|
||||
}
|
||||
|
||||
if (!pom.exists()) {
|
||||
return;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.apache.archiva.repository.maven;
|
|||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContentProvider;
|
||||
import org.apache.archiva.repository.maven.MavenManagedRepository;
|
||||
import org.apache.archiva.repository.maven.MavenRemoteRepository;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
|
|
|
@ -30,7 +30,7 @@ import static org.junit.Assert.fail;
|
|||
*
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public abstract class AbstractManagedRepositoryContentTest extends AbstractRepositoryContentTest
|
||||
public abstract class AbstractBaseRepositoryContentLayoutTest extends AbstractRepositoryContentTest
|
||||
{
|
||||
|
||||
@Override
|
|
@ -22,7 +22,7 @@ import org.apache.archiva.model.ArtifactReference;
|
|||
import org.apache.archiva.repository.RepositoryContent;
|
||||
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.Namespace;
|
||||
|
@ -642,7 +642,7 @@ public abstract class AbstractRepositoryContentTest
|
|||
|
||||
protected abstract ItemSelector toItemSelector(String path) throws LayoutException;
|
||||
|
||||
protected abstract ManagedRepositoryContent getManaged();
|
||||
protected abstract BaseRepositoryContentLayout getManaged();
|
||||
|
||||
protected abstract RepositoryContent getContent( );
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@ import org.apache.archiva.model.ArtifactReference;
|
|||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.EditableManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryContent;
|
||||
import org.apache.archiva.repository.content.Artifact;
|
||||
import org.apache.archiva.repository.content.BaseArtifactTypes;
|
||||
|
@ -42,11 +43,9 @@ import org.apache.archiva.repository.content.Namespace;
|
|||
import org.apache.archiva.repository.content.Project;
|
||||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.content.base.ArchivaContentItem;
|
||||
import org.apache.archiva.repository.content.base.ArchivaDataItem;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.apache.archiva.repository.maven.MavenManagedRepository;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.repository.metadata.MetadataReader;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Before;
|
||||
|
@ -73,7 +72,7 @@ import static org.junit.Assert.*;
|
|||
* ManagedDefaultRepositoryContentTest
|
||||
*/
|
||||
public class ManagedDefaultRepositoryContentTest
|
||||
extends AbstractManagedRepositoryContentTest
|
||||
extends AbstractBaseRepositoryContentLayoutTest
|
||||
{
|
||||
private ManagedDefaultRepositoryContent repoContent;
|
||||
|
||||
|
@ -411,7 +410,7 @@ public class ManagedDefaultRepositoryContentTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ManagedRepositoryContent getManaged( )
|
||||
protected BaseRepositoryContentLayout getManaged( )
|
||||
{
|
||||
return repoContent;
|
||||
}
|
||||
|
@ -1044,38 +1043,18 @@ public class ManagedDefaultRepositoryContentTest
|
|||
assertTrue( result.stream( ).anyMatch( a -> "axis2-1.3-20070725.210059-1.pom".equals( a.getAsset( ).getName( ) ) ) );
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testNewItemStreamWithNamespace2() {
|
||||
// ItemSelector selector = ArchivaItemSelector.builder( )
|
||||
// .withNamespace( "org.apache.maven" )
|
||||
// .build();
|
||||
//
|
||||
// Stream<? extends ContentItem> stream = repoContent.newItemStream( selector, false );
|
||||
// List<? extends ContentItem> result = stream.collect( Collectors.toList( ) );
|
||||
// int versions = 0;
|
||||
// int projects = 0;
|
||||
// int artifacts = 0;
|
||||
// int namespaces = 0;
|
||||
// int dataitems = 0;
|
||||
// for (int i=0; i<result.size(); i++) {
|
||||
// ContentItem ci = result.get( i );
|
||||
// System.out.println( i + ": " + result.get( i ) + " - " +result.get(i).getClass().getName() + " - " + result.get(i).getAsset().getPath() );
|
||||
// if (ci instanceof Version) {
|
||||
// versions++;
|
||||
// } else if (ci instanceof Project) {
|
||||
// projects++;
|
||||
// } else if (ci instanceof Namespace) {
|
||||
// namespaces++;
|
||||
// } else if (ci instanceof Artifact) {
|
||||
// artifacts++;
|
||||
// } else if (ci instanceof DataItem ) {
|
||||
// dataitems++;
|
||||
// }
|
||||
// }
|
||||
// System.out.println( "namespaces=" + namespaces + ", projects=" + projects + ", versions=" + versions + ", artifacts=" + artifacts + ", dataitems=" + dataitems );
|
||||
// assertEquals( 170, result.size( ) );
|
||||
// assertEquals( 92, result.stream( ).filter( a -> a instanceof Artifact ).count( ) );
|
||||
// }
|
||||
@Test
|
||||
public void testNewItemStreamWithNamespace2() {
|
||||
ItemSelector selector = ArchivaItemSelector.builder( )
|
||||
.withNamespace( "org.apache.maven" )
|
||||
.recurse()
|
||||
.build();
|
||||
|
||||
Stream<? extends ContentItem> stream = repoContent.newItemStream( selector, false );
|
||||
List<? extends ContentItem> result = stream.collect( Collectors.toList( ) );
|
||||
assertEquals( 170, result.size( ) );
|
||||
assertEquals( 92, result.stream( ).filter( a -> a instanceof DataItem ).count( ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetArtifactFromContentItem() {
|
||||
|
@ -1569,10 +1548,11 @@ public class ManagedDefaultRepositoryContentTest
|
|||
|
||||
|
||||
@Test
|
||||
public void testAddArtifact() throws IOException, URISyntaxException
|
||||
public void testAddArtifact() throws IOException, URISyntaxException, LayoutException
|
||||
{
|
||||
ManagedRepository repo = createManagedRepoWithContent( "delete-repository" );
|
||||
ManagedRepositoryContent myRepoContent = repo.getContent( );
|
||||
BaseRepositoryContentLayout layout = myRepoContent.getLayout( BaseRepositoryContentLayout.class );
|
||||
Path repoRoot = repo.getAsset( "" ).getFilePath( );
|
||||
|
||||
Path tmpFile = Files.createTempFile( "archiva-mvn-repotest", "jar" );
|
||||
|
@ -1594,8 +1574,8 @@ public class ManagedDefaultRepositoryContentTest
|
|||
.withArtifactVersion( "2.0" )
|
||||
.withExtension( "jar" )
|
||||
.build( );
|
||||
Artifact artifact = myRepoContent.getArtifact( selector );
|
||||
myRepoContent.addArtifact( tmpFile, artifact );
|
||||
Artifact artifact = layout.getArtifact( selector );
|
||||
layout.addArtifact( tmpFile, artifact );
|
||||
FileTime lmtAfter = Files.getLastModifiedTime( file );
|
||||
assertNotEquals( lmtAfter, lmt );
|
||||
Reader ln = Files.newBufferedReader( file, Charset.forName( "UTF-8" ) );
|
||||
|
@ -1622,8 +1602,8 @@ public class ManagedDefaultRepositoryContentTest
|
|||
.withArtifactVersion( "2.0" )
|
||||
.withExtension( "test" )
|
||||
.build( );
|
||||
artifact = myRepoContent.getArtifact( selector );
|
||||
myRepoContent.addArtifact( tmpFile, artifact );
|
||||
artifact = layout.getArtifact( selector );
|
||||
layout.addArtifact( tmpFile, artifact );
|
||||
ln = Files.newBufferedReader( file, Charset.forName( "UTF-8" ) );
|
||||
ln.read( content );
|
||||
assertTrue( new String( content ).startsWith( "test.test.test" ) );
|
||||
|
|
|
@ -23,10 +23,10 @@ import org.apache.archiva.common.utils.FileUtils;
|
|||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.FileType;
|
||||
import org.apache.archiva.configuration.FileTypes;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContentProvider;
|
||||
import org.apache.archiva.repository.maven.MavenManagedRepository;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.archiva.repository.maven.content;
|
|||
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContent;
|
||||
|
@ -69,7 +69,7 @@ public class RemoteDefaultRepositoryContentTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ManagedRepositoryContent getManaged( )
|
||||
protected BaseRepositoryContentLayout getManaged( )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.repository.maven.metadata;
|
|||
|
||||
import org.apache.archiva.common.utils.VersionComparator;
|
||||
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.mock.MockConfiguration;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
|
@ -29,7 +30,6 @@ import org.apache.archiva.policies.ReleasesPolicy;
|
|||
import org.apache.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContentProvider;
|
||||
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
|
||||
|
@ -407,7 +407,7 @@ public class MetadataToolsTest
|
|||
ProjectReference reference )
|
||||
throws LayoutException, IOException, SAXException, ParserConfigurationException
|
||||
{
|
||||
Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
|
||||
Path metadataFile = repository.getRepository().getAsset( "" ).getFilePath().resolve(tools.toPath( reference ) );
|
||||
String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
|
||||
|
||||
Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build();
|
||||
|
@ -425,7 +425,7 @@ public class MetadataToolsTest
|
|||
VersionedReference reference )
|
||||
throws LayoutException, IOException, SAXException, ParserConfigurationException
|
||||
{
|
||||
Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
|
||||
Path metadataFile = repository.getRepository().getAsset("").getFilePath().resolve( tools.toPath( reference ) );
|
||||
String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
|
||||
|
||||
Diff detailedDiff = DiffBuilder.compare( expectedMetadata ).withTest( actualMetadata ).checkForSimilar().build();
|
||||
|
@ -656,7 +656,7 @@ public class MetadataToolsTest
|
|||
|
||||
Path srcRepoDir = getRepositoryPath( "metadata-repository" );
|
||||
Path srcDir = srcRepoDir.resolve( path );
|
||||
Path destDir = Paths.get( repo.getRepoRoot(), path );
|
||||
Path destDir = repo.getRepository().getAsset( "" ).getFilePath().resolve( path );
|
||||
|
||||
assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
|
||||
Files.createDirectories(destDir);
|
||||
|
|
|
@ -23,9 +23,10 @@ import org.apache.archiva.consumers.AbstractMonitoredConsumer;
|
|||
import org.apache.archiva.consumers.ConsumerException;
|
||||
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -97,7 +98,7 @@ public class TestConsumer
|
|||
{
|
||||
try
|
||||
{
|
||||
consumed.add( repository.toArtifactReference( path ) );
|
||||
consumed.add( repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ) );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
|||
import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal;
|
||||
import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
|
||||
import org.apache.archiva.redback.users.User;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.metadata.audit.AuditListener;
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.apache.archiva.rest.services;
|
|||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.common.utils.VersionComparator;
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.apache.archiva.repository.maven.dependency.tree.DependencyTreeBuilder;
|
||||
import org.apache.archiva.maven2.model.Artifact;
|
||||
import org.apache.archiva.maven2.model.TreeEntry;
|
||||
|
@ -32,12 +34,10 @@ import org.apache.archiva.metadata.model.ProjectVersionReference;
|
|||
import org.apache.archiva.metadata.repository.*;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMetadataVersionComparator;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.MavenProjectFacet;
|
||||
import org.apache.archiva.model.ArchivaArtifact;
|
||||
import org.apache.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.archiva.proxy.ProxyRegistry;
|
||||
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
|
||||
import org.apache.archiva.components.cache.Cache;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryNotFoundException;
|
||||
|
@ -93,7 +93,7 @@ public class DefaultBrowseService
|
|||
@Named( value = "browse#versionMetadata" )
|
||||
private Cache<String, ProjectVersionMetadata> versionMetadataCache;
|
||||
|
||||
private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
|
||||
private ManagedRepositoryContent getManagedRepositoryContent( String id) throws RepositoryException
|
||||
{
|
||||
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
|
||||
if (repo==null) {
|
||||
|
@ -746,10 +746,12 @@ public class DefaultBrowseService
|
|||
|
||||
ManagedRepositoryContent managedRepositoryContent =
|
||||
getManagedRepositoryContent( repoId );
|
||||
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
|
||||
StringUtils.isEmpty( type ) ? "jar" : type,
|
||||
repoId );
|
||||
StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
|
||||
ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
|
||||
.withProjectId( artifactId ).withVersion( version ).withClassifier( classifier )
|
||||
.withType( StringUtils.isEmpty( type ) ? "jar" : type )
|
||||
.withArtifactId( artifactId ).build();
|
||||
org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
|
||||
StorageAsset file = archivaArtifact.getAsset();
|
||||
if ( file.exists() )
|
||||
{
|
||||
return readFileEntries( file, path, repoId );
|
||||
|
@ -835,10 +837,12 @@ public class DefaultBrowseService
|
|||
log.error("No repository content found for "+repoId);
|
||||
continue;
|
||||
}
|
||||
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
|
||||
StringUtils.isEmpty( type ) ? "jar" : type,
|
||||
repoId );
|
||||
StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
|
||||
ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
|
||||
.withProjectId( artifactId ).withVersion( version ).withClassifier( classifier )
|
||||
.withType( StringUtils.isEmpty( type ) ? "jar" : type )
|
||||
.withArtifactId( artifactId ).build();
|
||||
org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
|
||||
StorageAsset file = archivaArtifact.getAsset( );
|
||||
if ( !file.exists() )
|
||||
{
|
||||
log.debug( "file: {} not exists for repository: {} try next repository", file, repoId );
|
||||
|
@ -905,11 +909,14 @@ public class DefaultBrowseService
|
|||
ManagedRepositoryContent managedRepositoryContent = getManagedRepositoryContent( repoId );
|
||||
|
||||
// FIXME default to jar which can be wrong for war zip etc....
|
||||
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version,
|
||||
StringUtils.isEmpty( classifier )
|
||||
? ""
|
||||
: classifier, "jar", repoId );
|
||||
StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
|
||||
ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
|
||||
.withProjectId( artifactId ).withVersion( version ).withClassifier( StringUtils.isEmpty( classifier )
|
||||
? ""
|
||||
: classifier )
|
||||
.withType( "jar" )
|
||||
.withArtifactId( artifactId ).build();
|
||||
org.apache.archiva.repository.content.Artifact archivaArtifact = managedRepositoryContent.getItem( itemSelector ).adapt( org.apache.archiva.repository.content.Artifact.class );
|
||||
StorageAsset file = archivaArtifact.getAsset( );
|
||||
|
||||
if ( file != null && file.exists() )
|
||||
{
|
||||
|
|
|
@ -44,13 +44,15 @@ import org.apache.archiva.redback.users.User;
|
|||
import org.apache.archiva.redback.users.UserManagerException;
|
||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryNotFoundException;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.content.ContentItem;
|
||||
import org.apache.archiva.repository.content.ItemNotFoundException;
|
||||
import org.apache.archiva.repository.content.Version;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
|
@ -189,7 +191,7 @@ public class DefaultRepositoriesService
|
|||
}
|
||||
}
|
||||
|
||||
private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
|
||||
private ManagedRepositoryContent getManagedRepositoryContent( String id) throws RepositoryException
|
||||
{
|
||||
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
|
||||
if (repo==null) {
|
||||
|
@ -372,8 +374,8 @@ public class DefaultRepositoriesService
|
|||
|
||||
ManagedRepositoryContent sourceRepository =
|
||||
getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
|
||||
|
||||
String artifactSourcePath = sourceRepository.toPath( artifactReference );
|
||||
BaseRepositoryContentLayout layout = sourceRepository.getLayout( BaseRepositoryContentLayout.class );
|
||||
String artifactSourcePath = layout.toPath( artifactReference );
|
||||
|
||||
if ( StringUtils.isEmpty( artifactSourcePath ) )
|
||||
{
|
||||
|
@ -394,7 +396,7 @@ public class DefaultRepositoriesService
|
|||
ManagedRepositoryContent targetRepository =
|
||||
getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
|
||||
|
||||
String artifactPath = targetRepository.toPath( artifactReference );
|
||||
String artifactPath = layout.toPath( artifactReference );
|
||||
|
||||
int lastIndex = artifactPath.lastIndexOf( '/' );
|
||||
|
||||
|
@ -469,7 +471,7 @@ public class DefaultRepositoriesService
|
|||
log.debug("copyArtifact {}", msg);
|
||||
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
catch ( RepositoryException | LayoutException e )
|
||||
{
|
||||
log.error( "RepositoryException: {}", e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( e.getMessage(), e );
|
||||
|
@ -663,14 +665,14 @@ public class DefaultRepositoriesService
|
|||
try
|
||||
{
|
||||
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
|
||||
|
||||
BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArchivaItemSelector selector = ArchivaItemSelector.builder( )
|
||||
.withNamespace( namespace )
|
||||
.withProjectId( projectId )
|
||||
.withVersion( version )
|
||||
.build( );
|
||||
Version versionItem = repository.getVersion( selector );
|
||||
Version versionItem = layout.getVersion( selector );
|
||||
if (versionItem!=null && versionItem.exists()) {
|
||||
repository.deleteItem( versionItem );
|
||||
}
|
||||
|
@ -687,7 +689,7 @@ public class DefaultRepositoriesService
|
|||
|
||||
metadataRepository.removeProjectVersion(repositorySession , repositoryId, namespace, projectId, version );
|
||||
}
|
||||
catch ( MetadataRepositoryException | MetadataResolutionException | RepositoryException | ItemNotFoundException e )
|
||||
catch ( MetadataRepositoryException | MetadataResolutionException | RepositoryException | ItemNotFoundException | LayoutException e )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
|
@ -773,6 +775,7 @@ public class DefaultRepositoriesService
|
|||
ref.setVersion( artifact.getVersion() );
|
||||
|
||||
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
|
||||
BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class );
|
||||
|
||||
ArtifactReference artifactReference = new ArtifactReference();
|
||||
artifactReference.setArtifactId( artifact.getArtifactId() );
|
||||
|
@ -793,7 +796,7 @@ public class DefaultRepositoriesService
|
|||
|
||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
|
||||
String path = repository.toMetadataPath( ref );
|
||||
String path = layout.toMetadataPath( ref );
|
||||
|
||||
if ( StringUtils.isNotBlank( artifact.getClassifier() ) )
|
||||
{
|
||||
|
@ -802,7 +805,7 @@ public class DefaultRepositoriesService
|
|||
throw new ArchivaRestServiceException( "You must configure a type/packaging when using classifier",
|
||||
400, null );
|
||||
}
|
||||
List<? extends org.apache.archiva.repository.content.Artifact> artifactItems = repository.getArtifacts( selector );
|
||||
List<? extends org.apache.archiva.repository.content.Artifact> artifactItems = layout.getArtifacts( selector );
|
||||
for ( org.apache.archiva.repository.content.Artifact aRef : artifactItems ) {
|
||||
try
|
||||
{
|
||||
|
@ -834,19 +837,19 @@ public class DefaultRepositoriesService
|
|||
// delete from file system
|
||||
if ( !snapshotVersion )
|
||||
{
|
||||
repository.deleteVersion( ref );
|
||||
layout.deleteVersion( ref );
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are deleting all version related artifacts for a snapshot version
|
||||
VersionedReference versionRef = repository.toVersion( artifactReference );
|
||||
List<ArtifactReference> related = repository.getRelatedArtifacts( versionRef );
|
||||
VersionedReference versionRef = layout.toVersion( artifactReference );
|
||||
List<ArtifactReference> related = layout.getRelatedArtifacts( versionRef );
|
||||
log.debug( "related: {}", related );
|
||||
for ( ArtifactReference artifactRef : related )
|
||||
{
|
||||
try
|
||||
{
|
||||
repository.deleteArtifact( artifactRef );
|
||||
layout.deleteArtifact( artifactRef );
|
||||
} catch (ContentNotFoundException e) {
|
||||
log.warn( "Artifact that should be deleted, was not found: {}", artifactRef );
|
||||
}
|
||||
|
@ -1014,8 +1017,9 @@ public class DefaultRepositoriesService
|
|||
try
|
||||
{
|
||||
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
|
||||
|
||||
repository.deleteGroupId( groupId );
|
||||
ArchivaItemSelector itemselector = ArchivaItemSelector.builder( ).withNamespace( groupId ).build();
|
||||
ContentItem item = repository.getItem( itemselector );
|
||||
repository.deleteItem( item );
|
||||
|
||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
|
||||
|
@ -1038,6 +1042,11 @@ public class DefaultRepositoriesService
|
|||
log.error( e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
catch ( ItemNotFoundException e )
|
||||
{
|
||||
log.error( "Item not found {}", e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
|
@ -1083,8 +1092,11 @@ public class DefaultRepositoriesService
|
|||
try
|
||||
{
|
||||
ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
|
||||
ArchivaItemSelector itemSelector = ArchivaItemSelector.builder( ).withNamespace( groupId )
|
||||
.withProjectId( projectId ).build( );
|
||||
ContentItem item = repository.getItem( itemSelector );
|
||||
|
||||
repository.deleteProject( groupId, projectId );
|
||||
repository.deleteItem( item );
|
||||
}
|
||||
catch ( ContentNotFoundException e )
|
||||
{
|
||||
|
@ -1095,6 +1107,11 @@ public class DefaultRepositoriesService
|
|||
log.error( e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
catch ( ItemNotFoundException e )
|
||||
{
|
||||
log.error( "Item not found {}", e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -22,7 +22,9 @@ import org.apache.archiva.maven2.model.Artifact;
|
|||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.maven.model.MavenArtifactFacet;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.storage.StorageAsset;
|
||||
import org.apache.archiva.repository.storage.util.StorageUtil;
|
||||
|
||||
|
@ -79,7 +81,16 @@ public class ArtifactBuilder
|
|||
|
||||
ref.setClassifier( classifier );
|
||||
ref.setType( type );
|
||||
StorageAsset file = managedRepositoryContent.toFile( ref );
|
||||
BaseRepositoryContentLayout layout;
|
||||
try
|
||||
{
|
||||
layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new RuntimeException( "Could not convert to layout " + e.getMessage( ) );
|
||||
}
|
||||
StorageAsset file = layout.toFile( ref );
|
||||
|
||||
String extension = getExtensionFromFile(file);
|
||||
|
||||
|
@ -89,7 +100,7 @@ public class ArtifactBuilder
|
|||
artifact.setPackaging( type );
|
||||
artifact.setType( type );
|
||||
artifact.setFileExtension( extension );
|
||||
artifact.setPath( managedRepositoryContent.toPath( ref ) );
|
||||
artifact.setPath( layout.toPath( ref ) );
|
||||
// TODO: find a reusable formatter for this
|
||||
double s = this.artifactMetadata.getSize();
|
||||
String symbol = "b";
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.archiva.metadata.repository.storage.*;
|
|||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.policies.ProxyDownloadException;
|
||||
import org.apache.archiva.components.taskqueue.TaskQueueException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
|
||||
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
|
||||
|
|
|
@ -58,9 +58,10 @@ import org.apache.archiva.redback.policy.MustChangePasswordException;
|
|||
import org.apache.archiva.redback.system.SecuritySession;
|
||||
import org.apache.archiva.redback.users.User;
|
||||
import org.apache.archiva.redback.users.UserManager;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryGroup;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
|
@ -281,7 +282,7 @@ public class ArchivaDavResourceFactory
|
|||
repositoryRequestInfo = repo.getRequestInfo();
|
||||
String logicalResource = getLogicalResource( archivaLocator, null, false );
|
||||
resourcesInAbsolutePath.add(
|
||||
Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
|
||||
managedRepositoryContent.getRepository().getAsset( "" ).getFilePath().resolve(logicalResource ).toAbsolutePath().toString() );
|
||||
|
||||
}
|
||||
|
||||
|
@ -466,7 +467,7 @@ public class ArchivaDavResourceFactory
|
|||
logicalResource = logicalResource.substring( 1 );
|
||||
}
|
||||
resourcesInAbsolutePath.add(
|
||||
Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
|
||||
managedRepositoryContent.getRepository().getAsset( "" ).resolve( logicalResource ).getFilePath().toAbsolutePath().toString() );
|
||||
}
|
||||
catch ( DavException e )
|
||||
{
|
||||
|
@ -649,12 +650,13 @@ public class ArchivaDavResourceFactory
|
|||
ArtifactReference artifact = null;
|
||||
try
|
||||
{
|
||||
artifact = managedRepositoryContent.toArtifactReference( resourcePath );
|
||||
BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
|
||||
artifact = layout.toArtifactReference( resourcePath );
|
||||
|
||||
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
|
||||
{
|
||||
// check if artifact already exists and if artifact re-deployment to the repository is allowed
|
||||
if ( managedRepositoryContent.hasContent( artifact )
|
||||
if ( layout.hasContent( artifact )
|
||||
&& managedRepositoryContent.getRepository().blocksRedeployments())
|
||||
{
|
||||
log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",
|
||||
|
@ -681,23 +683,23 @@ public class ArchivaDavResourceFactory
|
|||
* create the collections themselves.
|
||||
*/
|
||||
|
||||
Path rootDirectory = Paths.get( managedRepositoryContent.getRepoRoot() );
|
||||
Path destDir = rootDirectory.resolve( logicalResource.getPath() ).getParent();
|
||||
StorageAsset rootDirectory = managedRepositoryContent.getRepository( ).getAsset( "" );
|
||||
StorageAsset destDir = rootDirectory.resolve( logicalResource.getPath() ).getParent();
|
||||
|
||||
if ( !Files.exists(destDir) )
|
||||
if ( !destDir.exists() )
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.createDirectories( destDir );
|
||||
destDir.create();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
log.error("Could not create directory {}: {}", destDir, e.getMessage(), e);
|
||||
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not create directory "+destDir );
|
||||
}
|
||||
String relPath = PathUtil.getRelative( rootDirectory.toAbsolutePath().toString(), destDir );
|
||||
String relPath = PathUtil.getRelative( rootDirectory.getPath(), destDir.getPath() );
|
||||
|
||||
log.debug( "Creating destination directory '{}' (current user '{}')", destDir.getFileName(),
|
||||
log.debug( "Creating destination directory '{}' (current user '{}')", destDir.getName(),
|
||||
activePrincipal );
|
||||
|
||||
triggerAuditEvent( request.getRemoteAddr(), managedRepositoryContent.getId(), relPath,
|
||||
|
@ -798,7 +800,7 @@ public class ArchivaDavResourceFactory
|
|||
|
||||
StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact );
|
||||
|
||||
resource.setPath( managedRepository.getContent().toPath( artifact ) );
|
||||
resource.setPath( managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( artifact ) );
|
||||
|
||||
log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion() );
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.archiva.configuration.RepositoryGroupConfiguration;
|
|||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.apache.archiva.proxy.ProxyRegistry;
|
||||
import org.apache.archiva.repository.EditableManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.BaseRepositoryContentLayout;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.Repository;
|
||||
|
@ -250,11 +250,11 @@ public class ArchivaDavResourceFactoryTest
|
|||
return repoConfig;
|
||||
}
|
||||
|
||||
private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
|
||||
private BaseRepositoryContentLayout createManagedRepositoryContent( String repoId )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
|
||||
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
|
||||
BaseRepositoryContentLayout repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
|
||||
if (repo!=null && repo instanceof EditableManagedRepository)
|
||||
{
|
||||
( (EditableManagedRepository) repo ).setContent( repoContent );
|
||||
|
@ -262,7 +262,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
return repoContent;
|
||||
}
|
||||
|
||||
private RepositoryContentProvider createRepositoryContentProvider(ManagedRepositoryContent content) {
|
||||
private RepositoryContentProvider createRepositoryContentProvider( BaseRepositoryContentLayout content) {
|
||||
Set<RepositoryType> TYPES = new HashSet<>( );
|
||||
TYPES.add(RepositoryType.MAVEN);
|
||||
return new RepositoryContentProvider( )
|
||||
|
@ -294,7 +294,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryContent createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
|
||||
public BaseRepositoryContentLayout createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
|
||||
{
|
||||
content.setRepository( repository );
|
||||
return content;
|
||||
|
@ -330,8 +330,8 @@ public class ArchivaDavResourceFactoryTest
|
|||
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
|
||||
new ArchivaDavLocatorFactory() );
|
||||
|
||||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
|
||||
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -407,9 +407,9 @@ public class ArchivaDavResourceFactoryTest
|
|||
|
||||
config.setRepositoryGroups( repoGroups );
|
||||
|
||||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
|
||||
ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
|
||||
BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -490,8 +490,8 @@ public class ArchivaDavResourceFactoryTest
|
|||
|
||||
config.setRepositoryGroups( repoGroups );
|
||||
|
||||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
|
||||
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
BaseRepositoryContentLayout localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
|
||||
|
||||
repositoryRegistry.putRepositoryGroup( repoGroup );
|
||||
|
||||
|
@ -565,7 +565,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
|
||||
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
|
||||
|
||||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
|
||||
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
|
||||
MavenRepositoryRequestInfo repoRequest = new MavenRepositoryRequestInfo(internalRepo.getRepository() );
|
||||
|
@ -622,7 +622,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
|
||||
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
|
||||
|
||||
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -662,7 +662,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
public void testRequestMetadataRepoIsLegacy()
|
||||
throws Exception
|
||||
{
|
||||
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
|
||||
BaseRepositoryContentLayout legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
|
||||
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
|
||||
RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo );
|
||||
beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
|||
import org.apache.archiva.filter.Filter;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.policies.ProxyDownloadException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.xml.XMLException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataN
|
|||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.policies.ProxyDownloadException;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.metadata.audit.RepositoryListener;
|
||||
import org.apache.archiva.xml.XMLException;
|
||||
|
||||
|
|
Loading…
Reference in New Issue