Search in sources :

Example 1 with FiletypeSelectionPredicate

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

Aggregations

Configuration (org.apache.archiva.configuration.model.Configuration)1 FileType (org.apache.archiva.configuration.model.FileType)1 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)1 FiletypeSelectionPredicate (org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate)1 Predicate (org.apache.commons.collections4.Predicate)1