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