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.lang.StringUtils;
26 import java.time.Duration;
29 * Feature for remote index download.
31 public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature> {
33 private boolean downloadRemoteIndex = false;
35 private boolean downloadRemoteIndexOnStartup = false;
36 private Duration downloadTimeout = Duration.ofSeconds( 600 );
37 private String proxyId = "";
41 public RemoteIndexFeature get() {
46 * True, if the remote index should be downloaded.
47 * @return True if download, otherwise false.
49 public boolean isDownloadRemoteIndex() {
50 return downloadRemoteIndex;
53 public void setDownloadRemoteIndex(boolean downloadRemoteIndex) {
54 this.downloadRemoteIndex = downloadRemoteIndex;
58 * The URI to access the remote index. May be a relative URI that is relative to the
63 public URI getIndexUri() {
68 * Sets the URI to access the remote index. May be a relative URI that is relative to the
69 * repository URI. The allowed URI schemes are dependent on the repository type.
71 * @param indexUri The URI of the index
73 public void setIndexUri(URI indexUri) {
74 this.indexUri = indexUri;
78 * Returns true, if the remote index should be downloaded on startup of the repository.
79 * @return true, if the index should be downloaded during startup, otherwise false.
81 public boolean isDownloadRemoteIndexOnStartup() {
82 return downloadRemoteIndexOnStartup;
86 * Sets the flag for download of the remote repository index.
88 * @param downloadRemoteIndexOnStartup
90 public void setDownloadRemoteIndexOnStartup(boolean downloadRemoteIndexOnStartup) {
91 this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup;
95 * Returns the timeout after that the remote index download is aborted.
96 * @return the time duration after that, the download is aborted.
98 public Duration getDownloadTimeout() {
99 return this.downloadTimeout;
103 * Sets the timeout after that a remote index download will be aborted.
104 * @param timeout The duration
106 public void setDownloadTimeout(Duration timeout) {
107 this.downloadTimeout = timeout;
111 * Returns the id of the proxy, that should be used to download the remote index.
112 * @return The proxy id
114 public String getProxyId( )
120 * Sets the id of the proxy that should be used to download the remote index.
123 public void setProxyId( String proxyId )
125 this.proxyId = proxyId;
129 * Returns true, if there is a index available.
133 public boolean hasIndex() {
134 return this.indexUri!=null && !StringUtils.isEmpty( this.indexUri.getPath() );