Removing method from repository layout

This commit is contained in:
Martin Stockhammer 2020-06-03 16:03:29 +02:00
parent d8f55d0c99
commit cb0e5f8eea
7 changed files with 9 additions and 52 deletions

View File

@ -270,17 +270,4 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay
/// ***************** End of new generation interface ********************** /// ***************** End of new generation interface **********************
/**
* <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();
} }

View File

@ -937,23 +937,24 @@ public class MetadataTools
path = path.substring( 0, idx ); path = path.substring( 0, idx );
} }
Path repoDir = Paths.get( managedRepository.getRepoRoot(), path ); StorageAsset repoDir = managedRepository.getGenericContent( ).getRepository( ).getAsset( "" );
if ( !Files.exists(repoDir)) if ( !repoDir.exists())
{ {
throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: " throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: "
+ repoDir.toAbsolutePath() ); + repoDir.toString() );
} }
if ( !Files.isDirectory( repoDir )) if ( !repoDir.isContainer())
{ {
throw new IOException( throw new IOException(
"Unable to gather the list of snapshot versions on a non-directory: " + repoDir.toAbsolutePath() ); "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.toString() );
} }
try(Stream<Path> stream = Files.list(repoDir)) { Path repoRoot = repoDir.getFilePath( );
try(Stream<Path> stream = Files.list(repoRoot)) {
String result = stream.filter( Files::isRegularFile ).map( path1 -> String result = stream.filter( Files::isRegularFile ).map( path1 ->
PathUtil.getRelative( managedRepository.getRepoRoot(), path1 ) repoRoot.relativize( path1 ).toString()
).filter( filetypes::matchesArtifactPattern ).findFirst().orElse( null ); ).filter( filetypes::matchesArtifactPattern ).findFirst().orElse( null );
if (result!=null) { if (result!=null) {
return managedRepository.getGenericContent().toArtifactReference( result ); return managedRepository.getGenericContent().toArtifactReference( result );

View File

@ -303,12 +303,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
return null; return null;
} }
@Override
public String getRepoRoot( )
{
return null;
}
@Override @Override
public ManagedRepository getRepository( ) public ManagedRepository getRepository( )
{ {

View File

@ -305,12 +305,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
return repository.getId(); return repository.getId();
} }
@Override
public String getRepoRoot( )
{
return getRepoRootAsset().getFilePath().toString();
}
private StorageAsset getRepoRootAsset() { private StorageAsset getRepoRootAsset() {
if (fsStorage==null) { if (fsStorage==null) {
try { try {

View File

@ -326,12 +326,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
return repository.getId(); return repository.getId();
} }
@Override
public String getRepoRoot( )
{
return getRepoRootAsset().getFilePath().toString();
}
private StorageAsset getRepoRootAsset() { private StorageAsset getRepoRootAsset() {
if (fsStorage==null) { if (fsStorage==null) {
try { try {

View File

@ -1374,12 +1374,6 @@ public class ManagedDefaultRepositoryContent
} }
@Override
public String getRepoRoot( )
{
return convertUriToPath( repository.getLocation( ) );
}
private String convertUriToPath( URI uri ) private String convertUriToPath( URI uri )
{ {
if ( uri.getScheme( ) == null ) if ( uri.getScheme( ) == null )

View File

@ -159,14 +159,7 @@ public class Maven3DependencyTreeBuilder
// FIXME take care of relative path // FIXME take care of relative path
ResolveRequest resolveRequest = new ResolveRequest(); ResolveRequest resolveRequest = new ResolveRequest();
resolveRequest.dependencyVisitor = dependencyVisitor; resolveRequest.dependencyVisitor = dependencyVisitor;
try resolveRequest.localRepoDir = repository.getAsset( "" ).getFilePath().toAbsolutePath().toString();
{
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.groupId = groupId;
resolveRequest.artifactId = artifactId; resolveRequest.artifactId = artifactId;
resolveRequest.version = version; resolveRequest.version = version;