Search in sources :

Example 1 with RepositoryCheckPath

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;
}
Also used : RepositoryCheckPath(org.apache.archiva.configuration.model.RepositoryCheckPath)

Example 2 with RepositoryCheckPath

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;
}
Also used : RepositoryCheckPath(org.apache.archiva.configuration.model.RepositoryCheckPath) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 3 with RepositoryCheckPath

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);
            }
        }
    }
}
Also used : RepositoryCheckPath(org.apache.archiva.configuration.model.RepositoryCheckPath) Iterator(java.util.Iterator)

Example 4 with RepositoryCheckPath

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;
}
Also used : RepositoryCheckPath(org.apache.archiva.configuration.model.RepositoryCheckPath)

Example 5 with RepositoryCheckPath

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;
}
Also used : List(java.util.List) RepositoryCheckPath(org.apache.archiva.configuration.model.RepositoryCheckPath) Iterator(java.util.Iterator) List(java.util.List) ArchivaDefaultConfiguration(org.apache.archiva.configuration.model.ArchivaDefaultConfiguration)

Aggregations

RepositoryCheckPath (org.apache.archiva.configuration.model.RepositoryCheckPath)6 Iterator (java.util.Iterator)3 List (java.util.List)2 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 ArchivaDefaultConfiguration (org.apache.archiva.configuration.model.ArchivaDefaultConfiguration)1 RepositoryException (org.apache.archiva.repository.RepositoryException)1