1 package org.apache.archiva.admin.repository;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
28 * @author Olivier Lamy
31 public abstract class AbstractRepositoryConnector
32 implements Serializable
35 * The Repository Source for this connector.
37 private String sourceRepoId;
40 * The Repository Target for this connector.
42 private String targetRepoId;
45 * The network proxy ID to use for this connector.
47 private String proxyId;
50 * Field blackListPatterns.
52 private List<String> blackListPatterns;
55 * Field whiteListPatterns.
57 private List<String> whiteListPatterns;
62 private Map<String, String> policies;
67 private Map<String, String> properties;
70 * If the the repository proxy connector is disabled or not
72 private boolean disabled = false;
79 * Method addBlackListPattern.
83 public void addBlackListPattern( String string )
85 getBlackListPatterns().add( string );
94 public void addPolicy( String key, String value )
96 getPolicies().put( key, value );
100 * Method addProperty.
105 public void addProperty( String key, String value )
107 getProperties().put( key, value );
111 * Method addWhiteListPattern.
115 public void addWhiteListPattern( String string )
117 getWhiteListPatterns().add( string );
121 * Method getBlackListPatterns.
125 public List<String> getBlackListPatterns()
127 if ( this.blackListPatterns == null )
129 this.blackListPatterns = new ArrayList<String>();
132 return this.blackListPatterns;
136 * Method getPolicies.
140 public Map<String, String> getPolicies()
142 if ( this.policies == null )
144 this.policies = new HashMap<String, String>();
147 return this.policies;
151 * Method getProperties.
155 public Map<String, String> getProperties()
157 if ( this.properties == null )
159 this.properties = new HashMap<String, String>();
162 return this.properties;
166 * Get the network proxy ID to use for this connector.
170 public String getProxyId()
176 * Get the Repository Source for this connector.
180 public String getSourceRepoId()
182 return this.sourceRepoId;
186 * Get the Repository Target for this connector.
190 public String getTargetRepoId()
192 return this.targetRepoId;
196 * Method getWhiteListPatterns.
200 public List<String> getWhiteListPatterns()
202 if ( this.whiteListPatterns == null )
204 this.whiteListPatterns = new ArrayList<String>();
207 return this.whiteListPatterns;
211 * Get if the the repository proxy connector is disabled or not
216 public boolean isDisabled()
218 return this.disabled;
222 * Method removeBlackListPattern.
226 public void removeBlackListPattern( String string )
228 getBlackListPatterns().remove( string );
232 * Method removeWhiteListPattern.
236 public void removeWhiteListPattern( String string )
238 getWhiteListPatterns().remove( string );
242 * Set the list of blacklisted patterns for this connector.
244 * @param blackListPatterns
246 public void setBlackListPatterns( List<String> blackListPatterns )
248 this.blackListPatterns = blackListPatterns;
252 * Set if the the repository proxy connector is
258 public void setDisabled( boolean disabled )
260 this.disabled = disabled;
264 * Set policy configuration for the connector.
268 public void setPolicies( Map<String, String> policies )
270 this.policies = policies;
274 * Set configuration for the connector.
278 public void setProperties( Map<String, String> properties )
280 this.properties = properties;
284 * Set the network proxy ID to use for this connector.
288 public void setProxyId( String proxyId )
290 this.proxyId = proxyId;
294 * Set the Repository Source for this connector.
296 * @param sourceRepoId
298 public void setSourceRepoId( String sourceRepoId )
300 this.sourceRepoId = sourceRepoId;
304 * Set the Repository Target for this connector.
306 * @param targetRepoId
308 public void setTargetRepoId( String targetRepoId )
310 this.targetRepoId = targetRepoId;
315 * The list of whitelisted patterns for this
318 * @param whiteListPatterns
320 public void setWhiteListPatterns( List<String> whiteListPatterns )
322 this.whiteListPatterns = whiteListPatterns;
327 * Obtain a specific policy from the underlying connector.
329 * @param policyId the policy id to fetch.
330 * @param defaultValue the default value for the policy id.
331 * @return the configured policy value (or default value if not found).
333 public String getPolicy( String policyId, String defaultValue )
335 if ( this.getPolicies() == null )
340 String value = this.getPolicies().get( policyId );
351 public boolean equals( Object o )
357 if ( o == null || getClass() != o.getClass() )
362 AbstractRepositoryConnector that = (AbstractRepositoryConnector) o;
364 if ( sourceRepoId != null ? !sourceRepoId.equals( that.sourceRepoId ) : that.sourceRepoId != null )
368 if ( targetRepoId != null ? !targetRepoId.equals( that.targetRepoId ) : that.targetRepoId != null )
377 public int hashCode()
379 int result = sourceRepoId != null ? sourceRepoId.hashCode() : 0;
380 result = 31 * result + ( targetRepoId != null ? targetRepoId.hashCode() : 0 );
385 public String toString()
387 final StringBuilder sb = new StringBuilder();
388 sb.append( "AbstractRepositoryConnector" );
389 sb.append( "{sourceRepoId='" ).append( sourceRepoId ).append( '\'' );
390 sb.append( ", targetRepoId='" ).append( targetRepoId ).append( '\'' );
391 sb.append( ", proxyId='" ).append( proxyId ).append( '\'' );
392 sb.append( ", blackListPatterns=" ).append( blackListPatterns );
393 sb.append( ", whiteListPatterns=" ).append( whiteListPatterns );
394 sb.append( ", policies=" ).append( policies );
395 sb.append( ", properties=" ).append( properties );
396 sb.append( ", disabled=" ).append( disabled );
398 return sb.toString();