This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.proxy.maven;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.archiva.proxy.model.NetworkProxy;
022import org.apache.commons.lang3.StringUtils;
023
024import java.util.HashMap;
025import java.util.Map;
026
027/**
028 * @author Olivier Lamy
029 * @since 1.4-M4
030 */
031public class WagonFactoryRequest
032{
033
034    public static final String USER_AGENT_SYSTEM_PROPERTY = "archiva.userAgent";
035
036    private static String DEFAULT_USER_AGENT = "Java-Archiva";
037
038    /**
039     * the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example
040     * <code>wagon#http</code>. <b>to have a wagon supporting ntlm add -ntlm</b>
041     */
042    private String protocol;
043
044    private Map<String, String> headers = new HashMap<>();
045
046    private String userAgent = DEFAULT_USER_AGENT;
047
048    static {
049        if ( StringUtils.isNotBlank( System.getProperty( USER_AGENT_SYSTEM_PROPERTY))) {
050            DEFAULT_USER_AGENT=System.getProperty(USER_AGENT_SYSTEM_PROPERTY);
051        }
052    }
053
054    private NetworkProxy networkProxy;
055
056    public WagonFactoryRequest()
057    {
058        // no op
059    }
060
061    public WagonFactoryRequest( String protocol, Map<String, String> headers )
062    {
063        this.protocol = protocol;
064        this.headers = headers;
065    }
066
067    public String getProtocol()
068    {
069        return protocol;
070    }
071
072    public void setProtocol( String protocol )
073    {
074        this.protocol = protocol;
075    }
076
077    public WagonFactoryRequest protocol( String protocol )
078    {
079        this.protocol = protocol;
080        return this;
081    }
082
083    public Map<String, String> getHeaders()
084    {
085        if ( this.headers == null )
086        {
087            this.headers = new HashMap<>();
088        }
089        return headers;
090    }
091
092    public void setHeaders( Map<String, String> headers )
093    {
094        this.headers = headers;
095    }
096
097    public WagonFactoryRequest headers( Map<String, String> headers )
098    {
099        this.headers = headers;
100        return this;
101    }
102
103    public String getUserAgent()
104    {
105        return userAgent;
106    }
107
108    public void setUserAgent( String userAgent )
109    {
110        this.userAgent = userAgent;
111    }
112
113    public WagonFactoryRequest userAgent( String userAgent )
114    {
115        this.userAgent = userAgent;
116        return this;
117    }
118
119    public NetworkProxy getNetworkProxy()
120    {
121        return networkProxy;
122    }
123
124    public void setNetworkProxy( NetworkProxy networkProxy )
125    {
126        this.networkProxy = networkProxy;
127    }
128
129    public WagonFactoryRequest networkProxy( NetworkProxy networkProxy )
130    {
131        this.networkProxy = networkProxy;
132        return this;
133    }
134
135    @Override
136    public boolean equals( Object o )
137    {
138        if ( this == o )
139        {
140            return true;
141        }
142        if ( !( o instanceof WagonFactoryRequest ) )
143        {
144            return false;
145        }
146
147        WagonFactoryRequest that = (WagonFactoryRequest) o;
148
149        if ( protocol != null ? !protocol.equals( that.protocol ) : that.protocol != null )
150        {
151            return false;
152        }
153        if ( userAgent != null ? !userAgent.equals( that.userAgent ) : that.userAgent != null )
154        {
155            return false;
156        }
157
158        return true;
159    }
160
161    @Override
162    public int hashCode()
163    {
164        int result = protocol != null ? protocol.hashCode() : 0;
165        result = 31 * result + ( userAgent != null ? userAgent.hashCode() : 0 );
166        return result;
167    }
168
169    @Override
170    public String toString()
171    {
172        return "WagonFactoryRequest{" +
173            "protocol='" + protocol + '\'' +
174            ", headers=" + headers +
175            ", userAgent='" + userAgent + '\'' +
176            ", networkProxy=" + networkProxy +
177            '}';
178    }
179}