Search in sources :

Example 46 with ManagedRepository

use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.

the class DefaultManagedRepositoryAdmin method convertRepo.

/*
     * Conversion between the repository from the registry and the serialized DTO for the admin API
     */
private ManagedRepository convertRepo(org.apache.archiva.repository.ManagedRepository repo) {
    if (repo == null) {
        return null;
    }
    ManagedRepository adminRepo = new ManagedRepository(getArchivaConfiguration().getDefaultLocale());
    setBaseRepoAttributes(adminRepo, repo);
    adminRepo.setLocation(convertUriToString(repo.getLocation()));
    adminRepo.setReleases(repo.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
    adminRepo.setSnapshots(repo.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
    adminRepo.setBlockRedeployments(repo.blocksRedeployments());
    adminRepo.setCronExpression(repo.getSchedulingDefinition());
    if (repo.supportsFeature(IndexCreationFeature.class)) {
        IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
        adminRepo.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
    }
    adminRepo.setScanned(repo.isScanned());
    if (repo.supportsFeature(ArtifactCleanupFeature.class)) {
        ArtifactCleanupFeature acf = repo.getFeature(ArtifactCleanupFeature.class).get();
        adminRepo.setRetentionPeriod(acf.getRetentionPeriod().getDays());
        adminRepo.setRetentionCount(acf.getRetentionCount());
        adminRepo.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
    }
    if (repo.supportsFeature(StagingRepositoryFeature.class)) {
        StagingRepositoryFeature stf = repo.getFeature(StagingRepositoryFeature.class).get();
        adminRepo.setStageRepoNeeded(stf.isStageRepoNeeded());
        if (stf.getStagingRepository() != null) {
            adminRepo.setStagingRepository(convertRepo(stf.getStagingRepository()));
        }
    }
    return adminRepo;
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepository(org.apache.archiva.admin.model.beans.ManagedRepository) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature)

Aggregations

ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)46 Test (org.junit.Test)23 Path (java.nio.file.Path)20 AbstractRepositoryAdminTest (org.apache.archiva.admin.repository.AbstractRepositoryAdminTest)11 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)10 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)10 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)9 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)8 ArrayList (java.util.ArrayList)7 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)7 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)5 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)5 RepositoryException (org.apache.archiva.repository.RepositoryException)5 IOException (java.io.IOException)4 Date (java.util.Date)4 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)4 ArtifactReference (org.apache.archiva.model.ArtifactReference)4 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)3 RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)3 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)3