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