1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.repository;
20
21 import java.io.File;
22 import java.util.Collections;
23 import java.util.List;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.artifact.metadata.ArtifactMetadata;
27 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
28 import org.apache.maven.repository.Proxy;
29 import org.apache.maven.wagon.repository.Repository;
30
31
32
33
34
35
36
37 @Deprecated
38 public class DefaultArtifactRepository extends Repository implements ArtifactRepository {
39 private ArtifactRepositoryLayout layout;
40
41 private ArtifactRepositoryPolicy snapshots;
42
43 private ArtifactRepositoryPolicy releases;
44
45 private boolean blacklisted;
46
47 private Authentication authentication;
48
49 private Proxy proxy;
50
51 private List<ArtifactRepository> mirroredRepositories = Collections.emptyList();
52
53 private boolean blocked;
54
55
56
57
58
59
60
61
62 public DefaultArtifactRepository(String id, String url, ArtifactRepositoryLayout layout) {
63 this(id, url, layout, null, null);
64 }
65
66
67
68
69
70
71
72
73
74 public DefaultArtifactRepository(String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion) {
75 super(id, url);
76 this.layout = layout;
77 }
78
79
80
81
82
83
84
85
86
87
88 public DefaultArtifactRepository(
89 String id,
90 String url,
91 ArtifactRepositoryLayout layout,
92 ArtifactRepositoryPolicy snapshots,
93 ArtifactRepositoryPolicy releases) {
94 super(id, url);
95
96 this.layout = layout;
97
98 if (snapshots == null) {
99 snapshots = new ArtifactRepositoryPolicy(
100 true,
101 ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
102 ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE);
103 }
104
105 this.snapshots = snapshots;
106
107 if (releases == null) {
108 releases = new ArtifactRepositoryPolicy(
109 true,
110 ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
111 ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE);
112 }
113
114 this.releases = releases;
115 }
116
117 public String pathOf(Artifact artifact) {
118 return layout.pathOf(artifact);
119 }
120
121 public String pathOfRemoteRepositoryMetadata(ArtifactMetadata artifactMetadata) {
122 return layout.pathOfRemoteRepositoryMetadata(artifactMetadata);
123 }
124
125 public String pathOfLocalRepositoryMetadata(ArtifactMetadata metadata, ArtifactRepository repository) {
126 return layout.pathOfLocalRepositoryMetadata(metadata, repository);
127 }
128
129 public void setLayout(ArtifactRepositoryLayout layout) {
130 this.layout = layout;
131 }
132
133 public ArtifactRepositoryLayout getLayout() {
134 return layout;
135 }
136
137 public void setSnapshotUpdatePolicy(ArtifactRepositoryPolicy snapshots) {
138 this.snapshots = snapshots;
139 }
140
141 public ArtifactRepositoryPolicy getSnapshots() {
142 return snapshots;
143 }
144
145 public void setReleaseUpdatePolicy(ArtifactRepositoryPolicy releases) {
146 this.releases = releases;
147 }
148
149 public ArtifactRepositoryPolicy getReleases() {
150 return releases;
151 }
152
153 public String getKey() {
154 return getId();
155 }
156
157 public boolean isBlacklisted() {
158 return blacklisted;
159 }
160
161 public void setBlacklisted(boolean blacklisted) {
162 this.blacklisted = blacklisted;
163 }
164
165 public String toString() {
166 StringBuilder sb = new StringBuilder(256);
167
168 sb.append(" id: ").append(getId()).append('\n');
169 sb.append(" url: ").append(getUrl()).append('\n');
170 sb.append(" layout: ").append(layout != null ? layout : "none").append('\n');
171
172 if (snapshots != null) {
173 sb.append("snapshots: [enabled => ").append(snapshots.isEnabled());
174 sb.append(", update => ").append(snapshots.getUpdatePolicy()).append("]\n");
175 }
176
177 if (releases != null) {
178 sb.append(" releases: [enabled => ").append(releases.isEnabled());
179 sb.append(", update => ").append(releases.getUpdatePolicy()).append("]\n");
180 }
181
182 return sb.toString();
183 }
184
185 public Artifact find(Artifact artifact) {
186 File artifactFile = new File(getBasedir(), pathOf(artifact));
187
188
189
190 artifact.setFile(artifactFile);
191
192 if (artifactFile.exists()) {
193 artifact.setResolved(true);
194 }
195
196 return artifact;
197 }
198
199 public List<String> findVersions(Artifact artifact) {
200 return Collections.emptyList();
201 }
202
203 public boolean isProjectAware() {
204 return false;
205 }
206
207 public Authentication getAuthentication() {
208 return authentication;
209 }
210
211 public void setAuthentication(Authentication authentication) {
212 this.authentication = authentication;
213 }
214
215 public Proxy getProxy() {
216 return proxy;
217 }
218
219 public void setProxy(Proxy proxy) {
220 this.proxy = proxy;
221 }
222
223 public boolean isUniqueVersion() {
224 return true;
225 }
226
227 public List<ArtifactRepository> getMirroredRepositories() {
228 return mirroredRepositories;
229 }
230
231 public void setMirroredRepositories(List<ArtifactRepository> mirroredRepositories) {
232 if (mirroredRepositories != null) {
233 this.mirroredRepositories = Collections.unmodifiableList(mirroredRepositories);
234 } else {
235 this.mirroredRepositories = Collections.emptyList();
236 }
237 }
238
239 public boolean isBlocked() {
240 return blocked;
241 }
242
243 public void setBlocked(boolean blocked) {
244 this.blocked = blocked;
245 }
246 }