diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-05-07 17:26:49 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-05-10 21:39:15 +0200 |
commit | 1acc6e7b8439b482e611392700f2decaef54b6e6 (patch) | |
tree | fc98db8d5433006bb83e4389f1dfc7f6ddf8ebdf /archiva-modules/archiva-base/archiva-repository-admin | |
parent | 10b408249ea9d8e2d63054ba95714e3a628ca782 (diff) | |
download | archiva-1acc6e7b8439b482e611392700f2decaef54b6e6.tar.gz archiva-1acc6e7b8439b482e611392700f2decaef54b6e6.zip |
Adding check path to remote repositories
Allow to set a check path for connection checks to the remote repositories.
This is useful for repositories that do not allow to browse the base directory.
Improved the fix for MRM-1933
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-admin')
2 files changed, 39 insertions, 1 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java index fdab2432e..fd07ce9ac 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java @@ -47,6 +47,12 @@ public class RemoteRepository private int timeout = 60; /** + * @since 2.2.3 + * The path to use for checking availability of the remote repository + */ + private String checkPath; + + /** * Activate download of remote index if remoteIndexUrl is set too. */ private boolean downloadRemoteIndex = false; @@ -316,6 +322,22 @@ public class RemoteRepository } } + public void setCheckPath(String checkPath) { + if (checkPath==null) { + this.checkPath=""; + } else if (checkPath.startsWith("/")) { + this.checkPath = StringUtils.removeStart(checkPath, "/"); + while(this.checkPath.startsWith("/")) { + this.checkPath = StringUtils.removeStart(checkPath, "/"); + } + } else { + this.checkPath = checkPath; + } + } + + public String getCheckPath() { + return checkPath; + } @Override public String toString() @@ -335,6 +357,7 @@ public class RemoteRepository sb.append( ", downloadRemoteIndexOnStartup=" ).append( downloadRemoteIndexOnStartup ); sb.append( ", extraParameters=" ).append( extraParameters ); sb.append( ", extraHeaders=" ).append( extraHeaders ); + sb.append( ", checkPath=").append(checkPath); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index 9f6a20b9d..8f390530b 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -29,6 +29,7 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.configuration.RepositoryCheckPath; import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.commons.lang.StringUtils; import org.apache.maven.index.NexusIndexer; @@ -137,6 +138,7 @@ public class DefaultRemoteRepositoryAdmin remoteRepository.setDescription( repositoryConfiguration.getDescription() ); remoteRepository.setExtraHeaders( repositoryConfiguration.getExtraHeaders() ); remoteRepository.setExtraParameters( repositoryConfiguration.getExtraParameters() ); + remoteRepository.setCheckPath(repositoryConfiguration.getCheckPath()); remoteRepositories.add( remoteRepository ); } return remoteRepositories; @@ -170,7 +172,19 @@ public class DefaultRemoteRepositoryAdmin } //MRM-752 - url needs trimming - remoteRepository.setUrl( StringUtils.trim( remoteRepository.getUrl() ) ); + //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 = getRemoteRepositoryConfiguration( remoteRepository ); @@ -365,6 +379,7 @@ public class DefaultRemoteRepositoryAdmin remoteRepositoryConfiguration.setDescription( remoteRepository.getDescription() ); remoteRepositoryConfiguration.setExtraHeaders( remoteRepository.getExtraHeaders() ); remoteRepositoryConfiguration.setExtraParameters( remoteRepository.getExtraParameters() ); + remoteRepositoryConfiguration.setCheckPath(remoteRepository.getCheckPath()); return remoteRepositoryConfiguration; } |