Search in sources :

Example 26 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class RepositoryConfigurationComparatorTest method createRepository.

private ManagedRepositoryConfiguration createRepository(String id) {
    ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
    repo.setId(id);
    return repo;
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration)

Example 27 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class AbstractMavenRepositorySearch method createRepositoryConfig.

protected ManagedRepositoryConfiguration createRepositoryConfig(String repository) {
    ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
    repositoryConfig.setId(repository);
    repositoryConfig.setLocation(org.apache.archiva.common.utils.FileUtils.getBasedir() + "/target/repos/" + repository);
    Path f = Paths.get(repositoryConfig.getLocation());
    if (!Files.exists(f)) {
        try {
            Files.createDirectories(f);
        } catch (IOException e) {
            log.error("Could not create directories for {}", f);
        }
    }
    repositoryConfig.setLayout("default");
    repositoryConfig.setName(repository);
    repositoryConfig.setScanned(true);
    repositoryConfig.setSnapshots(false);
    repositoryConfig.setReleases(true);
    repositoryConfig.setIndexDir(".indexer");
    return repositoryConfig;
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) IOException(java.io.IOException)

Example 28 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class RepositoryServletRepositoryGroupTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String appserverBase = System.getProperty("appserver.base");
    Configuration configuration = archivaConfiguration.getConfiguration();
    repoRootFirst = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_FIRST);
    repoRootLast = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_LAST);
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
    List<String> managedRepoIds = new ArrayList<>();
    managedRepoIds.add(MANAGED_REPO_FIRST);
    managedRepoIds.add(MANAGED_REPO_LAST);
    configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_VALID_REPOS, managedRepoIds));
    // Create the repository group with an invalid managed repository
    repoRootInvalid = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_INVALID);
    ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository(MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true);
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
    configuration.addManagedRepository(managedRepositoryConfiguration);
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
    List<String> invalidManagedRepoIds = new ArrayList<>();
    invalidManagedRepoIds.add(MANAGED_REPO_FIRST);
    invalidManagedRepoIds.add(MANAGED_REPO_INVALID);
    invalidManagedRepoIds.add(MANAGED_REPO_LAST);
    configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds));
    configuration.removeManagedRepository(managedRepositoryConfiguration);
    org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRootInvalid);
    repositoryRegistry.reload();
    saveConfiguration(archivaConfiguration);
    startRepository();
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 29 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class RepositoryServletSecurityTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    String appserverBase = System.getProperty("appserver.base", Paths.get("target/appserver-base").toAbsolutePath().toString());
    Path testConf = Paths.get("src/test/resources/repository-archiva.xml");
    Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml");
    FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
    Configuration config = archivaConfiguration.getConfiguration();
    // clear managed repository
    List<ManagedRepositoryConfiguration> f1 = new ArrayList<>(config.getManagedRepositories());
    for (ManagedRepositoryConfiguration f : f1) {
        config.removeManagedRepository(f);
    }
    assertEquals(0, config.getManagedRepositories().size());
    // add internal repo
    config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal.getRoot()));
    saveConfiguration(archivaConfiguration);
    CacheManager.getInstance().clearAll();
    servletAuthControl = EasyMock.createControl();
    servletAuth = servletAuthControl.createMock(ServletAuthenticator.class);
    httpAuthControl = EasyMock.createControl();
    httpAuth = httpAuthControl.createMock(HttpAuthenticator.class);
    davSessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
    final MockServletContext mockServletContext = new MockServletContext();
    WebApplicationContext webApplicationContext = new AbstractRepositoryServletTestCase.TestWebapplicationContext(applicationContext, mockServletContext);
    mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
    MockServletConfig mockServletConfig = new MockServletConfig() {

        @Override
        public ServletContext getServletContext() {
            return mockServletContext;
        }
    };
    servlet = new RepositoryServlet();
    servlet.init(mockServletConfig);
}
Also used : Path(java.nio.file.Path) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) MockServletConfig(org.springframework.mock.web.MockServletConfig) HttpAuthenticator(org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator) MockServletContext(org.springframework.mock.web.MockServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ServletAuthenticator(org.apache.archiva.security.ServletAuthenticator) Before(org.junit.Before)

Example 30 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.

the class RepositoryServletSecurityTest method createManagedRepository.

protected ManagedRepositoryConfiguration createManagedRepository(String id, String name, Path location) {
    ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
    repo.setId(id);
    repo.setName(name);
    repo.setLocation(location.toAbsolutePath().toString());
    return repo;
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration)

Aggregations

ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)46 Configuration (org.apache.archiva.configuration.Configuration)17 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)14 Path (java.nio.file.Path)9 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)9 Before (org.junit.Before)9 ContextConfiguration (org.springframework.test.context.ContextConfiguration)9 Test (org.junit.Test)8 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)7 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)7 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)7 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)7 ArrayList (java.util.ArrayList)6 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)5 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)5 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)5 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)5 IOException (java.io.IOException)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 RepositoryException (org.apache.archiva.repository.RepositoryException)4