use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRemoteRepositoryAdmin method updateRemoteRepository.
@Override
public Boolean updateRemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository, AuditInformation auditInformation) throws RepositoryAdminException {
String repositoryId = remoteRepository.getId();
triggerAuditEvent(repositoryId, null, AuditEvent.MODIFY_REMOTE_REPO, auditInformation);
// update means : remove and add
Configuration configuration = getArchivaConfiguration().getConfiguration();
RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
try {
repositoryRegistry.putRepository(remoteRepositoryConfiguration, configuration);
} catch (RepositoryException e) {
log.error("Could not update remote repository {}: {}", remoteRepositoryConfiguration.getId(), e.getMessage(), e);
throw new RepositoryAdminException("Update of remote repository failed" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
}
saveConfiguration(configuration);
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRemoteRepositoryAdmin method addRemoteRepository.
@Override
public Boolean addRemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository, AuditInformation auditInformation) throws RepositoryAdminException {
triggerAuditEvent(remoteRepository.getId(), null, AuditEvent.ADD_REMOTE_REPO, auditInformation);
getRepositoryCommonValidator().basicValidation(remoteRepository, false);
// TODO we can validate it's a good uri/url
if (StringUtils.isEmpty(remoteRepository.getUrl())) {
throw new RepositoryAdminException("url cannot be null");
}
// MRM-752 - url needs trimming
// MRM-1940 - URL should not end with a slash
remoteRepository.setUrl(StringUtils.stripEnd(StringUtils.trim(remoteRepository.getUrl()), "/"));
if (StringUtils.isEmpty(remoteRepository.getCheckPath())) {
String checkUrl = remoteRepository.getUrl().toLowerCase();
for (RepositoryCheckPath path : getArchivaConfiguration().getConfiguration().getArchivaDefaultConfiguration().getDefaultCheckPaths()) {
log.debug("Checking path for urls: {} <-> {}", checkUrl, path.getUrl());
if (checkUrl.startsWith(path.getUrl())) {
remoteRepository.setCheckPath(path.getPath());
break;
}
}
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
log.debug("Adding remote repo {}", remoteRepositoryConfiguration);
try {
repositoryRegistry.putRepository(remoteRepositoryConfiguration, configuration);
} catch (RepositoryException e) {
log.error("Could not add remote repository {}: {}", remoteRepositoryConfiguration.getId(), e.getMessage(), e);
throw new RepositoryAdminException("Adding of remote repository failed" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
}
saveConfiguration(configuration);
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultRedbackRuntimeConfigurationAdmin method updateRedbackRuntimeConfiguration.
@Override
public void updateRedbackRuntimeConfiguration(RedbackRuntimeConfiguration redbackRuntimeConfiguration) throws RepositoryAdminException {
org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration = build(redbackRuntimeConfiguration);
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setRedbackRuntimeConfiguration(runtimeConfiguration);
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.Configuration in project archiva by apache.
the class DefaultRepositoryCommonValidator method basicValidation.
/**
* @param abstractRepository
* @param update in update mode if yes already exists won't be check
* @throws RepositoryAdminException
*/
@Override
public void basicValidation(AbstractRepository abstractRepository, boolean update) throws RepositoryAdminException {
Configuration config = archivaConfiguration.getConfiguration();
String repoId = abstractRepository.getId();
if (!update) {
if (config.getManagedRepositoriesAsMap().containsKey(repoId)) {
throw new RepositoryAdminException("Unable to add new repository with id [" + repoId + "], that id already exists as a managed repository.");
} else if (config.getRepositoryGroupsAsMap().containsKey(repoId)) {
throw new RepositoryAdminException("Unable to add new repository with id [" + repoId + "], that id already exists as a repository group.");
} else if (config.getRemoteRepositoriesAsMap().containsKey(repoId)) {
throw new RepositoryAdminException("Unable to add new repository with id [" + repoId + "], that id already exists as a remote repository.");
}
}
if (StringUtils.isBlank(repoId)) {
throw new RepositoryAdminException("Repository ID cannot be empty.");
}
if (!GenericValidator.matchRegexp(repoId, REPOSITORY_ID_VALID_EXPRESSION)) {
throw new RepositoryAdminException("Invalid repository ID. Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
}
String name = abstractRepository.getName();
if (StringUtils.isBlank(name)) {
throw new RepositoryAdminException("repository name cannot be empty");
}
if (!GenericValidator.matchRegexp(name, REPOSITORY_NAME_VALID_EXPRESSION)) {
throw new RepositoryAdminException("Invalid repository name. Repository Name must only contain alphanumeric characters, white-spaces(' '), " + "forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-).");
}
}
use of org.apache.archiva.configuration.Configuration in project archiva by apache.
the class DefaultProxyConnectorAdmin method deleteProxyConnector.
// FIXME take care of proxyConnectorRules !
@Override
public Boolean deleteProxyConnector(ProxyConnector proxyConnector, AuditInformation auditInformation) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
ProxyConnectorConfiguration proxyConnectorConfiguration = findProxyConnector(proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration);
if (proxyConnectorConfiguration == null) {
throw new RepositoryAdminException("unable to find ProxyConnector with source " + proxyConnector.getSourceRepoId() + " and target " + proxyConnector.getTargetRepoId());
}
configuration.removeProxyConnector(proxyConnectorConfiguration);
saveConfiguration(configuration);
triggerAuditEvent(proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null, AuditEvent.DELETE_PROXY_CONNECTOR, auditInformation);
return Boolean.TRUE;
}
Aggregations