1 package org.apache.archiva.repository.features;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 import org.apache.commons.lang3.StringUtils;
26 import java.net.URISyntaxException;
27 import java.time.Duration;
30 * Feature for remote index download.
32 public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature> {
34 private boolean downloadRemoteIndex = false;
39 indexUri = new URI(".index");
40 } catch (URISyntaxException e) {
45 private boolean downloadRemoteIndexOnStartup = false;
46 private Duration downloadTimeout = Duration.ofSeconds( 600 );
47 private String proxyId = "";
51 public RemoteIndexFeature get() {
56 * True, if the remote index should be downloaded.
57 * @return True if download, otherwise false.
59 public boolean isDownloadRemoteIndex() {
60 return downloadRemoteIndex;
63 public void setDownloadRemoteIndex(boolean downloadRemoteIndex) {
64 this.downloadRemoteIndex = downloadRemoteIndex;
68 * The URI to access the remote index. May be a relative URI that is relative to the
73 public URI getIndexUri() {
78 * Sets the URI to access the remote index. May be a relative URI that is relative to the
79 * repository URI. The allowed URI schemes are dependent on the repository type.
81 * @param indexUri The URI of the index
83 public void setIndexUri(URI indexUri) {
84 this.indexUri = indexUri;
88 * Returns true, if the remote index should be downloaded on startup of the repository.
89 * @return true, if the index should be downloaded during startup, otherwise false.
91 public boolean isDownloadRemoteIndexOnStartup() {
92 return downloadRemoteIndexOnStartup;
96 * Sets the flag for download of the remote repository index.
98 * @param downloadRemoteIndexOnStartup
100 public void setDownloadRemoteIndexOnStartup(boolean downloadRemoteIndexOnStartup) {
101 this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup;
105 * Returns the timeout after that the remote index download is aborted.
106 * @return the time duration after that, the download is aborted.
108 public Duration getDownloadTimeout() {
109 return this.downloadTimeout;
113 * Sets the timeout after that a remote index download will be aborted.
114 * @param timeout The duration
116 public void setDownloadTimeout(Duration timeout) {
117 this.downloadTimeout = timeout;
121 * Returns the id of the proxy, that should be used to download the remote index.
122 * @return The proxy id
124 public String getProxyId( )
130 * Sets the id of the proxy that should be used to download the remote index.
133 public void setProxyId( String proxyId )
135 this.proxyId = proxyId;
139 * Returns true, if there is a index available.
143 public boolean hasIndex() {
144 return this.indexUri!=null && !StringUtils.isEmpty( this.indexUri.getPath() );
148 public String toString() {
149 StringBuilder str = new StringBuilder();
150 return str.append("RemoteIndexFeature:{downloadRemoteIndex=").append(downloadRemoteIndex)
151 .append(",indexURI=").append(indexUri)
152 .append(",downloadOnStartup=").append(downloadRemoteIndexOnStartup)
153 .append(",timeout=").append(downloadTimeout).append("}").toString();