use of org.apache.archiva.configuration.model.RepositoryCheckPath in project archiva by apache.
the class ConfigurationRegistryReader method readRepositoryCheckPath.
private RepositoryCheckPath readRepositoryCheckPath(String prefix, Registry registry) {
RepositoryCheckPath value = new RepositoryCheckPath();
// String url = registry.getString( prefix + "url", value.getUrl() );
List<String> urlList = registry.getList(prefix + "url");
String url = value.getUrl();
if (urlList != null && !urlList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = urlList.size(); i < size; i++) {
sb.append(urlList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
url = sb.toString();
}
value.setUrl(url);
// String path = registry.getString( prefix + "path", value.getPath() );
List<String> pathList = registry.getList(prefix + "path");
String path = value.getPath();
if (pathList != null && !pathList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = pathList.size(); i < size; i++) {
sb.append(pathList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
path = sb.toString();
}
value.setPath(path);
return value;
}
use of org.apache.archiva.configuration.model.RepositoryCheckPath 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;
}
}
}
RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
log.debug("Adding remote repo {}", remoteRepositoryConfiguration);
try {
repositoryRegistry.putRepository(remoteRepositoryConfiguration);
} 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()));
}
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.model.RepositoryCheckPath in project archiva by apache.
the class ConfigurationRegistryWriter method writeArchivaDefaultConfiguration.
private void writeArchivaDefaultConfiguration(String prefix, ArchivaDefaultConfiguration value, Registry registry) {
if (value != null) {
if (value.getDefaultCheckPaths() != null && value.getDefaultCheckPaths().size() > 0) {
registry.removeSubset(prefix + "defaultCheckPaths");
int count = 0;
for (Iterator iter = value.getDefaultCheckPaths().iterator(); iter.hasNext(); count++) {
String name = "defaultCheckPaths.defaultCheckPath(" + count + ")";
RepositoryCheckPath o = (RepositoryCheckPath) iter.next();
writeRepositoryCheckPath(prefix + name + ".", o, registry);
}
}
}
}
use of org.apache.archiva.configuration.model.RepositoryCheckPath in project archiva by apache.
the class DefaultArchivaConfiguration method readRepositoryCheckPath.
private RepositoryCheckPath readRepositoryCheckPath(Registry registry) {
RepositoryCheckPath value = new RepositoryCheckPath();
String url = registry.getString("url", value.getUrl());
value.setUrl(url);
String path = registry.getString("path", value.getPath());
value.setPath(path);
return value;
}
use of org.apache.archiva.configuration.model.RepositoryCheckPath in project archiva by apache.
the class ConfigurationRegistryReader method readArchivaDefaultConfiguration.
private ArchivaDefaultConfiguration readArchivaDefaultConfiguration(String prefix, Registry registry) {
ArchivaDefaultConfiguration value = new ArchivaDefaultConfiguration();
java.util.List defaultCheckPaths = new java.util.ArrayList();
List defaultCheckPathsSubsets = registry.getSubsetList(prefix + "defaultCheckPaths.defaultCheckPath");
for (Iterator i = defaultCheckPathsSubsets.iterator(); i.hasNext(); ) {
RepositoryCheckPath v = readRepositoryCheckPath("", (Registry) i.next());
defaultCheckPaths.add(v);
}
value.setDefaultCheckPaths(defaultCheckPaths);
return value;
}
Aggregations