1 package org.apache.archiva.admin.model.beans;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import javax.xml.bind.annotation.XmlRootElement;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
30 * @author Olivier Lamy
33 @XmlRootElement (name = "remoteRepository")
34 public class RemoteRepository
35 extends AbstractRepository
36 implements Serializable
41 private String userName;
43 private String password;
45 private int timeout = 60;
48 * Activate download of remote index if remoteIndexUrl is set too.
50 private boolean downloadRemoteIndex = false;
53 * Remote Index Url : if not starting with http will be relative to the remote repository url.
55 private String remoteIndexUrl = ".index";
57 private String remoteDownloadNetworkProxyId;
60 * default model value daily : every sunday at 8H00
62 private String cronExpression = "0 0 08 ? * SUN";
64 private int remoteDownloadTimeout = 300;
69 private boolean downloadRemoteIndexOnStartup = false;
76 private Map<String, String> extraParameters;
79 * field to ease json mapping wrapper on <code>extraParameters</code> field
83 private List<PropertyEntry> extraParametersEntries;
90 private Map<String, String> extraHeaders;
93 * field to ease json mapping wrapper on <code>extraHeaders</code> field
97 private List<PropertyEntry> extraHeadersEntries;
100 public RemoteRepository()
105 public RemoteRepository( String id, String name, String url, String layout )
107 super( id, name, layout );
111 public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
114 super( id, name, layout );
116 this.userName = userName;
117 this.password = password;
118 this.timeout = timeout;
124 public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
125 int timeout, String description )
127 this( id, name, url, layout, userName, password, timeout );
128 setDescription( description );
131 public String getUrl()
136 public void setUrl( String url )
141 public String getUserName()
146 public void setUserName( String userName )
148 this.userName = userName;
151 public String getPassword()
156 public void setPassword( String password )
158 this.password = password;
161 public int getTimeout()
166 public void setTimeout( int timeout )
168 this.timeout = timeout;
171 public boolean isDownloadRemoteIndex()
173 return downloadRemoteIndex;
176 public void setDownloadRemoteIndex( boolean downloadRemoteIndex )
178 this.downloadRemoteIndex = downloadRemoteIndex;
181 public String getRemoteIndexUrl()
183 return remoteIndexUrl;
186 public void setRemoteIndexUrl( String remoteIndexUrl )
188 this.remoteIndexUrl = remoteIndexUrl;
191 public String getRemoteDownloadNetworkProxyId()
193 return remoteDownloadNetworkProxyId;
196 public void setRemoteDownloadNetworkProxyId( String remoteDownloadNetworkProxyId )
198 this.remoteDownloadNetworkProxyId = remoteDownloadNetworkProxyId;
201 public String getCronExpression()
203 return cronExpression;
206 public void setCronExpression( String cronExpression )
208 this.cronExpression = cronExpression;
211 public int getRemoteDownloadTimeout()
213 return remoteDownloadTimeout;
216 public void setRemoteDownloadTimeout( int remoteDownloadTimeout )
218 this.remoteDownloadTimeout = remoteDownloadTimeout;
221 public boolean isDownloadRemoteIndexOnStartup()
223 return downloadRemoteIndexOnStartup;
226 public void setDownloadRemoteIndexOnStartup( boolean downloadRemoteIndexOnStartup )
228 this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup;
231 public Map<String, String> getExtraParameters()
233 if ( this.extraParameters == null )
235 this.extraParameters = new HashMap<>();
237 return extraParameters;
240 public void setExtraParameters( Map<String, String> extraParameters )
242 this.extraParameters = extraParameters;
245 public void addExtraParameter( String key, String value )
247 getExtraParameters().put( key, value );
250 public List<PropertyEntry> getExtraParametersEntries()
252 this.extraParametersEntries = new ArrayList<>();
253 for ( Map.Entry<String, String> entry : getExtraParameters().entrySet() )
255 this.extraParametersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
257 return this.extraParametersEntries;
260 public void setExtraParametersEntries( List<PropertyEntry> extraParametersEntries )
262 if ( extraParametersEntries == null )
267 this.extraParametersEntries = extraParametersEntries;
268 for ( PropertyEntry propertyEntry : extraParametersEntries )
270 this.addExtraParameter( propertyEntry.getKey(), propertyEntry.getValue() );
274 public Map<String, String> getExtraHeaders()
276 if ( this.extraHeaders == null )
278 this.extraHeaders = new HashMap<>();
283 public void setExtraHeaders( Map<String, String> extraHeaders )
285 this.extraHeaders = extraHeaders;
288 public void addExtraHeader( String key, String value )
290 getExtraHeaders().put( key, value );
293 public List<PropertyEntry> getExtraHeadersEntries()
295 this.extraHeadersEntries = new ArrayList<>();
296 for ( Map.Entry<String, String> entry : getExtraHeaders().entrySet() )
298 this.extraHeadersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
300 return this.extraHeadersEntries;
303 public void setExtraHeadersEntries( List<PropertyEntry> extraHeadersEntries )
305 if ( extraHeadersEntries == null )
310 this.extraHeadersEntries = extraHeadersEntries;
311 for ( PropertyEntry propertyEntry : extraHeadersEntries )
313 this.addExtraHeader( propertyEntry.getKey(), propertyEntry.getValue() );
319 public String toString()
321 final StringBuilder sb = new StringBuilder();
322 sb.append( super.toString() );
323 sb.append( "RemoteRepository" );
324 sb.append( "{url='" ).append( url ).append( '\'' );
325 sb.append( ", userName='" ).append( userName ).append( '\'' );
326 sb.append( ", password='" ).append( password ).append( '\'' );
327 sb.append( ", timeout=" ).append( timeout );
328 sb.append( ", downloadRemoteIndex=" ).append( downloadRemoteIndex );
329 sb.append( ", remoteIndexUrl='" ).append( remoteIndexUrl ).append( '\'' );
330 sb.append( ", remoteDownloadNetworkProxyId='" ).append( remoteDownloadNetworkProxyId ).append( '\'' );
331 sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
332 sb.append( ", remoteDownloadTimeout=" ).append( remoteDownloadTimeout );
333 sb.append( ", downloadRemoteIndexOnStartup=" ).append( downloadRemoteIndexOnStartup );
334 sb.append( ", extraParameters=" ).append( extraParameters );
335 sb.append( ", extraHeaders=" ).append( extraHeaders );
337 return sb.toString();