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);
}
}
}
}
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));
}
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");
}
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>"**/*"</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;
}
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);
}
}
Aggregations