Search in sources :

Example 1 with FileType

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

the class ConfigurationRegistryReader method readFileType.

private FileType readFileType(String prefix, Registry registry) {
    FileType value = new FileType();
    // String id = registry.getString( prefix + "id", value.getId() );
    List<String> idList = registry.getList(prefix + "id");
    String id = value.getId();
    if (idList != null && !idList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = idList.size(); i < size; i++) {
            sb.append(idList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        id = sb.toString();
    }
    value.setId(id);
    java.util.List patterns = new java.util.ArrayList();
    patterns.addAll(registry.getList(prefix + "patterns.pattern"));
    value.setPatterns(patterns);
    return value;
}
Also used : List(java.util.List) FileType(org.apache.archiva.configuration.model.FileType)

Example 2 with FileType

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

the class ConfigurationRegistryReader method readRepositoryScanningConfiguration.

private RepositoryScanningConfiguration readRepositoryScanningConfiguration(String prefix, Registry registry) {
    RepositoryScanningConfiguration value = new RepositoryScanningConfiguration();
    java.util.List fileTypes = new java.util.ArrayList();
    List fileTypesSubsets = registry.getSubsetList(prefix + "fileTypes.fileType");
    for (Iterator i = fileTypesSubsets.iterator(); i.hasNext(); ) {
        FileType v = readFileType("", (Registry) i.next());
        fileTypes.add(v);
    }
    value.setFileTypes(fileTypes);
    java.util.List knownContentConsumers = new java.util.ArrayList();
    knownContentConsumers.addAll(registry.getList(prefix + "knownContentConsumers.knownContentConsumer"));
    value.setKnownContentConsumers(knownContentConsumers);
    java.util.List invalidContentConsumers = new java.util.ArrayList();
    invalidContentConsumers.addAll(registry.getList(prefix + "invalidContentConsumers.invalidContentConsumer"));
    value.setInvalidContentConsumers(invalidContentConsumers);
    return value;
}
Also used : List(java.util.List) FileType(org.apache.archiva.configuration.model.FileType) Iterator(java.util.Iterator) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) List(java.util.List)

Example 3 with FileType

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

the class RepositoryPurgeConsumerTest method cleanupFileTypes.

private void cleanupFileTypes() {
    ArchivaConfiguration archivaConfiguration = applicationContext.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    fileType.removePattern("**/*.xml");
}
Also used : FileType(org.apache.archiva.configuration.model.FileType) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Example 4 with FileType

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

the class MockConfiguration method initialize.

@PostConstruct
public void initialize() throws Exception {
    configuration.setRepositoryScanning(new RepositoryScanningConfiguration() {

        @Override
        public List<FileType> getFileTypes() {
            FileType fileType = new FileType();
            fileType.setId(FileTypes.ARTIFACTS);
            fileType.setPatterns(Collections.singletonList("**/*"));
            return Collections.singletonList(fileType);
        }
    });
    ArchivaRuntimeConfiguration rt = new ArchivaRuntimeConfiguration();
    List<String> checksums = new ArrayList<>();
    checksums.add("MD5");
    checksums.add("SHA1");
    checksums.add("SHA256");
    rt.setChecksumTypes(checksums);
    configuration.setArchivaRuntimeConfiguration(rt);
}
Also used : ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) FileType(org.apache.archiva.configuration.model.FileType) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 5 with FileType

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

the class FileTypes method initialiseTypeMap.

private void initialiseTypeMap(Configuration configuration) {
    defaultTypeMap.clear();
    // Store the default file type declaration.
    List<FileType> filetypes = configuration.getRepositoryScanning().getFileTypes();
    for (FileType filetype : filetypes) {
        List<String> patterns = defaultTypeMap.get(filetype.getId());
        if (patterns == null) {
            patterns = new ArrayList<>(filetype.getPatterns().size());
        }
        patterns.addAll(filetype.getPatterns());
        defaultTypeMap.put(filetype.getId(), patterns);
    }
}
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