1 package org.apache.archiva.repository.features;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import org.apache.commons.lang3.StringUtils;
24
25 import java.net.URI;
26 import java.net.URISyntaxException;
27 import java.time.Duration;
28
29
30
31
32 public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature> {
33
34 private boolean downloadRemoteIndex = false;
35 private URI indexUri;
36
37 {
38 try {
39 indexUri = new URI(".index");
40 } catch (URISyntaxException e) {
41
42 }
43 }
44
45 private boolean downloadRemoteIndexOnStartup = false;
46 private Duration downloadTimeout = Duration.ofSeconds( 600 );
47 private String proxyId = "";
48
49
50 @Override
51 public RemoteIndexFeature get() {
52 return this;
53 }
54
55
56
57
58
59 public boolean isDownloadRemoteIndex() {
60 return downloadRemoteIndex;
61 }
62
63 public void setDownloadRemoteIndex(boolean downloadRemoteIndex) {
64 this.downloadRemoteIndex = downloadRemoteIndex;
65 }
66
67
68
69
70
71
72
73 public URI getIndexUri() {
74 return indexUri;
75 }
76
77
78
79
80
81
82
83 public void setIndexUri(URI indexUri) {
84 this.indexUri = indexUri;
85 }
86
87
88
89
90
91 public boolean isDownloadRemoteIndexOnStartup() {
92 return downloadRemoteIndexOnStartup;
93 }
94
95
96
97
98
99
100 public void setDownloadRemoteIndexOnStartup(boolean downloadRemoteIndexOnStartup) {
101 this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup;
102 }
103
104
105
106
107
108 public Duration getDownloadTimeout() {
109 return this.downloadTimeout;
110 }
111
112
113
114
115
116 public void setDownloadTimeout(Duration timeout) {
117 this.downloadTimeout = timeout;
118 }
119
120
121
122
123
124 public String getProxyId( )
125 {
126 return proxyId;
127 }
128
129
130
131
132
133 public void setProxyId( String proxyId )
134 {
135 this.proxyId = proxyId;
136 }
137
138
139
140
141
142
143 public boolean hasIndex() {
144 return this.indexUri!=null && !StringUtils.isEmpty( this.indexUri.getPath() );
145 }
146
147 @Override
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();
154 }
155 }