Separating content and layout interfaces

This commit is contained in:
Martin Stockhammer 2020-06-02 13:37:35 +02:00
parent 2257aae023
commit da89fe394c
28 changed files with 96 additions and 103 deletions

View File

@ -126,7 +126,7 @@ public class SimpleArtifactConsumer
{
ManagedRepositoryContent repositoryContent = repository.getContent();
BaseRepositoryContentLayout layout = repositoryContent.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = repositoryContent.toArtifactReference( path );
repositorySession.getRepository().getArtifacts( repositorySession, repository.getId(), artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion() );

View File

@ -174,7 +174,7 @@ public class MetadataUpdaterConsumer
{
try
{
ArtifactReference artifact = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
ArtifactReference artifact = repository.toArtifactReference( path );
updateVersionMetadata( artifact, path );
updateProjectMetadata( artifact, path );
}

View File

@ -100,7 +100,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
return;
}
ArtifactReference artifactRef = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path );
ArtifactReference artifactRef = repository.toArtifactReference( path );
if ( !VersionUtil.isSnapshot( artifactRef.getVersion( ) ) )
{

View File

@ -43,7 +43,7 @@ import java.util.stream.Stream;
*
*
*/
public interface BaseRepositoryContentLayout extends RepositoryContent, ManagedRepositoryContent, ManagedRepositoryContentLayout
public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLayout
{
/// ***************** New generation interface **********************

View File

@ -55,14 +55,7 @@ public class ArtifactUtil
{
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
final String artifactPath;
try
{
artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
}
catch ( LayoutException e )
{
throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
}
artifactPath = content.toPath( artifactReference );
return Paths.get( repository.getLocation( ) ).resolve( artifactPath );
}
@ -79,14 +72,7 @@ public class ArtifactUtil
{
final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository );
final String artifactPath;
try
{
artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference );
}
catch ( LayoutException e )
{
throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" );
}
artifactPath = content.toPath( artifactReference );
return repository.getAsset( artifactPath );
}

View File

@ -956,7 +956,7 @@ public class MetadataTools
PathUtil.getRelative( managedRepository.getRepoRoot(), path1 )
).filter( filetypes::matchesArtifactPattern ).findFirst().orElse( null );
if (result!=null) {
return managedRepository.toArtifactReference( result );
return managedRepository.getGenericContent().toArtifactReference( result );
}
}
// No artifact was found.

View File

@ -57,7 +57,7 @@ import java.util.stream.Stream;
* @author Martin Stockhammer <martin_s@apache.org>
*/
@Service("managedRepositoryContent#mock")
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent
{
private ManagedRepository repository;

View File

@ -21,6 +21,7 @@ package org.apache.archiva.repository.mock;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.Repository;
@ -63,7 +64,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider
}
@Override
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
public ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException {
return new ManagedRepositoryContentMock();
}

View File

@ -57,7 +57,7 @@ import java.util.stream.Stream;
/**
* @author Martin Stockhammer <martin_s@apache.org>
*/
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent
{
private static final String PATH_SEPARATOR = "/";
private static final String GROUP_SEPARATOR = ".";

View File

@ -64,7 +64,7 @@ public class CacheFailuresTransferTest
assertNotExistsInManagedDefaultRepo( expectedFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Repository (usually done within archiva.xml configuration)
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
@ -109,7 +109,7 @@ public class CacheFailuresTransferTest
assertNotExistsInManagedDefaultRepo( expectedFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Repository (usually done within archiva.xml configuration)
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" );
@ -155,7 +155,7 @@ public class CacheFailuresTransferTest
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Files.deleteIfExists( expectedFile );
assertFalse( Files.exists( expectedFile ) );

View File

@ -56,7 +56,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -79,7 +79,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -106,7 +106,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -133,7 +133,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -159,7 +159,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -185,7 +185,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -211,7 +211,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -235,7 +235,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -262,7 +262,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -286,7 +286,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -313,7 +313,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -337,7 +337,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -364,7 +364,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -392,7 +392,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -419,7 +419,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -446,7 +446,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile.getParent( ) ) );
@ -501,7 +501,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
@ -529,7 +529,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
@ -558,7 +558,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,

View File

@ -599,7 +599,7 @@ public class ErrorHandlingTest
{
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
layout.toArtifactReference( path ) );
managedDefaultRepository.toArtifactReference( path ) );
fail( "Proxy should not have succeeded" );
}
catch ( ProxyDownloadException e )
@ -642,7 +642,7 @@ public class ErrorHandlingTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
layout.toArtifactReference( path ) );
managedDefaultRepository.toArtifactReference( path ) );
wagonMockControl.verify();
return downloadedFile;

View File

@ -222,7 +222,7 @@ public class HttpProxyTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
Path expectedFile = managedDefaultRepository.getRepository().getAsset( "" ).resolve( path ).getFilePath();
Files.deleteIfExists( expectedFile );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Attempt the proxy fetch.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );

View File

@ -59,7 +59,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -84,7 +84,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -147,7 +147,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
@ -230,7 +230,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
@ -277,7 +277,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
@ -311,7 +311,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS ));
@ -339,7 +339,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -373,7 +373,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -400,7 +400,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -427,7 +427,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -464,7 +464,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertNotExistsInManagedDefaultRepo( expectedFile );

View File

@ -54,7 +54,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -77,7 +77,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -102,7 +102,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from( getPastDate().getTime(), TimeUnit.MILLISECONDS ));
@ -131,7 +131,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
@ -220,7 +220,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );
@ -251,7 +251,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false);
@ -274,7 +274,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -303,7 +303,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -332,7 +332,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = layout.toArtifactReference( path );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( Files.exists(expectedFile) );

View File

@ -55,7 +55,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider
}
@Override
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException {
public ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException {
return new ManagedRepositoryContentMock(repository);
}

View File

@ -84,7 +84,7 @@ import java.util.stream.Stream;
*/
public class ManagedDefaultRepositoryContent
extends AbstractDefaultRepositoryContent
implements BaseRepositoryContentLayout
implements ManagedRepositoryContent, BaseRepositoryContentLayout
{
// attribute flag that marks version objects that point to a snapshot artifact version

View File

@ -20,6 +20,7 @@ package org.apache.archiva.repository.maven.content;
import org.apache.archiva.common.filelock.FileLockManager;
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.repository.ManagedRepository;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
@ -98,7 +99,7 @@ public class MavenContentProvider implements RepositoryContentProvider
}
@Override
public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository ) throws RepositoryException
public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException
{
if (!supports( repository.getType() )) {
throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." );

View File

@ -280,7 +280,7 @@ public class MavenRepositoryRequestInfo implements RepositoryRequestInfo
// Treat as an artifact reference.
ArtifactReference ref = toArtifactReference( referencedResource );
String adjustedPath = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( ref );
String adjustedPath = repository.getContent().toPath( ref );
return adjustedPath + supportfile;
}

View File

@ -18,6 +18,7 @@ package org.apache.archiva.repository.maven.content;
* under the License.
*/
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
@ -50,10 +51,11 @@ public abstract class AbstractBaseRepositoryContentLayoutTest extends AbstractRe
}
@Test
public void testGetArtifactOnEmptyPath() {
public void testGetArtifactOnEmptyPath() throws LayoutException
{
ItemSelector selector = ArchivaItemSelector.builder( ).build( );
try {
getManaged( ).getArtifact( selector );
getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getArtifact( selector );
fail( "getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException" );
} catch (IllegalArgumentException e) {
// Good

View File

@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven.content;
*/
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
import org.apache.archiva.repository.LayoutException;
@ -581,25 +582,25 @@ public abstract class AbstractRepositoryContentTest
Version ver = null;
if ( StringUtils.isNotEmpty( groupId ) )
{
ns = getManaged( ).getNamespace( expectedArtifact );
ns = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getNamespace( expectedArtifact );
assertNotNull( ns );
assertEquals( groupId, ns.getNamespace( ) );
}
if ( StringUtils.isNotEmpty( artifactId ) )
{
pr = getManaged( ).getProject( expectedArtifact );
pr = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getProject( expectedArtifact );
assertNotNull( pr );
assertEquals( artifactId, pr.getId( ) );
assertEquals( ns, pr.getNamespace( ) );
}
if ( StringUtils.isNotEmpty( version ) )
{
ver = getManaged( ).getVersion( expectedArtifact );
ver = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getVersion( expectedArtifact );
assertNotNull( ver );
assertEquals( version, ver.getVersion( ) );
assertEquals( pr, ver.getProject( ) );
}
Artifact artifact = getManaged( ).getArtifact( expectedArtifact );
Artifact artifact = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getArtifact( expectedArtifact );
assertNotNull( artifact );
assertEquals( artifactId, artifact.getId( ) );
assertEquals( ver, artifact.getVersion( ) );
@ -642,7 +643,7 @@ public abstract class AbstractRepositoryContentTest
protected abstract ItemSelector toItemSelector(String path) throws LayoutException;
protected abstract BaseRepositoryContentLayout getManaged();
protected abstract ManagedRepositoryContent getManaged();
protected abstract RepositoryContent getContent( );
}

View File

@ -410,7 +410,7 @@ public class ManagedDefaultRepositoryContentTest
}
@Override
protected BaseRepositoryContentLayout getManaged( )
protected ManagedRepositoryContent getManaged( )
{
return repoContent;
}

View File

@ -21,6 +21,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.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RemoteRepositoryContent;
import org.apache.archiva.repository.RepositoryContent;
@ -69,7 +70,7 @@ public class RemoteDefaultRepositoryContentTest
}
@Override
protected BaseRepositoryContentLayout getManaged( )
protected ManagedRepositoryContent getManaged( )
{
return null;
}

View File

@ -98,7 +98,7 @@ public class TestConsumer
{
try
{
consumed.add( repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ) );
consumed.add( repository.toArtifactReference( path ) );
}
catch ( LayoutException e )
{

View File

@ -375,7 +375,7 @@ public class DefaultRepositoriesService
ManagedRepositoryContent sourceRepository =
getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
BaseRepositoryContentLayout layout = sourceRepository.getLayout( BaseRepositoryContentLayout.class );
String artifactSourcePath = layout.toPath( artifactReference );
String artifactSourcePath = sourceRepository.toPath( artifactReference );
if ( StringUtils.isEmpty( artifactSourcePath ) )
{
@ -396,7 +396,7 @@ public class DefaultRepositoriesService
ManagedRepositoryContent targetRepository =
getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
String artifactPath = layout.toPath( artifactReference );
String artifactPath = sourceRepository.toPath( artifactReference );
int lastIndex = artifactPath.lastIndexOf( '/' );
@ -777,7 +777,7 @@ public class DefaultRepositoriesService
.withVersion( artifact.getVersion( ) ).build( );
Version version1 = layout.getVersion( versionSelector );
String path = layout.toPath( version1 );
String path = repository.toPath( version1 );
ArtifactReference artifactReference = new ArtifactReference();
artifactReference.setArtifactId( artifact.getArtifactId() );
@ -839,7 +839,7 @@ public class DefaultRepositoriesService
{
try
{
layout.deleteItem( version1 );
repository.deleteItem( version1 );
}
catch ( ItemNotFoundException e )
{

View File

@ -100,7 +100,7 @@ public class ArtifactBuilder
artifact.setPackaging( type );
artifact.setType( type );
artifact.setFileExtension( extension );
artifact.setPath( layout.toPath( ref ) );
artifact.setPath( managedRepositoryContent.toPath( ref ) );
// TODO: find a reusable formatter for this
double s = this.artifactMetadata.getSize();
String symbol = "b";

View File

@ -651,7 +651,7 @@ public class ArchivaDavResourceFactory
try
{
BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class );
artifact = layout.toArtifactReference( resourcePath );
artifact = managedRepositoryContent.toArtifactReference( resourcePath );
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
{
@ -800,7 +800,7 @@ public class ArchivaDavResourceFactory
StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact );
resource.setPath( managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( artifact ) );
resource.setPath( managedRepository.getContent().toPath( artifact ) );
log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion() );

View File

@ -34,6 +34,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.repository.EditableManagedRepository;
@ -250,11 +251,11 @@ public class ArchivaDavResourceFactoryTest
return repoConfig;
}
private BaseRepositoryContentLayout createManagedRepositoryContent( String repoId )
private ManagedRepositoryContent createManagedRepositoryContent( String repoId )
throws RepositoryAdminException
{
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
BaseRepositoryContentLayout repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager);
if (repo!=null && repo instanceof EditableManagedRepository)
{
( (EditableManagedRepository) repo ).setContent( repoContent );
@ -262,7 +263,7 @@ public class ArchivaDavResourceFactoryTest
return repoContent;
}
private RepositoryContentProvider createRepositoryContentProvider( BaseRepositoryContentLayout content) {
private RepositoryContentProvider createRepositoryContentProvider( ManagedRepositoryContent content) {
Set<RepositoryType> TYPES = new HashSet<>( );
TYPES.add(RepositoryType.MAVEN);
return new RepositoryContentProvider( )
@ -294,7 +295,7 @@ public class ArchivaDavResourceFactoryTest
}
@Override
public BaseRepositoryContentLayout createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
public ManagedRepositoryContent createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException
{
content.setRepository( repository );
return content;
@ -330,8 +331,8 @@ public class ArchivaDavResourceFactoryTest
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
new ArchivaDavLocatorFactory() );
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
try
{
@ -407,9 +408,9 @@ public class ArchivaDavResourceFactoryTest
config.setRepositoryGroups( repoGroups );
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO );
try
{
@ -490,8 +491,8 @@ public class ArchivaDavResourceFactoryTest
config.setRepositoryGroups( repoGroups );
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
BaseRepositoryContentLayout localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO );
repositoryRegistry.putRepositoryGroup( repoGroup );
@ -565,7 +566,7 @@ public class ArchivaDavResourceFactoryTest
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml",
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
MavenRepositoryRequestInfo repoRequest = new MavenRepositoryRequestInfo(internalRepo.getRepository() );
@ -622,7 +623,7 @@ public class ArchivaDavResourceFactoryTest
new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml",
INTERNAL_REPO, new ArchivaDavLocatorFactory() );
BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
try
{
@ -662,7 +663,7 @@ public class ArchivaDavResourceFactoryTest
public void testRequestMetadataRepoIsLegacy()
throws Exception
{
BaseRepositoryContentLayout legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo );
beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);