1 package org.apache.archiva.configuration;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 /**
23 * Class AbstractRepositoryConnectorConfiguration.
24 *
25 * @version $Revision$ $Date$
26 */
27 @SuppressWarnings( "all" )
28 public class AbstractRepositoryConnectorConfiguration
29 implements java.io.Serializable
30 {
31
32 //--------------------------/
33 //- Class/Member Variables -/
34 //--------------------------/
35
36 /**
37 *
38 * The Repository Source for this connector.
39 *
40 */
41 private String sourceRepoId;
42
43 /**
44 *
45 * The Repository Target for this connector.
46 *
47 */
48 private String targetRepoId;
49
50 /**
51 *
52 * The network proxy ID to use for this connector.
53 *
54 */
55 private String proxyId;
56
57 /**
58 * Field blackListPatterns.
59 */
60 private java.util.List<String> blackListPatterns;
61
62 /**
63 * Field whiteListPatterns.
64 */
65 private java.util.List<String> whiteListPatterns;
66
67 /**
68 * Field policies.
69 */
70 private java.util.Map policies;
71
72 /**
73 * Field properties.
74 */
75 private java.util.Map properties;
76
77 /**
78 *
79 * If the the repository proxy connector is
80 * disabled or not
81 * .
82 */
83 private boolean disabled = false;
84
85
86 //-----------/
87 //- Methods -/
88 //-----------/
89
90 /**
91 * Method addBlackListPattern.
92 *
93 * @param string
94 */
95 public void addBlackListPattern( String string )
96 {
97 getBlackListPatterns().add( string );
98 } //-- void addBlackListPattern( String )
99
100 /**
101 * Method addPolicy.
102 *
103 * @param key
104 * @param value
105 */
106 public void addPolicy( String key, String value )
107 {
108 getPolicies().put( key, value );
109 } //-- void addPolicy( Object, String )
110
111 /**
112 * Method addProperty.
113 *
114 * @param key
115 * @param value
116 */
117 public void addProperty( String key, String value )
118 {
119 getProperties().put( key, value );
120 } //-- void addProperty( Object, String )
121
122 /**
123 * Method addWhiteListPattern.
124 *
125 * @param string
126 */
127 public void addWhiteListPattern( String string )
128 {
129 getWhiteListPatterns().add( string );
130 } //-- void addWhiteListPattern( String )
131
132 /**
133 * Method getBlackListPatterns.
134 *
135 * @return List
136 */
137 public java.util.List<String> getBlackListPatterns()
138 {
139 if ( this.blackListPatterns == null )
140 {
141 this.blackListPatterns = new java.util.ArrayList<String>();
142 }
143
144 return this.blackListPatterns;
145 } //-- java.util.List<String> getBlackListPatterns()
146
147 /**
148 * Method getPolicies.
149 *
150 * @return Map
151 */
152 public java.util.Map<String, String> getPolicies()
153 {
154 if ( this.policies == null )
155 {
156 this.policies = new java.util.HashMap();
157 }
158
159 return this.policies;
160 } //-- java.util.Map getPolicies()
161
162 /**
163 * Method getProperties.
164 *
165 * @return Map
166 */
167 public java.util.Map<String, String> getProperties()
168 {
169 if ( this.properties == null )
170 {
171 this.properties = new java.util.HashMap();
172 }
173
174 return this.properties;
175 } //-- java.util.Map getProperties()
176
177 /**
178 * Get the network proxy ID to use for this connector.
179 *
180 * @return String
181 */
182 public String getProxyId()
183 {
184 return this.proxyId;
185 } //-- String getProxyId()
186
187 /**
188 * Get the Repository Source for this connector.
189 *
190 * @return String
191 */
192 public String getSourceRepoId()
193 {
194 return this.sourceRepoId;
195 } //-- String getSourceRepoId()
196
197 /**
198 * Get the Repository Target for this connector.
199 *
200 * @return String
201 */
202 public String getTargetRepoId()
203 {
204 return this.targetRepoId;
205 } //-- String getTargetRepoId()
206
207 /**
208 * Method getWhiteListPatterns.
209 *
210 * @return List
211 */
212 public java.util.List<String> getWhiteListPatterns()
213 {
214 if ( this.whiteListPatterns == null )
215 {
216 this.whiteListPatterns = new java.util.ArrayList<String>();
217 }
218
219 return this.whiteListPatterns;
220 } //-- java.util.List<String> getWhiteListPatterns()
221
222 /**
223 * Get if the the repository proxy connector is disabled or
224 * not.
225 *
226 * @return boolean
227 */
228 public boolean isDisabled()
229 {
230 return this.disabled;
231 } //-- boolean isDisabled()
232
233 /**
234 * Method removeBlackListPattern.
235 *
236 * @param string
237 */
238 public void removeBlackListPattern( String string )
239 {
240 getBlackListPatterns().remove( string );
241 } //-- void removeBlackListPattern( String )
242
243 /**
244 * Method removeWhiteListPattern.
245 *
246 * @param string
247 */
248 public void removeWhiteListPattern( String string )
249 {
250 getWhiteListPatterns().remove( string );
251 } //-- void removeWhiteListPattern( String )
252
253 /**
254 * Set the list of blacklisted patterns for this connector.
255 *
256 * @param blackListPatterns
257 */
258 public void setBlackListPatterns( java.util.List<String> blackListPatterns )
259 {
260 this.blackListPatterns = blackListPatterns;
261 } //-- void setBlackListPatterns( java.util.List )
262
263 /**
264 * Set if the the repository proxy connector is disabled or
265 * not.
266 *
267 * @param disabled
268 */
269 public void setDisabled( boolean disabled )
270 {
271 this.disabled = disabled;
272 } //-- void setDisabled( boolean )
273
274 /**
275 * Set policy configuration for the connector.
276 *
277 * @param policies
278 */
279 public void setPolicies( java.util.Map policies )
280 {
281 this.policies = policies;
282 } //-- void setPolicies( java.util.Map )
283
284 /**
285 * Set configuration for the connector.
286 *
287 * @param properties
288 */
289 public void setProperties( java.util.Map properties )
290 {
291 this.properties = properties;
292 } //-- void setProperties( java.util.Map )
293
294 /**
295 * Set the network proxy ID to use for this connector.
296 *
297 * @param proxyId
298 */
299 public void setProxyId( String proxyId )
300 {
301 this.proxyId = proxyId;
302 } //-- void setProxyId( String )
303
304 /**
305 * Set the Repository Source for this connector.
306 *
307 * @param sourceRepoId
308 */
309 public void setSourceRepoId( String sourceRepoId )
310 {
311 this.sourceRepoId = sourceRepoId;
312 } //-- void setSourceRepoId( String )
313
314 /**
315 * Set the Repository Target for this connector.
316 *
317 * @param targetRepoId
318 */
319 public void setTargetRepoId( String targetRepoId )
320 {
321 this.targetRepoId = targetRepoId;
322 } //-- void setTargetRepoId( String )
323
324 /**
325 * Set the list of whitelisted patterns for this connector.
326 *
327 * @param whiteListPatterns
328 */
329 public void setWhiteListPatterns( java.util.List<String> whiteListPatterns )
330 {
331 this.whiteListPatterns = whiteListPatterns;
332 } //-- void setWhiteListPatterns( java.util.List )
333
334
335 /**
336 * Obtain a specific policy from the underlying connector.
337 *
338 * @param policyId the policy id to fetch.
339 * @param defaultValue the default value for the policy id.
340 * @return the configured policy value (or default value if not found).
341 */
342 public String getPolicy( String policyId, String defaultValue )
343 {
344 if ( this.getPolicies() == null )
345 {
346 return null;
347 }
348
349 Object value = this.getPolicies().get( policyId );
350
351 if ( value == null )
352 {
353 return defaultValue;
354 }
355
356 return (String) value;
357 }
358
359 }