Search in sources :

Example 11 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class RepositoryServletTest method testGetRepositoryAfterDelete.

@Test
public void testGetRepositoryAfterDelete() throws Exception {
    RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
    assertNotNull(servlet);
    ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
    Configuration c = archivaConfiguration.getConfiguration();
    c.removeManagedRepository(c.findManagedRepositoryById(REPOID_INTERNAL));
    saveConfiguration(archivaConfiguration);
    repositoryRegistry.removeRepository(REPOID_INTERNAL);
    org.apache.archiva.repository.ManagedRepository repository = servlet.getRepository(REPOID_INTERNAL);
    assertNull(repository);
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Test(org.junit.Test)

Example 12 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class AbstractRepositoryServletTestCase method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    System.setProperty("appserver.base", getAppserverBase().toAbsolutePath().toString());
    log.info("setUp appserverBase={}, projectBase={}, workingDir={}", getAppserverBase(), getProjectBase(), Paths.get("").toString());
    repositoryRegistry.getRepositories().stream().forEach(r -> {
        try {
            repositoryRegistry.removeRepository(r);
        } catch (RepositoryException e) {
            e.printStackTrace();
        }
    });
    org.apache.archiva.common.utils.FileUtils.deleteDirectory(getAppserverBase());
    Path testConf = getProjectBase().resolve("src/test/resources/repository-archiva.xml");
    Path testConfDest = getAppserverBase().resolve("conf/archiva.xml");
    if (Files.exists(testConfDest)) {
        org.apache.archiva.common.utils.FileUtils.deleteQuietly(testConfDest);
    }
    FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
    repoRootInternal = getAppserverBase().resolve("data/repositories/internal");
    repoRootLegacy = getAppserverBase().resolve("data/repositories/legacy");
    Configuration config = archivaConfiguration.getConfiguration();
    config.getManagedRepositories().clear();
    config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true));
    config.getProxyConnectors().clear();
    config.getRemoteRepositories().clear();
    saveConfiguration(archivaConfiguration);
// repositoryRegistry.reload();
// ArchivaIndexingContext ctx = repositoryRegistry.getManagedRepository( REPOID_INTERNAL ).getIndexingContext( );
// try
// {
// if (repositoryRegistry.getIndexManager(RepositoryType.MAVEN)!=null) {
// repositoryRegistry.getIndexManager(RepositoryType.MAVEN).pack(ctx);
// }
// } finally
// {
// if (ctx!=null)
// {
// ctx.close( );
// }
// }
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) Before(org.junit.Before)

Example 13 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class ReinitServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(req.getServletContext());
    ArchivaConfiguration archivaConfiguration = applicationContext.getBean(ArchivaConfiguration.class);
    archivaConfiguration.reload();
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Example 14 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class FileMetadataRepositoryTest method createTestConfiguration.

protected static ArchivaConfiguration createTestConfiguration(Path directory) {
    ArchivaConfiguration config = mock(ArchivaConfiguration.class);
    Configuration configData = new Configuration();
    configData.addManagedRepository(createManagedRepository(TEST_REPO_ID, directory));
    configData.addManagedRepository(createManagedRepository("other-repo", directory));
    when(config.getConfiguration()).thenReturn(configData);
    return config;
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Aggregations

ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)14 Configuration (org.apache.archiva.configuration.model.Configuration)6 Path (java.nio.file.Path)5 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)5 Before (org.junit.Before)5 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 FileType (org.apache.archiva.configuration.model.FileType)2 FileTypes (org.apache.archiva.configuration.provider.FileTypes)2 HttpAuthenticator (org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator)2 ManagedRepository (org.apache.archiva.repository.ManagedRepository)2 RepositoryContentFactory (org.apache.archiva.repository.RepositoryContentFactory)2 ServletAuthenticator (org.apache.archiva.security.ServletAuthenticator)2 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)1 ManagedRepositoryAdmin (org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin)1 DefaultRepositoryCommonValidator (org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator)1