Search in sources :

Example 6 with ArchivaConfiguration

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

the class FileMetadataRepositoryTest method setUp.

@BeforeEach
@Override
public void setUp() throws Exception {
    super.setUp();
    assertMaxTries = 1;
    assertRetrySleepMs = 10;
    Path directory = Paths.get("target/test-repositories");
    if (Files.exists(directory)) {
        org.apache.archiva.common.utils.FileUtils.deleteDirectory(directory);
    }
    ArchivaConfiguration config = createTestConfiguration(directory);
    List<MetadataFacetFactory> factories = createTestMetadataFacetFactories();
    MetadataService metadataService = new MetadataService();
    metadataService.setMetadataFacetFactories(factories);
    this.repository = new FileMetadataRepository(metadataService, config);
}
Also used : Path(java.nio.file.Path) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) MetadataService(org.apache.archiva.metadata.repository.MetadataService) MetadataFacetFactory(org.apache.archiva.metadata.model.MetadataFacetFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ArchivaConfiguration

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

the class RepositoryPurgeConsumerTest method assertNotConsumed.

@SuppressWarnings("deprecation")
private void assertNotConsumed(String path) throws Exception {
    ArchivaConfiguration archivaConfiguration = applicationContext.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    assertEquals(FileTypes.ARTIFACTS, fileType.getId());
    fileType.addPattern("**/*.xml");
    // FileTypes fileTypes = applicationContext.getBean( FileTypes.class );
    for (FileTypes fileTypes : applicationContext.getBeansOfType(FileTypes.class).values()) {
        fileTypes.afterConfigurationChange(null, "repositoryScanning.fileTypes", null);
    }
    KnownRepositoryContentConsumer repoPurgeConsumer = applicationContext.getBean("knownRepositoryContentConsumer#repository-purge", KnownRepositoryContentConsumer.class);
    Path repoLocation = Paths.get("target/test-" + getName() + "/test-repo");
    Path localFile = repoLocation.resolve(path);
    ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
    BaseFile baseFile = new BaseFile(repoLocation.toFile(), localFile.toFile());
    predicate.setBasefile(baseFile);
    assertFalse(predicate.evaluate(repoPurgeConsumer));
}
Also used : Path(java.nio.file.Path) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) FileType(org.apache.archiva.configuration.model.FileType) BaseFile(org.apache.archiva.common.utils.BaseFile) FileTypes(org.apache.archiva.configuration.provider.FileTypes) ConsumerWantsFilePredicate(org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Example 8 with ArchivaConfiguration

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

the class NexusIndexerConsumerTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    scheduler = new ArchivaTaskSchedulerStub();
    ArchivaConfiguration configuration = applicationContext.getBean(ArchivaConfiguration.class);
    FileTypes filetypes = applicationContext.getBean(FileTypes.class);
    nexusIndexerConsumer = new NexusIndexerConsumer(scheduler, configuration, filetypes);
    // initialize to set the file types to be processed
    nexusIndexerConsumer.initialize();
    repositoryConfig = BasicManagedRepository.newFilesystemInstance("test-repo", "Test Repository", Paths.get("target/test-classes").resolve("test-repo"));
    repositoryConfig.setLocation(new URI("target/test-classes/test-repo"));
    repositoryConfig.setLayout("default");
    repositoryConfig.setScanned(true);
    repositoryConfig.addActiveReleaseScheme(ReleaseScheme.RELEASE);
    repositoryConfig.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
    repositoryRegistry.putRepository(repositoryConfig);
}
Also used : FileTypes(org.apache.archiva.configuration.provider.FileTypes) URI(java.net.URI) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) Before(org.junit.Before)

Example 9 with ArchivaConfiguration

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

the class RepositoryServlet method initServers.

public void initServers(ServletConfig servletConfig) {
    long start = System.currentTimeMillis();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletConfig.getServletContext());
    rwLock.writeLock().lock();
    try {
        configuration = wac.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
        configuration.addListener(this);
        repositoryRegistry = wac.getBean(ArchivaRepositoryRegistry.class);
        resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class);
        locatorFactory = new ArchivaDavLocatorFactory();
        ServletAuthenticator servletAuth = wac.getBean(ServletAuthenticator.class);
        HttpAuthenticator httpAuth = wac.getBean("httpAuthenticator#basic", HttpAuthenticator.class);
        sessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
    } finally {
        rwLock.writeLock().unlock();
    }
    long end = System.currentTimeMillis();
    log.debug("initServers done in {} ms", (end - start));
}
Also used : DavResourceFactory(org.apache.jackrabbit.webdav.DavResourceFactory) ServletAuthenticator(org.apache.archiva.security.ServletAuthenticator) HttpAuthenticator(org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ArchivaRepositoryRegistry(org.apache.archiva.repository.base.ArchivaRepositoryRegistry)

Example 10 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration 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", getProjectBase().resolve("target/appserver-base").toAbsolutePath().toString());
    Path testConf = getProjectBase().resolve("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);
    servletAuth = mock(ServletAuthenticator.class);
    httpAuth = mock(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) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.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)

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