Search in sources :

Example 6 with StagingRepositoryFeature

use of org.apache.archiva.repository.features.StagingRepositoryFeature in project archiva by apache.

the class RepositoryProviderMock method updateManagedInstance.

@Override
public void updateManagedInstance(EditableManagedRepository managedRepository, ManagedRepositoryConfiguration configuration) throws RepositoryException {
    try {
        managedRepository.setName(managedRepository.getPrimaryLocale(), configuration.getName());
        managedRepository.setLocation(new URI(configuration.getLocation() == null ? "" : configuration.getLocation()));
        managedRepository.setBaseUri(new URI(""));
        managedRepository.setBlocksRedeployment(configuration.isBlockRedeployments());
        managedRepository.setDescription(managedRepository.getPrimaryLocale(), configuration.getDescription());
        managedRepository.setLayout(configuration.getLayout());
        managedRepository.setScanned(configuration.isScanned());
        managedRepository.setSchedulingDefinition(configuration.getRefreshCronExpression());
        if (configuration.isReleases()) {
            managedRepository.addActiveReleaseScheme(ReleaseScheme.RELEASE);
        }
        if (configuration.isSnapshots()) {
            managedRepository.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
        }
        ArtifactCleanupFeature acf = managedRepository.getFeature(ArtifactCleanupFeature.class).get();
        acf.setRetentionPeriod(Period.ofDays(configuration.getRetentionPeriod()));
        acf.setDeleteReleasedSnapshots(configuration.isDeleteReleasedSnapshots());
        acf.setRetentionCount(configuration.getRetentionCount());
        IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class).get();
        icf.setIndexPath(new URI(configuration.getIndexDir()));
        icf.setSkipPackedIndexCreation(configuration.isSkipPackedIndexCreation());
        StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class).get();
        srf.setStageRepoNeeded(configuration.isStageRepoNeeded());
    } catch (Exception e) {
        throw new RepositoryException("Error", e);
    }
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) RepositoryException(org.apache.archiva.repository.RepositoryException) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) RepositoryException(org.apache.archiva.repository.RepositoryException)

Example 7 with StagingRepositoryFeature

use of org.apache.archiva.repository.features.StagingRepositoryFeature in project archiva by apache.

the class RepositoryProviderMock method updateManagedInstance.

@Override
public void updateManagedInstance(EditableManagedRepository managedRepository, ManagedRepositoryConfiguration configuration) throws RepositoryException {
    try {
        managedRepository.setName(managedRepository.getPrimaryLocale(), configuration.getName());
        managedRepository.setLocation(new URI(configuration.getLocation() == null ? "" : configuration.getLocation()));
        managedRepository.setBaseUri(new URI(""));
        managedRepository.setBlocksRedeployment(configuration.isBlockRedeployments());
        managedRepository.setDescription(managedRepository.getPrimaryLocale(), configuration.getDescription());
        managedRepository.setLayout(configuration.getLayout());
        managedRepository.setScanned(configuration.isScanned());
        managedRepository.setSchedulingDefinition(configuration.getRefreshCronExpression());
        if (configuration.isReleases()) {
            managedRepository.addActiveReleaseScheme(ReleaseScheme.RELEASE);
        }
        if (configuration.isSnapshots()) {
            managedRepository.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
        }
        ArtifactCleanupFeature acf = managedRepository.getFeature(ArtifactCleanupFeature.class).get();
        acf.setRetentionPeriod(Period.ofDays(configuration.getRetentionPeriod()));
        acf.setDeleteReleasedSnapshots(configuration.isDeleteReleasedSnapshots());
        acf.setRetentionCount(configuration.getRetentionCount());
        IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class).get();
        icf.setIndexPath(new URI(configuration.getIndexDir()));
        icf.setSkipPackedIndexCreation(configuration.isSkipPackedIndexCreation());
        StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class).get();
        srf.setStageRepoNeeded(configuration.isStageRepoNeeded());
    } catch (Exception e) {
        throw new RepositoryException("Error", e);
    }
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) RepositoryException(org.apache.archiva.repository.RepositoryException) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) RepositoryException(org.apache.archiva.repository.RepositoryException)

Example 8 with StagingRepositoryFeature

use of org.apache.archiva.repository.features.StagingRepositoryFeature 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)

Example 9 with StagingRepositoryFeature

use of org.apache.archiva.repository.features.StagingRepositoryFeature in project archiva by apache.

the class DefaultManagedRepositoryAdmin method addManagedRepository.

@Override
public Boolean addManagedRepository(ManagedRepository managedRepository, boolean needStageRepo, AuditInformation auditInformation) throws RepositoryAdminException {
    log.debug("addManagedRepository {}, {}, {}", managedRepository.getId(), needStageRepo, auditInformation);
    getRepositoryCommonValidator().basicValidation(managedRepository, false);
    getRepositoryCommonValidator().validateManagedRepository(managedRepository);
    triggerAuditEvent(managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation);
    ManagedRepositoryConfiguration repoConfig = getRepositoryConfiguration(managedRepository);
    if (needStageRepo) {
        repoConfig.setStageRepoNeeded(true);
    }
    Configuration configuration = getArchivaConfiguration().getConfiguration();
    try {
        org.apache.archiva.repository.ManagedRepository newRepo = repositoryRegistry.putRepository(repoConfig, configuration);
        log.debug("Added new repository {}", newRepo.getId());
        org.apache.archiva.repository.ManagedRepository stagingRepo = null;
        addRepositoryRoles(newRepo.getId());
        if (newRepo.supportsFeature(StagingRepositoryFeature.class)) {
            StagingRepositoryFeature stf = newRepo.getFeature(StagingRepositoryFeature.class).get();
            stagingRepo = stf.getStagingRepository();
            if (stf.isStageRepoNeeded() && stagingRepo != null) {
                addRepositoryRoles(stagingRepo.getId());
                triggerAuditEvent(stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation);
            }
        }
        saveConfiguration(configuration);
        // scan repository when adding of repository is successful
        try {
            if (newRepo.isScanned()) {
                scanRepository(newRepo.getId(), true);
            }
            if (stagingRepo != null && stagingRepo.isScanned()) {
                scanRepository(stagingRepo.getId(), true);
            }
        } catch (Exception e) {
            log.warn("Unable to scan repository [{}]: {}", newRepo.getId(), e.getMessage(), e);
        }
    } catch (RepositoryException e) {
        log.error("Could not add managed repository {}" + managedRepository);
        throw new RepositoryAdminException("Could not add repository " + e.getMessage());
    } catch (RoleManagerException e) {
        log.error("Could not add repository roles for repository [{}]: {}", managedRepository.getId(), e.getMessage(), e);
        throw new RepositoryAdminException("Could not add roles to repository " + e.getMessage());
    }
    return Boolean.TRUE;
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RepositoryException(org.apache.archiva.repository.RepositoryException) MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) TaskQueueException(org.apache.archiva.redback.components.taskqueue.TaskQueueException) IndeterminateConfigurationException(org.apache.archiva.configuration.IndeterminateConfigurationException) RoleManagerException(org.apache.archiva.redback.role.RoleManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryException(org.apache.archiva.repository.RepositoryException) IndexUpdateFailedException(org.apache.archiva.indexer.IndexUpdateFailedException) MetadataRepositoryException(org.apache.archiva.metadata.repository.MetadataRepositoryException) RegistryException(org.apache.archiva.redback.components.registry.RegistryException) IOException(java.io.IOException) RoleManagerException(org.apache.archiva.redback.role.RoleManagerException)

Example 10 with StagingRepositoryFeature

use of org.apache.archiva.repository.features.StagingRepositoryFeature in project archiva by apache.

the class RepositoryProviderMock method getManagedConfiguration.

@Override
public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
    ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
    configuration.setId(managedRepository.getId());
    configuration.setName(managedRepository.getName());
    configuration.setLocation(managedRepository.getLocation() == null ? "" : managedRepository.getLocation().toString());
    configuration.setBlockRedeployments(managedRepository.blocksRedeployments());
    configuration.setDescription(managedRepository.getDescription());
    configuration.setLayout(managedRepository.getLayout());
    configuration.setScanned(managedRepository.isScanned());
    configuration.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
    configuration.setReleases(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
    configuration.setSnapshots(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
    ArtifactCleanupFeature acf = managedRepository.getFeature(ArtifactCleanupFeature.class).get();
    configuration.setRetentionPeriod(acf.getRetentionPeriod().getDays());
    configuration.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
    configuration.setRetentionCount(acf.getRetentionCount());
    IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class).get();
    configuration.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
    configuration.setIndexDir(icf.getIndexPath() == null ? "" : icf.getIndexPath().toString());
    StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class).get();
    configuration.setStageRepoNeeded(srf.isStageRepoNeeded());
    return configuration;
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature)

Aggregations

StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)13 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)10 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)10 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)6 RepositoryException (org.apache.archiva.repository.RepositoryException)5 IOException (java.io.IOException)3 URI (java.net.URI)3 Test (org.junit.Test)3 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)1 Configuration (org.apache.archiva.configuration.Configuration)1 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)1 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)1 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)1 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)1 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)1 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)1 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)1