Search in sources :

Example 6 with FileType

use of org.apache.archiva.configuration.model.FileType in project archiva by apache.

the class ConfigurationRegistryWriter method writeRepositoryScanningConfiguration.

private void writeRepositoryScanningConfiguration(String prefix, RepositoryScanningConfiguration value, Registry registry) {
    if (value != null) {
        if (value.getFileTypes() != null && value.getFileTypes().size() > 0) {
            registry.removeSubset(prefix + "fileTypes");
            int count = 0;
            for (Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++) {
                String name = "fileTypes.fileType(" + count + ")";
                FileType o = (FileType) iter.next();
                writeFileType(prefix + name + ".", o, registry);
            }
        }
        if (value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0) {
            registry.removeSubset(prefix + "knownContentConsumers");
            int count = 0;
            for (Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++) {
                String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
                String knownContentConsumer = (String) iter.next();
                registry.setString(prefix + name, knownContentConsumer);
            }
        }
        if (value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0) {
            registry.removeSubset(prefix + "invalidContentConsumers");
            int count = 0;
            for (Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++) {
                String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
                String invalidContentConsumer = (String) iter.next();
                registry.setString(prefix + name, invalidContentConsumer);
            }
        }
    }
}
Also used : FileType(org.apache.archiva.configuration.model.FileType) Iterator(java.util.Iterator)

Example 7 with FileType

use of org.apache.archiva.configuration.model.FileType 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 FileType

use of org.apache.archiva.configuration.model.FileType in project archiva by apache.

the class AbstractArtifactConsumerTest method setUp.

@Before
public void setUp() throws Exception {
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    assertEquals(FileTypes.ARTIFACTS, fileType.getId());
    fileType.addPattern("**/*.xml");
    archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().addChecksumType("MD5");
    archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().addChecksumType("SHA1");
    archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().addChecksumType("SHA256");
    repoLocation = Paths.get("target/test-" + getName() + "/test-repo");
}
Also used : FileType(org.apache.archiva.configuration.model.FileType) Before(org.junit.Before)

Example 9 with FileType

use of org.apache.archiva.configuration.model.FileType in project archiva by apache.

the class FileTypes method getFileTypePatterns.

/**
 * Get the list of patterns for a specified filetype.
 * You will always get a list.  In this order.
 * <ul>
 * <li>The Configured List</li>
 * <li>The Default List</li>
 * <li>A single item list of <code>&quot;**&#47;*&quot;</code></li>
 * </ul>
 *
 * @param id the id to lookup.
 * @return the list of patterns.
 */
public List<String> getFileTypePatterns(String id) {
    Configuration config = archivaConfiguration.getConfiguration();
    Predicate selectedFiletype = new FiletypeSelectionPredicate(id);
    RepositoryScanningConfiguration repositoryScanningConfiguration = config.getRepositoryScanning();
    if (repositoryScanningConfiguration != null) {
        FileType filetype = IterableUtils.find(config.getRepositoryScanning().getFileTypes(), selectedFiletype);
        if ((filetype != null) && CollectionUtils.isNotEmpty(filetype.getPatterns())) {
            return filetype.getPatterns();
        }
    }
    List<String> defaultPatterns = defaultTypeMap.get(id);
    if (CollectionUtils.isEmpty(defaultPatterns)) {
        return Collections.singletonList("**/*");
    }
    return defaultPatterns;
}
Also used : RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) FileType(org.apache.archiva.configuration.model.FileType) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) Predicate(org.apache.commons.collections4.Predicate) FiletypeSelectionPredicate(org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate) FiletypeSelectionPredicate(org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate)

Example 10 with FileType

use of org.apache.archiva.configuration.model.FileType in project archiva by apache.

the class FiletypeToMapClosure method execute.

@Override
public void execute(Object input) {
    if (input instanceof FileType) {
        FileType filetype = (FileType) input;
        map.put(filetype.getId(), filetype);
    }
}
Also used : FileType(org.apache.archiva.configuration.model.FileType)

Aggregations

FileType (org.apache.archiva.configuration.model.FileType)13 Path (java.nio.file.Path)4 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)3 MavenManagedRepository (org.apache.archiva.maven.repository.MavenManagedRepository)3 Before (org.junit.Before)3 Iterator (java.util.Iterator)2 List (java.util.List)2 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)2 PostConstruct (javax.annotation.PostConstruct)1 BaseFile (org.apache.archiva.common.utils.BaseFile)1 ArchivaRuntimeConfiguration (org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration)1 Configuration (org.apache.archiva.configuration.model.Configuration)1 FiletypeSelectionPredicate (org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate)1 FileTypes (org.apache.archiva.configuration.provider.FileTypes)1 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)1 ConsumerWantsFilePredicate (org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate)1 Predicate (org.apache.commons.collections4.Predicate)1