Search in sources :

Example 1 with FileType

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);
}
Also used : UiConfiguration(org.apache.archiva.admin.model.beans.UiConfiguration) NetworkConfiguration(org.apache.archiva.admin.model.beans.NetworkConfiguration) Configuration(org.apache.archiva.configuration.Configuration) WebappConfiguration(org.apache.archiva.configuration.WebappConfiguration) FileType(org.apache.archiva.admin.model.beans.FileType)

Example 2 with FileType

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);
}
Also used : UiConfiguration(org.apache.archiva.admin.model.beans.UiConfiguration) NetworkConfiguration(org.apache.archiva.admin.model.beans.NetworkConfiguration) Configuration(org.apache.archiva.configuration.Configuration) WebappConfiguration(org.apache.archiva.configuration.WebappConfiguration) FileType(org.apache.archiva.admin.model.beans.FileType) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 3 with FileType

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();
}
Also used : FileType(org.apache.archiva.admin.model.beans.FileType) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 4 with FileType

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"));
}
Also used : FileType(org.apache.archiva.admin.model.beans.FileType) Test(org.junit.Test)

Example 5 with FileType

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);
    }
}
Also used : FileType(org.apache.archiva.admin.model.beans.FileType)

Aggregations

FileType (org.apache.archiva.admin.model.beans.FileType)5 NetworkConfiguration (org.apache.archiva.admin.model.beans.NetworkConfiguration)2 UiConfiguration (org.apache.archiva.admin.model.beans.UiConfiguration)2 Configuration (org.apache.archiva.configuration.Configuration)2 WebappConfiguration (org.apache.archiva.configuration.WebappConfiguration)2 Test (org.junit.Test)2 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 AbstractRepositoryAdminTest (org.apache.archiva.admin.repository.AbstractRepositoryAdminTest)1