001 package org.apache.archiva.proxy.common; 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 021 import org.apache.archiva.admin.model.beans.NetworkProxy; 022 023 import java.util.HashMap; 024 import java.util.Map; 025 026 /** 027 * @author Olivier Lamy 028 * @since 1.4-M4 029 */ 030 public class WagonFactoryRequest 031 { 032 /** 033 * the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example 034 * <code>wagon#http</code>. <b>to have a wagon supporting ntlm add -ntlm</b> 035 */ 036 private String protocol; 037 038 private Map<String, String> headers = new HashMap<String, String>(); 039 040 private String userAgent = "Java-Archiva"; 041 042 private NetworkProxy networkProxy; 043 044 public WagonFactoryRequest() 045 { 046 // no op 047 } 048 049 public WagonFactoryRequest( String protocol, Map<String, String> headers ) 050 { 051 this.protocol = protocol; 052 this.headers = headers; 053 } 054 055 public String getProtocol() 056 { 057 return protocol; 058 } 059 060 public void setProtocol( String protocol ) 061 { 062 this.protocol = protocol; 063 } 064 065 public WagonFactoryRequest protocol( String protocol ) 066 { 067 this.protocol = protocol; 068 return this; 069 } 070 071 public Map<String, String> getHeaders() 072 { 073 if ( this.headers == null ) 074 { 075 this.headers = new HashMap<String, String>(); 076 } 077 return headers; 078 } 079 080 public void setHeaders( Map<String, String> headers ) 081 { 082 this.headers = headers; 083 } 084 085 public WagonFactoryRequest headers( Map<String, String> headers ) 086 { 087 this.headers = headers; 088 return this; 089 } 090 091 public String getUserAgent() 092 { 093 return userAgent; 094 } 095 096 public void setUserAgent( String userAgent ) 097 { 098 this.userAgent = userAgent; 099 } 100 101 public WagonFactoryRequest userAgent( String userAgent ) 102 { 103 this.userAgent = userAgent; 104 return this; 105 } 106 107 public NetworkProxy getNetworkProxy() 108 { 109 return networkProxy; 110 } 111 112 public void setNetworkProxy( NetworkProxy networkProxy ) 113 { 114 this.networkProxy = networkProxy; 115 } 116 117 public WagonFactoryRequest networkProxy( NetworkProxy networkProxy ) 118 { 119 this.networkProxy = networkProxy; 120 return this; 121 } 122 123 @Override 124 public boolean equals( Object o ) 125 { 126 if ( this == o ) 127 { 128 return true; 129 } 130 if ( !( o instanceof WagonFactoryRequest ) ) 131 { 132 return false; 133 } 134 135 WagonFactoryRequest that = (WagonFactoryRequest) o; 136 137 if ( protocol != null ? !protocol.equals( that.protocol ) : that.protocol != null ) 138 { 139 return false; 140 } 141 if ( userAgent != null ? !userAgent.equals( that.userAgent ) : that.userAgent != null ) 142 { 143 return false; 144 } 145 146 return true; 147 } 148 149 @Override 150 public int hashCode() 151 { 152 int result = protocol != null ? protocol.hashCode() : 0; 153 result = 31 * result + ( userAgent != null ? userAgent.hashCode() : 0 ); 154 return result; 155 } 156 }