Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractRepositoryConnectorConfiguration |
|
| 0.0;0 |
1 | /* | |
2 | * $Id$ | |
3 | */ | |
4 | ||
5 | package org.apache.maven.archiva.configuration; | |
6 | ||
7 | //---------------------------------/ | |
8 | //- Imported classes and packages -/ | |
9 | //---------------------------------/ | |
10 | ||
11 | import java.util.Date; | |
12 | ||
13 | /** | |
14 | * Class AbstractRepositoryConnectorConfiguration. | |
15 | * | |
16 | * @version $Revision$ $Date$ | |
17 | */ | |
18 | 0 | public class AbstractRepositoryConnectorConfiguration |
19 | implements java.io.Serializable | |
20 | { | |
21 | ||
22 | //--------------------------/ | |
23 | //- Class/Member Variables -/ | |
24 | //--------------------------/ | |
25 | ||
26 | /** | |
27 | * | |
28 | * The Repository Source for this connector. | |
29 | * | |
30 | */ | |
31 | private String sourceRepoId; | |
32 | ||
33 | /** | |
34 | * | |
35 | * The Repository Target for this connector. | |
36 | * | |
37 | */ | |
38 | private String targetRepoId; | |
39 | ||
40 | /** | |
41 | * | |
42 | * The network proxy ID to use for this connector. | |
43 | * | |
44 | */ | |
45 | private String proxyId; | |
46 | ||
47 | /** | |
48 | * Field blackListPatterns. | |
49 | */ | |
50 | private java.util.List<String> blackListPatterns; | |
51 | ||
52 | /** | |
53 | * Field whiteListPatterns. | |
54 | */ | |
55 | private java.util.List<String> whiteListPatterns; | |
56 | ||
57 | /** | |
58 | * Field policies. | |
59 | */ | |
60 | private java.util.Map policies; | |
61 | ||
62 | /** | |
63 | * Field properties. | |
64 | */ | |
65 | private java.util.Map properties; | |
66 | ||
67 | /** | |
68 | * | |
69 | * If the the repository proxy connector is | |
70 | * disabled or not | |
71 | * . | |
72 | */ | |
73 | 0 | private boolean disabled = false; |
74 | ||
75 | ||
76 | //-----------/ | |
77 | //- Methods -/ | |
78 | //-----------/ | |
79 | ||
80 | /** | |
81 | * Method addBlackListPattern. | |
82 | * | |
83 | * @param string | |
84 | */ | |
85 | public void addBlackListPattern( String string ) | |
86 | { | |
87 | 0 | if ( !(string instanceof String) ) |
88 | { | |
89 | 0 | throw new ClassCastException( "AbstractRepositoryConnectorConfiguration.addBlackListPatterns(string) parameter must be instanceof " + String.class.getName() ); |
90 | } | |
91 | 0 | getBlackListPatterns().add( string ); |
92 | 0 | } //-- void addBlackListPattern( String ) |
93 | ||
94 | /** | |
95 | * Method addPolicy. | |
96 | * | |
97 | * @param key | |
98 | * @param value | |
99 | */ | |
100 | public void addPolicy( Object key, String value ) | |
101 | { | |
102 | 0 | getPolicies().put( key, value ); |
103 | 0 | } //-- void addPolicy( Object, String ) |
104 | ||
105 | /** | |
106 | * Method addProperty. | |
107 | * | |
108 | * @param key | |
109 | * @param value | |
110 | */ | |
111 | public void addProperty( Object key, String value ) | |
112 | { | |
113 | 0 | getProperties().put( key, value ); |
114 | 0 | } //-- void addProperty( Object, String ) |
115 | ||
116 | /** | |
117 | * Method addWhiteListPattern. | |
118 | * | |
119 | * @param string | |
120 | */ | |
121 | public void addWhiteListPattern( String string ) | |
122 | { | |
123 | 0 | if ( !(string instanceof String) ) |
124 | { | |
125 | 0 | throw new ClassCastException( "AbstractRepositoryConnectorConfiguration.addWhiteListPatterns(string) parameter must be instanceof " + String.class.getName() ); |
126 | } | |
127 | 0 | getWhiteListPatterns().add( string ); |
128 | 0 | } //-- void addWhiteListPattern( String ) |
129 | ||
130 | /** | |
131 | * Method getBlackListPatterns. | |
132 | * | |
133 | * @return List | |
134 | */ | |
135 | public java.util.List<String> getBlackListPatterns() | |
136 | { | |
137 | 0 | if ( this.blackListPatterns == null ) |
138 | { | |
139 | 0 | this.blackListPatterns = new java.util.ArrayList<String>(); |
140 | } | |
141 | ||
142 | 0 | return this.blackListPatterns; |
143 | } //-- java.util.List<String> getBlackListPatterns() | |
144 | ||
145 | /** | |
146 | * Method getPolicies. | |
147 | * | |
148 | * @return Map | |
149 | */ | |
150 | public java.util.Map getPolicies() | |
151 | { | |
152 | 0 | if ( this.policies == null ) |
153 | { | |
154 | 0 | this.policies = new java.util.HashMap(); |
155 | } | |
156 | ||
157 | 0 | return this.policies; |
158 | } //-- java.util.Map getPolicies() | |
159 | ||
160 | /** | |
161 | * Method getProperties. | |
162 | * | |
163 | * @return Map | |
164 | */ | |
165 | public java.util.Map getProperties() | |
166 | { | |
167 | 0 | if ( this.properties == null ) |
168 | { | |
169 | 0 | this.properties = new java.util.HashMap(); |
170 | } | |
171 | ||
172 | 0 | return this.properties; |
173 | } //-- java.util.Map getProperties() | |
174 | ||
175 | /** | |
176 | * Get | |
177 | * The network proxy ID to use for this connector. | |
178 | * | |
179 | * | |
180 | * @return String | |
181 | */ | |
182 | public String getProxyId() | |
183 | { | |
184 | 0 | return this.proxyId; |
185 | } //-- String getProxyId() | |
186 | ||
187 | /** | |
188 | * Get | |
189 | * The Repository Source for this connector. | |
190 | * | |
191 | * | |
192 | * @return String | |
193 | */ | |
194 | public String getSourceRepoId() | |
195 | { | |
196 | 0 | return this.sourceRepoId; |
197 | } //-- String getSourceRepoId() | |
198 | ||
199 | /** | |
200 | * Get | |
201 | * The Repository Target for this connector. | |
202 | * | |
203 | * | |
204 | * @return String | |
205 | */ | |
206 | public String getTargetRepoId() | |
207 | { | |
208 | 0 | return this.targetRepoId; |
209 | } //-- String getTargetRepoId() | |
210 | ||
211 | /** | |
212 | * Method getWhiteListPatterns. | |
213 | * | |
214 | * @return List | |
215 | */ | |
216 | public java.util.List<String> getWhiteListPatterns() | |
217 | { | |
218 | 0 | if ( this.whiteListPatterns == null ) |
219 | { | |
220 | 0 | this.whiteListPatterns = new java.util.ArrayList<String>(); |
221 | } | |
222 | ||
223 | 0 | return this.whiteListPatterns; |
224 | } //-- java.util.List<String> getWhiteListPatterns() | |
225 | ||
226 | /** | |
227 | * Get | |
228 | * If the the repository proxy connector is | |
229 | * disabled or not | |
230 | * . | |
231 | * | |
232 | * @return boolean | |
233 | */ | |
234 | public boolean isDisabled() | |
235 | { | |
236 | 0 | return this.disabled; |
237 | } //-- boolean isDisabled() | |
238 | ||
239 | /** | |
240 | * Method removeBlackListPattern. | |
241 | * | |
242 | * @param string | |
243 | */ | |
244 | public void removeBlackListPattern( String string ) | |
245 | { | |
246 | 0 | if ( !(string instanceof String) ) |
247 | { | |
248 | 0 | throw new ClassCastException( "AbstractRepositoryConnectorConfiguration.removeBlackListPatterns(string) parameter must be instanceof " + String.class.getName() ); |
249 | } | |
250 | 0 | getBlackListPatterns().remove( string ); |
251 | 0 | } //-- void removeBlackListPattern( String ) |
252 | ||
253 | /** | |
254 | * Method removeWhiteListPattern. | |
255 | * | |
256 | * @param string | |
257 | */ | |
258 | public void removeWhiteListPattern( String string ) | |
259 | { | |
260 | 0 | if ( !(string instanceof String) ) |
261 | { | |
262 | 0 | throw new ClassCastException( "AbstractRepositoryConnectorConfiguration.removeWhiteListPatterns(string) parameter must be instanceof " + String.class.getName() ); |
263 | } | |
264 | 0 | getWhiteListPatterns().remove( string ); |
265 | 0 | } //-- void removeWhiteListPattern( String ) |
266 | ||
267 | /** | |
268 | * Set | |
269 | * The list of blacklisted patterns for this | |
270 | * connector. | |
271 | * | |
272 | * | |
273 | * @param blackListPatterns | |
274 | */ | |
275 | public void setBlackListPatterns( java.util.List<String> blackListPatterns ) | |
276 | { | |
277 | 0 | this.blackListPatterns = blackListPatterns; |
278 | 0 | } //-- void setBlackListPatterns( java.util.List ) |
279 | ||
280 | /** | |
281 | * Set | |
282 | * If the the repository proxy connector is | |
283 | * disabled or not | |
284 | * . | |
285 | * | |
286 | * @param disabled | |
287 | */ | |
288 | public void setDisabled( boolean disabled ) | |
289 | { | |
290 | 0 | this.disabled = disabled; |
291 | 0 | } //-- void setDisabled( boolean ) |
292 | ||
293 | /** | |
294 | * Set policy configuration for the connector. | |
295 | * | |
296 | * @param policies | |
297 | */ | |
298 | public void setPolicies( java.util.Map policies ) | |
299 | { | |
300 | 0 | this.policies = policies; |
301 | 0 | } //-- void setPolicies( java.util.Map ) |
302 | ||
303 | /** | |
304 | * Set configuration for the connector. | |
305 | * | |
306 | * @param properties | |
307 | */ | |
308 | public void setProperties( java.util.Map properties ) | |
309 | { | |
310 | 0 | this.properties = properties; |
311 | 0 | } //-- void setProperties( java.util.Map ) |
312 | ||
313 | /** | |
314 | * Set | |
315 | * The network proxy ID to use for this connector. | |
316 | * | |
317 | * | |
318 | * @param proxyId | |
319 | */ | |
320 | public void setProxyId( String proxyId ) | |
321 | { | |
322 | 0 | this.proxyId = proxyId; |
323 | 0 | } //-- void setProxyId( String ) |
324 | ||
325 | /** | |
326 | * Set | |
327 | * The Repository Source for this connector. | |
328 | * | |
329 | * | |
330 | * @param sourceRepoId | |
331 | */ | |
332 | public void setSourceRepoId( String sourceRepoId ) | |
333 | { | |
334 | 0 | this.sourceRepoId = sourceRepoId; |
335 | 0 | } //-- void setSourceRepoId( String ) |
336 | ||
337 | /** | |
338 | * Set | |
339 | * The Repository Target for this connector. | |
340 | * | |
341 | * | |
342 | * @param targetRepoId | |
343 | */ | |
344 | public void setTargetRepoId( String targetRepoId ) | |
345 | { | |
346 | 0 | this.targetRepoId = targetRepoId; |
347 | 0 | } //-- void setTargetRepoId( String ) |
348 | ||
349 | /** | |
350 | * Set | |
351 | * The list of whitelisted patterns for this | |
352 | * connector. | |
353 | * | |
354 | * | |
355 | * @param whiteListPatterns | |
356 | */ | |
357 | public void setWhiteListPatterns( java.util.List<String> whiteListPatterns ) | |
358 | { | |
359 | 0 | this.whiteListPatterns = whiteListPatterns; |
360 | 0 | } //-- void setWhiteListPatterns( java.util.List ) |
361 | ||
362 | ||
363 | /** | |
364 | * Obtain a specific policy from the underlying connector. | |
365 | * | |
366 | * @param policyId the policy id to fetch. | |
367 | * @param defaultValue the default value for the policy id. | |
368 | * @return the configured policy value (or default value if not found). | |
369 | */ | |
370 | public String getPolicy( String policyId, String defaultValue ) | |
371 | { | |
372 | 0 | if ( this.getPolicies() == null ) |
373 | { | |
374 | 0 | return null; |
375 | } | |
376 | ||
377 | 0 | Object value = this.getPolicies().get( policyId ); |
378 | ||
379 | 0 | if ( value == null ) |
380 | { | |
381 | 0 | return defaultValue; |
382 | } | |
383 | ||
384 | 0 | return (String) value; |
385 | } | |
386 | ||
387 | } |