Moving references to repositoryRegistry

This commit is contained in:
Martin Stockhammer 2018-04-08 00:32:46 +02:00
parent 2ef9315447
commit d3564941d5
3 changed files with 11 additions and 49 deletions

View File

@ -20,6 +20,7 @@ package org.apache.archiva.rest.api.model;
import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.ManagedRepository;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;

View File

@ -23,7 +23,6 @@ import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.indexer.search.SearchResultHit; import org.apache.archiva.indexer.search.SearchResultHit;
@ -39,7 +38,6 @@ import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.User;
import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.repository.events.AuditListener;
@ -106,9 +104,6 @@ public abstract class AbstractRestService
@Inject @Inject
protected RepositoryRegistry repositoryRegistry; protected RepositoryRegistry repositoryRegistry;
@Inject
protected RepositoryContentFactory repositoryContentFactory;
@Inject @Inject
@Named(value = "archivaTaskScheduler#repository") @Named(value = "archivaTaskScheduler#repository")
protected RepositoryArchivaTaskScheduler repositoryTaskScheduler; protected RepositoryArchivaTaskScheduler repositoryTaskScheduler;

View File

@ -21,8 +21,6 @@ package org.apache.archiva.rest.services;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile; import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.common.utils.VersionComparator;
@ -51,6 +49,7 @@ import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManagerException; import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException; import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException; import org.apache.archiva.repository.RepositoryNotFoundException;
@ -122,10 +121,6 @@ public class DefaultRepositoriesService
@Inject @Inject
private RepositoryRegistry repositoryRegistry; private RepositoryRegistry repositoryRegistry;
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
@Inject @Inject
private SecuritySystem securitySystem; private SecuritySystem securitySystem;
@ -273,14 +268,7 @@ public class DefaultRepositoriesService
} }
ManagedRepository source = null; ManagedRepository source = null;
try source = repositoryRegistry.getManagedRepository( artifactTransferRequest.getRepositoryId() );
{
source = managedRepositoryAdmin.getManagedRepository( artifactTransferRequest.getRepositoryId() );
}
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( e.getMessage(), e );
}
if ( source == null ) if ( source == null )
{ {
@ -289,14 +277,7 @@ public class DefaultRepositoriesService
} }
ManagedRepository target = null; ManagedRepository target = null;
try target = repositoryRegistry.getManagedRepository( artifactTransferRequest.getTargetRepositoryId() );
{
target = managedRepositoryAdmin.getManagedRepository( artifactTransferRequest.getTargetRepositoryId() );
}
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( e.getMessage(), e );
}
if ( target == null ) if ( target == null )
{ {
@ -403,7 +384,7 @@ public class DefaultRepositoriesService
null ); null );
} }
Path artifactFile = Paths.get( source.getLocation(), artifactSourcePath ); Path artifactFile = source.getLocalPath().resolve( artifactSourcePath );
if ( !Files.exists(artifactFile) ) if ( !Files.exists(artifactFile) )
{ {
@ -420,7 +401,7 @@ public class DefaultRepositoriesService
int lastIndex = artifactPath.lastIndexOf( '/' ); int lastIndex = artifactPath.lastIndexOf( '/' );
String path = artifactPath.substring( 0, lastIndex ); String path = artifactPath.substring( 0, lastIndex );
Path targetPath = Paths.get( target.getLocation(), path ); Path targetPath = target.getLocalPath().resolve( path );
Date lastUpdatedTimestamp = Calendar.getInstance().getTime(); Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
int newBuildNumber = 1; int newBuildNumber = 1;
@ -440,7 +421,7 @@ public class DefaultRepositoriesService
!( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) ); !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );
Path targetFile = targetPath.resolve( filename ); Path targetFile = targetPath.resolve( filename );
if ( Files.exists(targetFile) && target.isBlockRedeployments() ) if ( Files.exists(targetFile) && target.blocksRedeployments())
{ {
throw new ArchivaRestServiceException( throw new ArchivaRestServiceException(
"artifact already exists in target repo: " + artifactTransferRequest.getTargetRepositoryId() "artifact already exists in target repo: " + artifactTransferRequest.getTargetRepositoryId()
@ -461,9 +442,8 @@ public class DefaultRepositoriesService
} }
pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom"; pomFilename = FilenameUtils.removeExtension( pomFilename ) + ".pom";
Path pomFile = Paths.get(source.getLocation(), Path pomFile = source.getLocalPath().resolve(
artifactSourcePath.substring( 0, artifactPath.lastIndexOf( '/' ) ) , artifactSourcePath.substring( 0, artifactPath.lastIndexOf( '/' ) )).resolve( pomFilename );
pomFilename );
if ( pomFile != null && Files.size( pomFile ) > 0 ) if ( pomFile != null && Files.size( pomFile ) > 0 )
{ {
@ -785,7 +765,7 @@ public class DefaultRepositoriesService
TimeZone timezone = TimeZone.getTimeZone( "UTC" ); TimeZone timezone = TimeZone.getTimeZone( "UTC" );
DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" ); DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
fmt.setTimeZone( timezone ); fmt.setTimeZone( timezone );
ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId ); ManagedRepository repoConfig = repositoryRegistry.getManagedRepository( repositoryId );
VersionedReference ref = new VersionedReference(); VersionedReference ref = new VersionedReference();
ref.setArtifactId( artifact.getArtifactId() ); ref.setArtifactId( artifact.getArtifactId() );
@ -821,7 +801,7 @@ public class DefaultRepositoriesService
int index = path.lastIndexOf( '/' ); int index = path.lastIndexOf( '/' );
path = path.substring( 0, index ); path = path.substring( 0, index );
Path targetPath = Paths.get( repoConfig.getLocation(), path ); Path targetPath = repoConfig.getLocalPath().resolve( path );
if ( !Files.exists(targetPath) ) if ( !Files.exists(targetPath) )
{ {
@ -965,10 +945,6 @@ public class DefaultRepositoriesService
{ {
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e ); throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
} }
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( "RepositoryAdmin exception: " + e.getMessage(), 500, e );
}
finally finally
{ {
@ -1201,16 +1177,6 @@ public class DefaultRepositoriesService
return new StringList( downloadRemoteIndexScheduler.getRunningRemoteDownloadIds() ); return new StringList( downloadRemoteIndexScheduler.getRunningRemoteDownloadIds() );
} }
public ManagedRepositoryAdmin getManagedRepositoryAdmin()
{
return managedRepositoryAdmin;
}
public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
{
this.managedRepositoryAdmin = managedRepositoryAdmin;
}
public RepositorySessionFactory getRepositorySessionFactory() public RepositorySessionFactory getRepositorySessionFactory()
{ {
return repositorySessionFactory; return repositorySessionFactory;