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