use of org.apache.archiva.admin.model.beans.FileType in project archiva by apache.
the class DefaultArchivaAdministration method removeFileType.
@Override
public void removeFileType(String fileTypeId, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
org.apache.archiva.configuration.FileType fileType = new org.apache.archiva.configuration.FileType();
fileType.setId(fileTypeId);
configuration.getRepositoryScanning().removeFileType(fileType);
saveConfiguration(configuration);
}
use of org.apache.archiva.admin.model.beans.FileType in project archiva by apache.
the class DefaultArchivaAdministration method addFileType.
@Override
public void addFileType(FileType fileType, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
if (getFileTypeById(fileType.getId(), configuration) != null) {
throw new RepositoryAdminException("impossible to FileType with id " + fileType.getId() + " already exists");
}
configuration.getRepositoryScanning().addFileType(getModelMapper().map(fileType, org.apache.archiva.configuration.FileType.class));
saveConfiguration(configuration);
}
use of org.apache.archiva.admin.model.beans.FileType in project archiva by apache.
the class ArchivaAdministrationTest method addAndUpdateAndDeleteFileType.
@Test
public void addAndUpdateAndDeleteFileType() throws RepositoryAdminException {
int initialSize = archivaAdministration.getFileTypes().size();
FileType fileType = new FileType();
fileType.setId("foo");
fileType.setPatterns(Arrays.asList("bar", "toto"));
archivaAdministration.addFileType(fileType, getFakeAuditInformation());
assertEquals(initialSize + 1, archivaAdministration.getFileTypes().size());
archivaAdministration.addFileTypePattern("foo", "zorro", getFakeAuditInformation());
assertEquals(initialSize + 1, archivaAdministration.getFileTypes().size());
assertEquals(3, archivaAdministration.getFileType("foo").getPatterns().size());
assertTrue(archivaAdministration.getFileType("foo").getPatterns().contains("bar"));
assertTrue(archivaAdministration.getFileType("foo").getPatterns().contains("toto"));
assertTrue(archivaAdministration.getFileType("foo").getPatterns().contains("zorro"));
archivaAdministration.removeFileTypePattern("foo", "zorro", getFakeAuditInformation());
assertEquals(initialSize + 1, archivaAdministration.getFileTypes().size());
assertEquals(2, archivaAdministration.getFileType("foo").getPatterns().size());
assertTrue(archivaAdministration.getFileType("foo").getPatterns().contains("bar"));
assertTrue(archivaAdministration.getFileType("foo").getPatterns().contains("toto"));
assertFalse(archivaAdministration.getFileType("foo").getPatterns().contains("zorro"));
archivaAdministration.removeFileType("foo", getFakeAuditInformation());
assertEquals(initialSize, archivaAdministration.getFileTypes().size());
assertNull(archivaAdministration.getFileType("foo"));
mockAuditListener.clearEvents();
}
use of org.apache.archiva.admin.model.beans.FileType in project archiva by apache.
the class ArchivaAdministrationServiceTest method addAndDeleteFileType.
@Test
public void addAndDeleteFileType() throws Exception {
int initialSize = getArchivaAdministrationService().getFileTypes().size();
FileType fileType = new FileType();
fileType.setId("footwo");
fileType.setPatterns(Arrays.asList("foo", "bar"));
getArchivaAdministrationService().addFileType(fileType);
assertEquals(initialSize + 1, getArchivaAdministrationService().getFileTypes().size());
assertNotNull(getArchivaAdministrationService().getFileType("footwo"));
assertEquals(Arrays.asList("foo", "bar"), getArchivaAdministrationService().getFileType("footwo").getPatterns());
getArchivaAdministrationService().removeFileType("footwo");
assertEquals(initialSize, getArchivaAdministrationService().getFileTypes().size());
assertNull(getArchivaAdministrationService().getFileType("footwo"));
}
use of org.apache.archiva.admin.model.beans.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