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