* under the License.
*/
+
+
import org.apache.archiva.admin.model.beans.ManagedRepository;
import javax.xml.bind.annotation.XmlRootElement;
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
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.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.events.AuditListener;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.services.utils.ArtifactBuilder;
@Inject
protected ManagedRepositoryAdmin managedRepositoryAdmin;
+ @Inject
+ protected RepositoryRegistry repositoryRegistry;
+
@Inject
protected RepositoryContentFactory repositoryContentFactory;
if ( repoId == null ) {
throw new IllegalStateException( "Repository Id is null" );
}
-
+ ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
+ if (repo==null) {
+ throw new RepositoryException( "Repository not found "+repoId );
+ }
+ ManagedRepositoryContent content = repo.getContent( );
ArtifactBuilder builder =
new ArtifactBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent(
- repositoryContentFactory.getManagedRepositoryContent( repoId ) );
+ content );
Artifact art = builder.build();
art.setUrl( getArtifactUrl( art, repositoryId ) );
artifacts.add( art );
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.rest.api.model.*;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
@Inject
private DependencyTreeBuilder dependencyTreeBuilder;
- @Inject
- private RepositoryContentFactory repositoryContentFactory;
-
@Inject
@Named( value = "repositoryProxyConnectors#default" )
private RepositoryProxyConnectors connectors;
@Named( value = "browse#versionMetadata" )
private Cache<String, ProjectVersionMetadata> versionMetadataCache;
+ private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
+ {
+ org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
+ if (repo==null) {
+ throw new RepositoryException( "Could not find repository "+id );
+ }
+ return repo.getContent();
+ }
+
@Override
public BrowseResult getRootGroups( String repositoryId )
throws ArchivaRestServiceException
{
ManagedRepositoryContent managedRepositoryContent =
- repositoryContentFactory.getManagedRepositoryContent( repoId );
+ getManagedRepositoryContent( repoId );
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
StringUtils.isEmpty( type ) ? "jar" : type,
repoId );
for ( String repoId : selectedRepos )
{
- ManagedRepositoryContent managedRepositoryContent =
- repositoryContentFactory.getManagedRepositoryContent( repoId );
+ ManagedRepositoryContent managedRepositoryContent = null;
+ try
+ {
+ managedRepositoryContent = getManagedRepositoryContent( repoId );
+ }
+ catch ( RepositoryException e )
+ {
+ log.error("No repository content found for "+repoId);
+ continue;
+ }
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
StringUtils.isEmpty( type ) ? "jar" : type,
repoId );
throw new ArchivaRestServiceException( e.getMessage(),
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
}
- catch ( RepositoryNotFoundException e )
- {
- log.error( e.getMessage(), e );
- throw new ArchivaRestServiceException( e.getMessage(),
- Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
- }
- catch ( RepositoryException e )
- {
- log.error( e.getMessage(), e );
- throw new ArchivaRestServiceException( e.getMessage(),
- Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
- }
log.debug( "artifact: {}:{}:{}:{}:{} not found", groupId, artifactId, version, classifier, type );
// 404 ?
return new ArtifactContent();
{
continue;
}
- ManagedRepositoryContent managedRepositoryContent =
- repositoryContentFactory.getManagedRepositoryContent( repoId );
+ 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 )
import org.apache.archiva.redback.users.UserManagerException;
import org.apache.archiva.redback.users.UserNotFoundException;
import org.apache.archiva.repository.*;
+import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
@Named(value = "taskExecutor#indexing")
private ArchivaIndexingTaskExecutor archivaIndexingTaskExecutor;
+ @Inject
+ private RepositoryRegistry repositoryRegistry;
+
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
@Inject
private SecuritySystem securitySystem;
- @Inject
- private RepositoryContentFactory repositoryFactory;
-
@Inject
@Named(value = "archivaTaskScheduler#repository")
private ArchivaTaskScheduler scheduler;
}
}
+ private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException
+ {
+ org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id );
+ if (repo==null) {
+ throw new RepositoryException( "Repository not found "+id );
+ }
+ return repo.getContent();
+ }
+
@Override
public Boolean scanRepositoryNow( String repositoryId, boolean fullScan )
throws ArchivaRestServiceException
try
{
- ManagedRepository repository = managedRepositoryAdmin.getManagedRepository( repositoryId );
+
+ org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository( repositoryId );
IndexingContext context = managedRepositoryAdmin.createIndexContext( repository );
{
ManagedRepositoryContent sourceRepository =
- repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
+ getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() );
String artifactSourcePath = sourceRepository.toPath( artifactReference );
}
ManagedRepositoryContent targetRepository =
- repositoryFactory.getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
+ getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() );
String artifactPath = targetRepository.toPath( artifactReference );
try
{
- ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
VersionedReference ref = new VersionedReference();
ref.setArtifactId( projectId );
ref.setGroupId( artifact.getGroupId() );
ref.setVersion( artifact.getVersion() );
- ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
ArtifactReference artifactReference = new ArtifactReference();
artifactReference.setArtifactId( artifact.getArtifactId() );
try
{
- ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
repository.deleteGroupId( groupId );
try
{
- ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId );
repository.deleteProject( groupId, projectId );
}
long sinceWhen = RepositoryScanner.FRESH_SCAN;
try
{
- return repoScanner.scan( getManagedRepositoryAdmin().getManagedRepository( repositoryId ), sinceWhen );
+ return repoScanner.scan( repositoryRegistry.getManagedRepository( repositoryId ), sinceWhen );
}
catch ( RepositoryScannerException e )
{
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( "RepositoryScannerException exception: " + e.getMessage(), 500, e );
}
- catch ( RepositoryAdminException e )
- {
- log.error( e.getMessage(), e );
- throw new ArchivaRestServiceException( "RepositoryScannerException exception: " + e.getMessage(), 500, e );
- }
}
/**
this.managedRepositoryAdmin = managedRepositoryAdmin;
}
- public RepositoryContentFactory getRepositoryFactory()
- {
- return repositoryFactory;
- }
-
- public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
- {
- this.repositoryFactory = repositoryFactory;
- }
-
public RepositorySessionFactory getRepositorySessionFactory()
{
return repositorySessionFactory;
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.redback.components.cache.CacheStatistics;
import org.apache.archiva.redback.components.taskqueue.TaskQueue;
private RepositoryScanner scanner;
+ ManagedRepositoryAdmin managedRepositoryAdmin;
+
// display spring scheduled
//@Inject @Named (value="springScheduler");
queues = getBeansOfType( applicationContext, TaskQueue.class );
caches = getBeansOfType( applicationContext, Cache.class );
+
+ managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
}
@Override
List<RepositoryScannerStatistics> repositoryScannerStatisticsList =
new ArrayList<RepositoryScannerStatistics>( repositoryScannerInstances.size() );
+
for ( RepositoryScannerInstance instance : repositoryScannerInstances )
{
RepositoryScannerStatistics repositoryScannerStatistics = new RepositoryScannerStatistics();
repositoryScannerStatisticsList.add( repositoryScannerStatistics );
- repositoryScannerStatistics.setManagedRepository( instance.getRepository() );
+ try
+ {
+ repositoryScannerStatistics.setManagedRepository( managedRepositoryAdmin.getManagedRepository( instance.getRepository().getId()) );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error("Could not retrieve repository '{}'", instance.getRepository().getId());
+ }
repositoryScannerStatistics.setNewFileCount( instance.getStats().getNewFileCount() );
repositoryScannerStatistics.setTotalFileCount( instance.getStats().getTotalFileCount() );
repositoryScannerStatistics.setConsumerScanningStatistics( mapConsumerScanningStatistics( instance ) );
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Date;
+import java.util.Locale;
/**
* @author Olivier Lamy
protected ManagedRepository getTestManagedRepository()
{
String location = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repo" ).toAbsolutePath().toString();
- return new ManagedRepository( "TEST", "test", location, "default", true, true, false, "2 * * * * ?", null,
+ return new ManagedRepository( Locale.getDefault(), "TEST", "test", location, "default", true, true, false, "2 * * * * ?", null,
false, 2, 3, true, false, "my nice repo", false );
}
getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( testRepoId, false );
}
- ManagedRepository managedRepository = new ManagedRepository();
+ ManagedRepository managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId( testRepoId );
managedRepository.setName( "test repo" );
import javax.ws.rs.ForbiddenException;
import java.util.List;
+import java.util.Locale;
/**
* @author Olivier Lamy
RemoteRepository getRemoteRepository()
{
- return new RemoteRepository( "id-new", "new one", "http://foo.com", "default", "foo", "foopassword", 120,
+ return new RemoteRepository( Locale.getDefault( ), "id-new", "new one", "http://foo.com", "default", "foo", "foopassword", 120,
"cool repo" );
}
RemoteRepository getRemoteMavenRepository()
{
- return new RemoteRepository( "id-maven1", "Maven1", "http://repo.maven.apache.org/maven2", "default", "foo", "foopassword", 120,
+ return new RemoteRepository( Locale.getDefault( ),"id-maven1", "Maven1", "http://repo.maven.apache.org/maven2", "default", "foo", "foopassword", 120,
"cool repo3" );
}
RemoteRepository getRemoteOracleRepository()
{
- return new RemoteRepository( "id-oracle", "Oracle", "http://download.oracle.com/maven", "default", "foo", "foopassword", 120,
+ return new RemoteRepository( Locale.getDefault( ),"id-oracle", "Oracle", "http://download.oracle.com/maven", "default", "foo", "foopassword", 120,
"cool repo4" );
}
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
protected ManagedRepository getTestManagedRepository( String id, String path )
{
String location = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/" + path ).toAbsolutePath().toString();
- return new ManagedRepository( id, id, location, "default", true, true, true, "2 * * * * ?", null, false, 80, 80,
+ return new ManagedRepository( Locale.getDefault(), id, id, location, "default", true, true, true, "2 * * * * ?", null, false, 80, 80,
true, false );
}
<context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils"/>
+ base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils,org.apache.archiva.repository.content.maven2"/>
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.users.UserManagerException;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
@Named(value = "archivaConfiguration#default")
private ArchivaConfiguration archivaConfiguration;
+ @Inject
+ private RepositoryRegistry repositoryRegistry;
+
@Inject
protected UserRepositories userRepos;
{
archivaConfiguration.getConfiguration().addManagedRepository( repoConfig );
}
+ repositoryRegistry.reload();
// Add repo roles to security.
userRepos.createMissingRepositoryRoles( repoId );
}
@Override
- public String getFilePath( String requestPath, ManagedRepository managedRepository )
+ public String getFilePath( String requestPath, org.apache.archiva.repository.ManagedRepository managedRepository )
{
return null;
}
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-lazy-init="true">
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+
<bean name="securitySystem#testable" class="org.apache.archiva.redback.system.DefaultSecuritySystem">
<property name="userManager" ref="userManager#memory"/>
<property name="keyManager" ref="keyManager#memory"/>
* under the License.
*/
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.ConsumerMonitor;
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
+import org.apache.archiva.repository.ManagedRepository;
import org.springframework.stereotype.Service;
import java.util.Date;
retentionCount=Retention Count
snapshots=Snapshots
blockRedeployments=Block Redeployments
-retentionTime=Days Older
+retentionPeriod=Days Older
cronExpression=Cron Expression
cronExpression.help.title=Cron Expression Format
cronExpression.help.content= Quartz cron is used. Documentation is: <a target="_blank" href="http://quartz-scheduler.org/documentation/quartz-2.1.x/cookbook/">here</a>
managedRepository.location.help.content=Location on File System (can be relative to Archiva base directory or absolute path)
managedRepository.indexDirectory.help.title=Index Directory
managedRepository.indexDirectory.help.content=Path to the Maven Index directory
-managedRepository.retentionTime.help.title=Days Older
-managedRepository.retentionTime.help.content=For snapshots repositories, maximum file days age you want to keep
+managedRepository.retentionPeriod.help.title=Days Older
+managedRepository.retentionPeriod.help.content=For snapshots repositories, maximum file days age you want to keep
managedRepository.retentionCount.help.title=Retention Count
managedRepository.retentionCount.help.content=For snapshots repositories, maximum of files you want to keep.
managedRepository.description.help.content=A free description for your repository
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Locale;
/**
* @author Olivier Lamy
FileUtils.deleteDirectory( tmpIndexDir.toFile() );
}
String id = Long.toString( System.currentTimeMillis() );
- ManagedRepository managedRepository = new ManagedRepository();
+ ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
+import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
org.apache.archiva.common.utils.FileUtils.deleteDirectory( tmpIndexDir );
}
String id = Long.toString( System.currentTimeMillis() );
- ManagedRepository managedRepository = new ManagedRepository();
+ ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
// create a repo with a remote on the one with index
id = Long.toString( System.currentTimeMillis() );
- managedRepository = new ManagedRepository();
+ managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
String remoteId = Long.toString( System.currentTimeMillis() );
- RemoteRepository remoteRepository = new RemoteRepository();
+ RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId( remoteId );
remoteRepository.setName( remoteId );
remoteRepository.setDownloadRemoteIndex( true );
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
+import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
FileUtils.deleteDirectory( tmpIndexDir.toFile() );
}
String id = Long.toString( System.currentTimeMillis() );
- ManagedRepository managedRepository = new ManagedRepository();
+ ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
// create a repo with a remote on the one with index
id = Long.toString( System.currentTimeMillis() );
- managedRepository = new ManagedRepository();
+ managedRepository = new ManagedRepository(Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
getManagedRepositoriesService().addManagedRepository( managedRepository );
- RemoteRepository remoteRepository = new RemoteRepository();
+ RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
remoteRepository.setId( "all-merged" );
remoteRepository.setName( "all-merged" );
remoteRepository.setDownloadRemoteIndex( true );
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
org.apache.archiva.common.utils.FileUtils.deleteDirectory( tmpIndexDir );
}
String id = Long.toString( System.currentTimeMillis() );
- ManagedRepository managedRepository = new ManagedRepository();
+ ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault());
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/snapshot-repo" );
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
RemoteRepository getRemoteRepository()
{
- return new RemoteRepository( "id-new", "new one", "http://foo.com", "default", "foo", "foopassword", 120,
+ return new RemoteRepository( Locale.getDefault( ), "id-new", "new one", "http://foo.com", "default", "foo", "foopassword", 120,
"cool repo" );
}
<context:property-placeholder system-properties-mode="OVERRIDE"/>
+ <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+
<bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry">
<property name="properties">
<value>
default-lazy-init="true">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
+ <context:component-scan base-package="org.apache.archiva.repository.content.maven2" />
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.webtest.memory"/>
+ <context:component-scan base-package="org.apache.archiva.webtest.memory,org.apache.archiva.repository.content.maven2"/>
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+
<alias name="repositorySessionFactory#test" alias="repositorySessionFactory"/>
<context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils"/>
+ base-package="org.apache.archiva.redback.keys,org.apache.archiva.rest.services.utils,org.apache.archiva.repository.content.maven2"/>
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
</bean>
-->
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
+
+
<alias name="repositorySessionFactory#jcr" alias="repositorySessionFactory"/>
<bean name="TestRepositorySessionFactoryBean" class="org.apache.archiva.TestRepositorySessionFactoryBean">
];
ManagedRepository=function(id,name,layout,indexDirectory,location,snapshots,releases,blockRedeployments,cronExpression,
- scanned,retentionTime,retentionCount,deleteReleasedSnapshots,stageRepoNeeded,description,
+ scanned,retentionPeriod,retentionCount,deleteReleasedSnapshots,stageRepoNeeded,description,
skipPackedIndexCreation,feedsUrl,url){
var self=this;
//private ManagedRepository stagingRepository;
- //private int retentionTime = 100;
- this.retentionTime=ko.observable(retentionTime);
- this.retentionTime.subscribe(function(newValue){self.modified(true)});
+ //private int retentionPeriod = 100;
+ this.retentionPeriod=ko.observable(retentionPeriod);
+ this.retentionPeriod.subscribe(function(newValue){self.modified(true)});
//private int retentionCount = 2;
this.retentionCount=ko.observable(retentionCount);
return new ManagedRepository(data.id,data.name,data.layout,data.indexDirectory,data.location,data.snapshots
,data.releases,
data.blockRedeployments,data.cronExpression,
- data.scanned,data.retentionTime,data.retentionCount,data.deleteReleasedSnapshots,
+ data.scanned,data.retentionPeriod,data.retentionCount,data.deleteReleasedSnapshots,
data.stageRepoNeeded,data.description,data.skipPackedIndexCreation);
}
</div>
</div>
<div class="control-group">
- <label class="control-label" for="retentionTime">${$.i18n.prop('retentionTime')}</label>
+ <label class="control-label" for="retentionPeriod">${$.i18n.prop('retentionPeriod')}</label>
<div class="controls">
- <input type="text" id="retentionTime" class="digits" name="retentionTime" size="5"
- data-bind="value: managedRepository.retentionTime"/>
- <a class="btn btn-warning btn-mini popover-doc" id="managedRepository-retentionTime-info-button"
- data-original-title="${$.i18n.prop('managedRepository.retentionTime.help.title')}"
- data-content="${$.i18n.prop('managedRepository.retentionTime.help.content')}">
+ <input type="text" id="retentionPeriod" class="digits" name="retentionPeriod" size="5"
+ data-bind="value: managedRepository.retentionPeriod"/>
+ <a class="btn btn-warning btn-mini popover-doc" id="managedRepository-retentionPeriod-info-button"
+ data-original-title="${$.i18n.prop('managedRepository.retentionPeriod.help.title')}"
+ data-content="${$.i18n.prop('managedRepository.retentionPeriod.help.content')}">
<i class="icon-question-sign icon-white"></i>
</a>
</div>
<label class="control-label" for="timeout">${$.i18n.prop('timeout')}</label>
<div class="controls">
- <input type="text" id="timeout" class="digits" name="retentionTime" size="5"
+ <input type="text" id="timeout" class="digits" name="retentionPeriod" size="5"
data-bind="value: remoteRepository.timeout"/>
<a class="btn btn-warning btn-mini popover-doc" id="remoteRepository-timeout-info-button"
data-original-title="${$.i18n.prop('remoteRepository.timeout.help.title')}"
* under the License.
*/
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.common.filelock.FileLockException;
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.common.filelock.FileLockTimeoutException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceIterator;
+import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.io.InputContext;
import org.apache.jackrabbit.webdav.io.OutputContext;
-import org.apache.jackrabbit.webdav.lock.*;
-import org.apache.jackrabbit.webdav.property.*;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.ResourceType;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
private String remoteAddr;
- private final ManagedRepository repository;
+ private final org.apache.archiva.repository.ManagedRepository repository;
private final MimeTypes mimeTypes;
private Logger log = LoggerFactory.getLogger( ArchivaDavResource.class );
- public ArchivaDavResource( String localResource, String logicalResource, ManagedRepository repository,
+ public ArchivaDavResource( String localResource, String logicalResource, org.apache.archiva.repository.ManagedRepository repository,
DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory,
MimeTypes mimeTypes, List<AuditListener> auditListeners,
RepositoryArchivaTaskScheduler scheduler, FileLockManager fileLockManager )
this.fileLockManager = fileLockManager;
}
- public ArchivaDavResource( String localResource, String logicalResource, ManagedRepository repository,
+ public ArchivaDavResource( String localResource, String logicalResource, org.apache.archiva.repository.ManagedRepository repository,
String remoteAddr, String principal, DavSession session,
ArchivaDavResourceLocator locator, DavResourceFactory factory, MimeTypes mimeTypes,
List<AuditListener> auditListeners, RepositoryArchivaTaskScheduler scheduler,
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
-import org.apache.archiva.indexer.merger.*;
+import org.apache.archiva.indexer.merger.IndexMerger;
+import org.apache.archiva.indexer.merger.IndexMergerException;
+import org.apache.archiva.indexer.merger.IndexMergerRequest;
+import org.apache.archiva.indexer.merger.MergedRemoteIndexesTask;
+import org.apache.archiva.indexer.merger.MergedRemoteIndexesTaskRequest;
+import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.metadata.model.facets.AuditEvent;
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.ManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.content.maven2.RepositoryRequest;
import org.apache.archiva.repository.events.AuditListener;
+import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
-import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
import org.apache.jackrabbit.webdav.lock.LockManager;
import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
import org.apache.maven.index.context.IndexingContext;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
*
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
+ @Inject
+ private RepositoryRegistry repositoryRegistry;
+
@Inject
private IndexMerger indexMerger;
archivaLocator.getRepositoryId(), e.getMessage() );
}
- ManagedRepositoryContent managedRepositoryContent = null;
- try
- {
- managedRepositoryContent =
- repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
- }
- catch ( RepositoryNotFoundException e )
- {
+ ManagedRepository repo = repositoryRegistry.getManagedRepository( archivaLocator.getRepositoryId() );
+ if (repo==null) {
throw new DavException( HttpServletResponse.SC_NOT_FOUND,
- "Invalid repository: " + archivaLocator.getRepositoryId() );
+ "Invalid repository: " + archivaLocator.getRepositoryId() );
}
- catch ( RepositoryException e )
- {
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ ManagedRepositoryContent managedRepositoryContent = repo.getContent( );
+ if (managedRepositoryContent==null) {
+ log.error("Inconsistency detected. Repository content not found for '{}'", archivaLocator.getRepositoryId());
+ throw new DavException( HttpServletResponse.SC_NOT_FOUND,
+ "Invalid repository: " + archivaLocator.getRepositoryId() );
}
log.debug( "Managed repository '{}' accessed by '{}'", managedRepositoryContent.getId(), activePrincipal );
- try
- {
- resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
- managedRepositoryAdmin.getManagedRepository(
- archivaLocator.getRepositoryId() ) );
+ resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
+ repo);
- String logicalResource = getLogicalResource( archivaLocator, null, false );
- resourcesInAbsolutePath.add(
- Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
+ String logicalResource = getLogicalResource( archivaLocator, null, false );
+ resourcesInAbsolutePath.add(
+ Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ).toAbsolutePath().toString() );
- }
- catch ( RepositoryAdminException e )
- {
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
- }
}
String requestedResource = request.getRequestURI();
for ( String repositoryId : repositories )
{
ManagedRepositoryContent managedRepositoryContent;
- try
- {
- managedRepositoryContent = repositoryFactory.getManagedRepositoryContent( repositoryId );
+ ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( repositoryId );
+ if (managedRepository==null) {
+ throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not find repository with id "+repositoryId );
}
- catch ( RepositoryNotFoundException e )
- {
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
- }
- catch ( RepositoryException e )
- {
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ managedRepositoryContent = managedRepository.getContent();
+ if (managedRepositoryContent==null) {
+ log.error("Inconsistency detected. Repository content not found for '{}'",repositoryId);
+ throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not find repository content with id "+repositoryId );
}
-
try
{
- ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repositoryId );
DavResource updatedResource =
processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
managedRepository );
{
storedExceptions.add( e );
}
- catch ( RepositoryAdminException e )
- {
- storedExceptions.add( new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e ) );
- }
}
}
if ( resource == null )
return resource;
}
- private String getLogicalResource( ArchivaDavResourceLocator archivaLocator, ManagedRepository managedRepository,
+ private String getLogicalResource( ArchivaDavResourceLocator archivaLocator, org.apache.archiva.repository.ManagedRepository managedRepository,
boolean useOrigResourcePath )
{
// FIXME remove this hack
// but currently managedRepository can be null in case of group
- String layout = managedRepository == null ? new ManagedRepository().getLayout() : managedRepository.getLayout();
+ String layout = managedRepository == null ? "default" : managedRepository.getLayout();
RepositoryStorage repositoryStorage =
this.applicationContext.getBean( "repositoryStorage#" + layout, RepositoryStorage.class );
String path = repositoryStorage.getFilePath(
throws DavException
{
String layout = managedRepositoryContent.getRepository() == null
- ? new ManagedRepository().getLayout()
+ ? "default"
: managedRepositoryContent.getRepository().getLayout();
RepositoryStorage repositoryStorage =
this.applicationContext.getBean( "repositoryStorage#" + layout, RepositoryStorage.class );
private DavResource processRepository( final DavServletRequest request, ArchivaDavResourceLocator archivaLocator,
String activePrincipal, ManagedRepositoryContent managedRepositoryContent,
- ManagedRepository managedRepository )
+ org.apache.archiva.repository.ManagedRepository managedRepository )
throws DavException
{
DavResource resource = null;
// check if target repo is enabled for releases
// we suppose that release-artifacts can be deployed only to repos enabled for releases
- if ( managedRepositoryContent.getRepository().isReleases() && !repositoryRequest.isMetadata(
+ if ( managedRepositoryContent.getRepository().getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ) && !repositoryRequest.isMetadata(
resourcePath ) && !repositoryRequest.isSupportFile( resourcePath ) )
{
ArtifactReference artifact = null;
{
// check if artifact already exists and if artifact re-deployment to the repository is allowed
if ( managedRepositoryContent.hasContent( artifact )
- && managedRepositoryContent.getRepository().isBlockRedeployments() )
+ && managedRepositoryContent.getRepository().blocksRedeployments())
{
log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",
managedRepositoryContent.getId() );
ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );
ManagedRepositoryContent managedRepositoryContent;
- try
- {
- managedRepositoryContent =
- repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
- }
- catch ( RepositoryNotFoundException e )
- {
+ ManagedRepository repo = repositoryRegistry.getManagedRepository( archivaLocator.getRepositoryId( ) );
+ if (repo==null) {
throw new DavException( HttpServletResponse.SC_NOT_FOUND,
- "Invalid repository: " + archivaLocator.getRepositoryId() );
+ "Invalid repository: " + archivaLocator.getRepositoryId() );
}
- catch ( RepositoryException e )
- {
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ managedRepositoryContent = repo.getContent();
+ if (managedRepositoryContent==null) {
+ log.error("Inconsistency detected. Repository content not found for '{}'", archivaLocator.getRepositoryId());
+ throw new DavException( HttpServletResponse.SC_NOT_FOUND,
+ "Invalid repository: " + archivaLocator.getRepositoryId() );
}
DavResource resource = null;
- try
- {
- String logicalResource = getLogicalResource( archivaLocator, managedRepositoryAdmin.getManagedRepository(
- archivaLocator.getRepositoryId() ), false );
- if ( logicalResource.startsWith( "/" ) )
- {
- logicalResource = logicalResource.substring( 1 );
- }
- Path resourceFile = Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource );
- resource = new ArchivaDavResource( resourceFile.toAbsolutePath().toString(), logicalResource,
- managedRepositoryContent.getRepository(), davSession, archivaLocator,
- this, mimeTypes, auditListeners, scheduler, fileLockManager );
-
- resource.addLockManager( lockManager );
- }
- catch ( RepositoryAdminException e )
+ String logicalResource = getLogicalResource( archivaLocator, repo, false );
+ if ( logicalResource.startsWith( "/" ) )
{
- throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
+ logicalResource = logicalResource.substring( 1 );
}
+ Path resourceFile = Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource );
+ resource = new ArchivaDavResource( resourceFile.toAbsolutePath().toString(), logicalResource,
+ repo, davSession, archivaLocator,
+ this, mimeTypes, auditListeners, scheduler, fileLockManager );
+
+ resource.addLockManager( lockManager );
return resource;
}
// FIXME add a method with group in the repository storage
String firstRepoId = repositoryGroupConfiguration.getRepositories().get( 0 );
- String path = getLogicalResource( locator, managedRepositoryAdmin.getManagedRepository( firstRepoId ), false );
+ String path = getLogicalResource( locator, repositoryRegistry.getManagedRepository( firstRepoId ), false );
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
for ( String repository : repositories )
{
ManagedRepositoryContent managedRepository = null;
-
- try
- {
- managedRepository = repositoryFactory.getManagedRepositoryContent( repository );
- }
- catch ( RepositoryNotFoundException e )
- {
+ ManagedRepository repo = repositoryRegistry.getManagedRepository( repository );
+ if (repo == null) {
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- "Invalid managed repository <" + repository + ">: " + e.getMessage() );
+ "Invalid managed repository <" + repository + ">");
}
- catch ( RepositoryException e )
- {
+ managedRepository = repo.getContent();
+ if (managedRepository==null) {
+ log.error("Inconsistency detected. Repository content not found for '{}'",repository);
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- "Invalid managed repository <" + repository + ">: " + e.getMessage() );
+ "Invalid managed repository <" + repository + ">");
}
-
Path resourceFile = Paths.get( managedRepository.getRepoRoot(), logicalResource.getPath() );
if ( Files.exists(resourceFile) )
{
// in case of group displaying index directory doesn't have sense !!
- String repoIndexDirectory = managedRepository.getRepository().getIndexDirectory();
+ IndexCreationFeature idf = managedRepository.getRepository().getFeature(IndexCreationFeature.class).get();
+ String repoIndexDirectory = idf.getIndexPath().toString();
if ( StringUtils.isNotEmpty( repoIndexDirectory ) )
{
if ( !Paths.get( repoIndexDirectory ).isAbsolute() )
{
- repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation(),
+ repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve(
StringUtils.isEmpty( repoIndexDirectory )
? ".indexer"
: repoIndexDirectory ).toAbsolutePath().toString();
}
if ( StringUtils.isEmpty( repoIndexDirectory ) )
{
- repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation(),
+ repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve(
".indexer" ).toAbsolutePath().toString();
}
{
this.managedRepositoryAdmin = managedRepositoryAdmin;
}
+
+ public RepositoryRegistry getRepositoryRegistry( )
+ {
+ return repositoryRegistry;
+ }
+
+ public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )
+ {
+ this.repositoryRegistry = repositoryRegistry;
+ }
}
long end = System.currentTimeMillis();
- log.info( "initServers done in {} ms", (end - start) );
+ log.debug( "initServers done in {} ms", (end - start) );
}
@Override
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest;
import org.apache.archiva.webdav.util.MavenIndexerCleaner;
@Inject
protected ManagedRepositoryAdmin managedRepositoryAdmin;
+ @Inject
+ RepositoryRegistry repositoryRegistry;
+
protected Logger log = LoggerFactory.getLogger( getClass() );
throws Exception
{
saveConfiguration( archivaConfiguration );
+ repositoryRegistry.reload();
}
@Before
config.addManagedRepository(
createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) );
+ repositoryRegistry.reload();
managedRepositoryAdmin.createIndexContext( managedRepositoryAdmin.getManagedRepository( REPOID_INTERNAL ) );
protected void saveConfiguration( ArchivaConfiguration archivaConfiguration )
throws Exception
{
+ repositoryRegistry.reload();
archivaConfiguration.save( archivaConfiguration.getConfiguration() );
}
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.proxy.DefaultRepositoryProxyConnectors;
import org.apache.archiva.proxy.model.ProxyFetchResult;
+import org.apache.archiva.repository.EditableManagedRepository;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent;
import org.apache.archiva.repository.content.maven2.RepositoryRequest;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.jackrabbit.webdav.DavResourceLocator;
import org.apache.jackrabbit.webdav.DavServletRequest;
import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import static org.easymock.EasyMock.*;
@Inject
DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin;
+ @Inject
+ RepositoryRegistry repositoryRegistry;
+
@Inject
RemoteRepositoryAdmin remoteRepositoryAdmin;
archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class );
config = new Configuration();
- expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 5, 20 );
+ expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2, 20 );
+ expect (archivaConfiguration.getDefaultLocale()).andReturn( Locale.getDefault() ).anyTimes();
+ archivaConfiguration.addListener( EasyMock.anyObject( ) );
+ expectLastCall().times(0, 4);
archivaConfiguration.save( config );
- expectLastCall().times( 1, 4 );
+ expectLastCall().times( 0, 4 );
archivaConfigurationControl.replay();
defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
+ repositoryRegistry.setArchivaConfiguration( archivaConfiguration );
+ repositoryRegistry.reload();
( (DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator() ).setArchivaConfiguration(
archivaConfiguration );
if ( defaultManagedRepositoryAdmin.getManagedRepository( RELEASES_REPO ) == null )
resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
resourceFactory.setRemoteRepositoryAdmin( remoteRepositoryAdmin );
resourceFactory.setManagedRepositoryAdmin( defaultManagedRepositoryAdmin );
+ resourceFactory.setRepositoryRegistry( repositoryRegistry );
}
private ManagedRepository createManagedRepository( String id, String location, String layout )
{
- ManagedRepository repoConfig = new ManagedRepository();
+ ManagedRepository repoConfig = new ManagedRepository( Locale.getDefault());
repoConfig.setId( id );
repoConfig.setName( id );
repoConfig.setLocation( location );
throws RepositoryAdminException
{
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
- repoContent.setRepository( defaultManagedRepositoryAdmin.getManagedRepository( repoId ) );
-
+ org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId );
+ repoContent.setRepository( repo );
+ if (repo!=null && repo instanceof EditableManagedRepository)
+ {
+ ( (EditableManagedRepository) repo ).setContent( repoContent );
+ }
return repoContent;
}
{
archivaConfigurationControl.reset();
- expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2 );
-
- expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
+ expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 1 );
expect( request.getMethod() ).andReturn( "GET" ).times( 4 );
public void testRequestMetadataRepoIsLegacy()
throws Exception
{
+ ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
+ ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
+ beanFactory.registerSingleton("managedRepositoryContent#legacy", legacyRepo);
defaultManagedRepositoryAdmin.addManagedRepository(
createManagedRepository( LEGACY_REPO, Paths.get( "target/test-classes/" + LEGACY_REPO ).toString(),
"legacy" ), false, null );
new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
LEGACY_REPO, new ArchivaDavLocatorFactory() );
- ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
RepositoryRequest repoRequest = new RepositoryRequest( );
*/
import junit.framework.TestCase;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.repository.events.AuditListener;
+import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.util.MimeTypes;
-import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.LockManager;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
+import org.apache.jackrabbit.webdav.lock.Type;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
private LockManager lockManager;
- private ManagedRepository repository = new ManagedRepository();
+ private MavenManagedRepository repository = new MavenManagedRepository( "repo001", "repo001");
@Override
@Before
configuration.removeManagedRepository( managedRepositoryConfiguration );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRootInvalid );
+ repositoryRegistry.reload();
saveConfiguration( archivaConfiguration );
startRepository();
import org.apache.archiva.redback.system.SecuritySession;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.memory.SimpleUser;
+import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.audit.TestAuditListener;
import org.apache.archiva.security.ServletAuthenticator;
import org.apache.archiva.security.common.ArchivaRoleConstants;
@Inject
protected ArchivaConfiguration archivaConfiguration;
+ @Inject
+ protected RepositoryRegistry repositoryRegistry;
+
private DavSessionProvider davSessionProvider;
private IMocksControl servletAuthControl;
protected void saveConfiguration( ArchivaConfiguration archivaConfiguration )
throws Exception
{
+ repositoryRegistry.reload();
archivaConfiguration.save( archivaConfiguration.getConfiguration() );
}
<configuration>
- <version>2</version>
+ <version>3.0.0</version>
<repositoryScanning>
<fileTypes>
<context:annotation-config/>
<context:component-scan
- base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.webdav.util,org.apache.archiva.common.plexusbridge"/>
+ base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.webdav.util,org.apache.archiva.common.plexusbridge,org.apache.archiva.repository.content.maven2,org.apache.archiva.repository"/>
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">
<context:property-placeholder system-properties-mode="OVERRIDE"/>
<context:annotation-config/>
- <context:component-scan base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository"/>
+ <context:component-scan base-package="org.apache.archiva.redback.keys,org.apache.archiva.webdav,org.apache.archiva.metadata.repository,org.apache.archiva.repository,org.apache.archiva.repository.content.maven2"/>
+
+ <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" />
+ <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" />
<bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
<property name="properties">