<groupId>org.apache.archiva</groupId>
<artifactId>audit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-scanner</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
- <!-- TODO uncomment when repository admin will be finished
+ <!-- should be runtime but currently not possible due ConfigurationListener
<scope>runtime</scope>
-->
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-scanner</artifactId>
+ <artifactId>archiva-repository-admin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<argLine>-Xmx512m -Xms512m -client</argLine>
<systemPropertyVariables>
<appserver.base>${basedir}/target/appserver-base</appserver.base>
+ <plexus.home>${project.build.outputDirectory}</plexus.home>
+ <java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
</systemPropertyVariables>
<forkMode>${webdav.forkMode}</forkMode>
</configuration>
* under the License.
*/
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.security.ServletAuthenticator;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavLocatorFactory;
import org.apache.jackrabbit.webdav.DavMethods;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationEvent;
import org.apache.maven.archiva.configuration.ConfigurationListener;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.security.ServletAuthenticator;
import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private ArchivaConfiguration configuration;
- private Map<String, ManagedRepositoryConfiguration> repositoryMap;
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+ private Map<String, ManagedRepository> repositoryMap;
private DavLocatorFactory locatorFactory;
throws ServletException
{
super.init( servletConfig );
- initServers( servletConfig );
+ try
+ {
+ initServers( servletConfig );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new ServletException( e.getMessage(), e );
+ }
}
/**
}
public synchronized void initServers( ServletConfig servletConfig )
+ throws RepositoryAdminException
{
WebApplicationContext wac =
WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() );
configuration = wac.getBean( "archivaConfiguration#default", ArchivaConfiguration.class );
configuration.addListener( this );
- repositoryMap = configuration.getConfiguration().getManagedRepositoriesAsMap();
+ managedRepositoryAdmin = wac.getBean( ManagedRepositoryAdmin.class );
+
+ repositoryMap = managedRepositoryAdmin.getManagedRepositoriesAsMap();
- for ( ManagedRepositoryConfiguration repo : repositoryMap.values() )
+ for ( ManagedRepository repo : repositoryMap.values() )
{
File repoDir = new File( repo.getLocation() );
}
}
- resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class );
+ resourceFactory = wac.getBean( "davResourceFactory#archiva", DavResourceFactory.class );
locatorFactory = new ArchivaDavLocatorFactory();
ServletAuthenticator servletAuth = wac.getBean( ServletAuthenticator.class );
{
if ( event.getType() == ConfigurationEvent.SAVED )
{
- initRepositories();
+ try
+ {
+ initRepositories();
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error( e.getMessage(), e );
+ throw new RuntimeException( e.getMessage(), e );
+ }
}
}
private void initRepositories()
+ throws RepositoryAdminException
{
synchronized ( repositoryMap )
{
repositoryMap.clear();
- repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
+ repositoryMap.putAll( managedRepositoryAdmin.getManagedRepositoriesAsMap() );
}
synchronized ( reloadLock )
}
}
- public synchronized ManagedRepositoryConfiguration getRepository( String prefix )
+ public synchronized ManagedRepository getRepository( String prefix )
+ throws RepositoryAdminException
{
if ( repositoryMap.isEmpty() )
{
- repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
+ repositoryMap.putAll( managedRepositoryAdmin.getManagedRepositoriesAsMap() );
}
return repositoryMap.get( prefix );
}
import junit.framework.Assert;
import junit.framework.TestCase;
import net.sf.ehcache.CacheManager;
+import org.apache.archiva.admin.repository.managed.ManagedRepository;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
}
protected void assertRepositoryValid( RepositoryServlet servlet, String repoId )
+ throws Exception
{
- ManagedRepositoryConfiguration repository = servlet.getRepository( repoId );
+ ManagedRepository repository = servlet.getRepository( repoId );
assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
File repoRoot = new File( repository.getLocation() );
assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.",
* under the License.
*/
+import org.apache.archiva.admin.repository.managed.ManagedRepository;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
c.removeManagedRepository( c.findManagedRepositoryById( REPOID_INTERNAL ) );
saveConfiguration( archivaConfiguration );
- ManagedRepositoryConfiguration repository = servlet.getRepository( REPOID_INTERNAL );
+ ManagedRepository repository = servlet.getRepository( REPOID_INTERNAL );
assertNull( repository );
}
c.addManagedRepository( repo );
saveConfiguration( archivaConfiguration );
- ManagedRepositoryConfiguration repository = servlet.getRepository( NEW_REPOSITORY_ID );
+ ManagedRepository repository = servlet.getRepository( NEW_REPOSITORY_ID );
assertNotNull( repository );
assertEquals( NEW_REPOSITORY_NAME, repository.getName() );