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