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 org.apache.commons.lang.StringUtils;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import java.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
32 * @author Olivier Lamy
35 @XmlRootElement (name = "remoteRepository")
36 public class RemoteRepository
37 extends AbstractRepository
38 implements Serializable
43 private String userName;
45 private String password;
47 private int timeout = 60;
50 * Activate download of remote index if remoteIndexUrl is set too.
52 private boolean downloadRemoteIndex = false;
55 * Remote Index Url : if not starting with http will be relative to the remote repository url.
57 private String remoteIndexUrl = ".index";
59 private String remoteDownloadNetworkProxyId;
62 * default model value daily : every sunday at 8H00
64 private String cronExpression = "0 0 08 ? * SUN";
66 private int remoteDownloadTimeout = 300;
71 private boolean downloadRemoteIndexOnStartup = false;
78 private Map<String, String> extraParameters;
81 * field to ease json mapping wrapper on <code>extraParameters</code> field
85 private List<PropertyEntry> extraParametersEntries;
92 private Map<String, String> extraHeaders;
95 * field to ease json mapping wrapper on <code>extraHeaders</code> field
99 private List<PropertyEntry> extraHeadersEntries;
102 public RemoteRepository()
107 public RemoteRepository( String id, String name, String url, String layout )
109 super( id, name, layout );
113 public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
116 super( id, name, layout );
117 this.url = StringUtils.stripEnd(url,"/");
118 this.userName = userName;
119 this.password = password;
120 this.timeout = timeout;
126 public RemoteRepository( String id, String name, String url, String layout, String userName, String password,
127 int timeout, String description )
129 this( id, name, url, layout, userName, password, timeout );
130 setDescription( description );
133 public String getUrl()
138 public void setUrl( String url )
140 this.url = StringUtils.stripEnd(url,"/");
143 public String getUserName()
148 public void setUserName( String userName )
150 this.userName = userName;
153 public String getPassword()
158 public void setPassword( String password )
160 this.password = password;
163 public int getTimeout()
168 public void setTimeout( int timeout )
170 this.timeout = timeout;
173 public boolean isDownloadRemoteIndex()
175 return downloadRemoteIndex;
178 public void setDownloadRemoteIndex( boolean downloadRemoteIndex )
180 this.downloadRemoteIndex = downloadRemoteIndex;
183 public String getRemoteIndexUrl()
185 return remoteIndexUrl;
188 public void setRemoteIndexUrl( String remoteIndexUrl )
190 this.remoteIndexUrl = remoteIndexUrl;
193 public String getRemoteDownloadNetworkProxyId()
195 return remoteDownloadNetworkProxyId;
198 public void setRemoteDownloadNetworkProxyId( String remoteDownloadNetworkProxyId )
200 this.remoteDownloadNetworkProxyId = remoteDownloadNetworkProxyId;
203 public String getCronExpression()
205 return cronExpression;
208 public void setCronExpression( String cronExpression )
210 this.cronExpression = cronExpression;
213 public int getRemoteDownloadTimeout()
215 return remoteDownloadTimeout;
218 public void setRemoteDownloadTimeout( int remoteDownloadTimeout )
220 this.remoteDownloadTimeout = remoteDownloadTimeout;
223 public boolean isDownloadRemoteIndexOnStartup()
225 return downloadRemoteIndexOnStartup;
228 public void setDownloadRemoteIndexOnStartup( boolean downloadRemoteIndexOnStartup )
230 this.downloadRemoteIndexOnStartup = downloadRemoteIndexOnStartup;
233 public Map<String, String> getExtraParameters()
235 if ( this.extraParameters == null )
237 this.extraParameters = new HashMap<>();
239 return extraParameters;
242 public void setExtraParameters( Map<String, String> extraParameters )
244 this.extraParameters = extraParameters;
247 public void addExtraParameter( String key, String value )
249 getExtraParameters().put( key, value );
252 public List<PropertyEntry> getExtraParametersEntries()
254 this.extraParametersEntries = new ArrayList<>();
255 for ( Map.Entry<String, String> entry : getExtraParameters().entrySet() )
257 this.extraParametersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
259 return this.extraParametersEntries;
262 public void setExtraParametersEntries( List<PropertyEntry> extraParametersEntries )
264 if ( extraParametersEntries == null )
269 this.extraParametersEntries = extraParametersEntries;
270 for ( PropertyEntry propertyEntry : extraParametersEntries )
272 this.addExtraParameter( propertyEntry.getKey(), propertyEntry.getValue() );
276 public Map<String, String> getExtraHeaders()
278 if ( this.extraHeaders == null )
280 this.extraHeaders = new HashMap<>();
285 public void setExtraHeaders( Map<String, String> extraHeaders )
287 this.extraHeaders = extraHeaders;
290 public void addExtraHeader( String key, String value )
292 getExtraHeaders().put( key, value );
295 public List<PropertyEntry> getExtraHeadersEntries()
297 this.extraHeadersEntries = new ArrayList<>();
298 for ( Map.Entry<String, String> entry : getExtraHeaders().entrySet() )
300 this.extraHeadersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
302 return this.extraHeadersEntries;
305 public void setExtraHeadersEntries( List<PropertyEntry> extraHeadersEntries )
307 if ( extraHeadersEntries == null )
312 this.extraHeadersEntries = extraHeadersEntries;
313 for ( PropertyEntry propertyEntry : extraHeadersEntries )
315 this.addExtraHeader( propertyEntry.getKey(), propertyEntry.getValue() );
321 public String toString()
323 final StringBuilder sb = new StringBuilder();
324 sb.append( super.toString() );
325 sb.append( "RemoteRepository" );
326 sb.append( "{url='" ).append( url ).append( '\'' );
327 sb.append( ", userName='" ).append( userName ).append( '\'' );
328 sb.append( ", password='" ).append( password ).append( '\'' );
329 sb.append( ", timeout=" ).append( timeout );
330 sb.append( ", downloadRemoteIndex=" ).append( downloadRemoteIndex );
331 sb.append( ", remoteIndexUrl='" ).append( remoteIndexUrl ).append( '\'' );
332 sb.append( ", remoteDownloadNetworkProxyId='" ).append( remoteDownloadNetworkProxyId ).append( '\'' );
333 sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
334 sb.append( ", remoteDownloadTimeout=" ).append( remoteDownloadTimeout );
335 sb.append( ", downloadRemoteIndexOnStartup=" ).append( downloadRemoteIndexOnStartup );
336 sb.append( ", extraParameters=" ).append( extraParameters );
337 sb.append( ", extraHeaders=" ).append( extraHeaders );
339 return sb.toString();