use of org.apache.archiva.configuration.IndeterminateConfigurationException in project archiva by apache.
the class DefaultManagedRepositoryAdmin method updateManagedRepository.
@Override
public Boolean updateManagedRepository(ManagedRepository managedRepository, boolean needStageRepo, AuditInformation auditInformation, boolean resetStats) throws RepositoryAdminException {
log.debug("updateManagedConfiguration repo {} needStage {} resetStats {} ", managedRepository, needStageRepo, resetStats);
// Ensure that the fields are valid.
getRepositoryCommonValidator().basicValidation(managedRepository, true);
getRepositoryCommonValidator().validateManagedRepository(managedRepository);
Configuration configuration = getArchivaConfiguration().getConfiguration();
ManagedRepositoryConfiguration updatedRepoConfig = getRepositoryConfiguration(managedRepository);
updatedRepoConfig.setStageRepoNeeded(needStageRepo);
org.apache.archiva.repository.ManagedRepository oldRepo = repositoryRegistry.getManagedRepository(managedRepository.getId());
boolean stagingExists = false;
if (oldRepo.supportsFeature(StagingRepositoryFeature.class)) {
stagingExists = oldRepo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository() != null;
}
boolean updateIndexContext = !StringUtils.equals(updatedRepoConfig.getIndexDir(), managedRepository.getIndexDirectory());
org.apache.archiva.repository.ManagedRepository newRepo;
// TODO remove content from old if path has changed !!!!!
try {
newRepo = repositoryRegistry.putRepository(updatedRepoConfig, configuration);
if (newRepo.supportsFeature(StagingRepositoryFeature.class)) {
org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository();
if (stagingRepo != null && !stagingExists) {
triggerAuditEvent(stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation);
addRepositoryRoles(stagingRepo.getId());
}
}
} catch (RepositoryException e) {
log.error("Could not update repository {}: {}", managedRepository.getId(), e.getMessage(), e);
throw new RepositoryAdminException("Could not update repository " + managedRepository.getId());
} catch (RoleManagerException e) {
log.error("Error during role update of stage repo {}", managedRepository.getId(), e);
throw new RepositoryAdminException("Could not update repository " + managedRepository.getId());
}
triggerAuditEvent(managedRepository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO, auditInformation);
try {
getArchivaConfiguration().save(configuration);
} catch (RegistryException | IndeterminateConfigurationException e) {
log.error("Could not save repository configuration: {}", e.getMessage(), e);
throw new RepositoryAdminException("Could not save repository configuration: " + e.getMessage());
}
// Save the repository configuration.
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
try {
if (resetStats) {
log.debug("call repositoryStatisticsManager.deleteStatistics");
getRepositoryStatisticsManager().deleteStatistics(repositorySession.getRepository(), managedRepository.getId());
repositorySession.save();
}
} catch (MetadataRepositoryException e) {
throw new RepositoryAdminException(e.getMessage(), e);
} finally {
repositorySession.close();
}
if (updateIndexContext) {
try {
repositoryRegistry.resetIndexingContext(newRepo);
} catch (IndexUpdateFailedException e) {
e.printStackTrace();
}
}
return true;
}
use of org.apache.archiva.configuration.IndeterminateConfigurationException in project archiva by apache.
the class DefaultArchivaRuntimeConfigurationAdmin method updateArchivaRuntimeConfiguration.
@Override
public void updateArchivaRuntimeConfiguration(ArchivaRuntimeConfiguration archivaRuntimeConfiguration) throws RepositoryAdminException {
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setArchivaRuntimeConfiguration(build(archivaRuntimeConfiguration));
try {
archivaConfiguration.save(configuration);
} catch (RegistryException e) {
throw new RepositoryAdminException(e.getMessage(), e);
} catch (IndeterminateConfigurationException e) {
throw new RepositoryAdminException(e.getMessage(), e);
}
}
use of org.apache.archiva.configuration.IndeterminateConfigurationException in project archiva by apache.
the class RepositoryRegistry method putRepository.
/**
* Adds a remote repository, or overwrites the repository definition with the same id, if it exists already.
* The modification is saved to the configuration immediately.
*
* @param remoteRepository the remote repository to add
* @throws RepositoryException if an error occurs during configuration save
*/
public RemoteRepository putRepository(RemoteRepository remoteRepository) throws RepositoryException {
rwLock.writeLock().lock();
try {
Configuration configuration = getArchivaConfiguration().getConfiguration();
try {
RemoteRepository repo = putRepository(remoteRepository, configuration);
getArchivaConfiguration().save(configuration);
return repo;
} catch (RegistryException | IndeterminateConfigurationException e) {
log.error("Error while saving remote repository {}", e.getMessage(), e);
throw new RepositoryException("Could not save the configuration" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
}
} finally {
rwLock.writeLock().unlock();
}
}
Aggregations