This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.configuration;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022/**
023 * Class AbstractRepositoryConnectorConfiguration.
024 * 
025 * @version $Revision$ $Date$
026 */
027@SuppressWarnings( "all" )
028public class AbstractRepositoryConnectorConfiguration
029    implements java.io.Serializable
030{
031
032      //--------------------------/
033     //- Class/Member Variables -/
034    //--------------------------/
035
036    /**
037     * 
038     *             The Repository Source for this connector.
039     *           
040     */
041    private String sourceRepoId;
042
043    /**
044     * 
045     *             The Repository Target for this connector.
046     *           
047     */
048    private String targetRepoId;
049
050    /**
051     * 
052     *             The network proxy ID to use for this connector.
053     *           
054     */
055    private String proxyId;
056
057    /**
058     * Field blackListPatterns.
059     */
060    private java.util.List<String> blackListPatterns;
061
062    /**
063     * Field whiteListPatterns.
064     */
065    private java.util.List<String> whiteListPatterns;
066
067    /**
068     * Field policies.
069     */
070    private java.util.Map policies;
071
072    /**
073     * Field properties.
074     */
075    private java.util.Map properties;
076
077    /**
078     * 
079     *             If the the repository proxy connector is
080     * disabled or not
081     *           .
082     */
083    private boolean disabled = false;
084
085
086      //-----------/
087     //- Methods -/
088    //-----------/
089
090    /**
091     * Method addBlackListPattern.
092     * 
093     * @param string
094     */
095    public void addBlackListPattern( String string )
096    {
097        getBlackListPatterns().add( string );
098    } //-- void addBlackListPattern( String )
099
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}