You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WagonFactoryRequest.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package org.apache.archiva.proxy.maven;
  2. /*
  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
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  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
  18. * under the License.
  19. */
  20. import org.apache.archiva.proxy.model.NetworkProxy;
  21. import org.apache.commons.lang.StringUtils;
  22. import java.util.HashMap;
  23. import java.util.Map;
  24. /**
  25. * @author Olivier Lamy
  26. * @since 1.4-M4
  27. */
  28. public class WagonFactoryRequest
  29. {
  30. public static final String USER_AGENT_SYSTEM_PROPERTY = "archiva.userAgent";
  31. private static String DEFAULT_USER_AGENT = "Java-Archiva";
  32. /**
  33. * the protocol to find the Wagon for, which must be prefixed with <code>wagon#</code>, for example
  34. * <code>wagon#http</code>. <b>to have a wagon supporting ntlm add -ntlm</b>
  35. */
  36. private String protocol;
  37. private Map<String, String> headers = new HashMap<>();
  38. private String userAgent = DEFAULT_USER_AGENT;
  39. static {
  40. if ( StringUtils.isNotBlank( System.getProperty( USER_AGENT_SYSTEM_PROPERTY))) {
  41. DEFAULT_USER_AGENT=System.getProperty(USER_AGENT_SYSTEM_PROPERTY);
  42. }
  43. }
  44. private NetworkProxy networkProxy;
  45. public WagonFactoryRequest()
  46. {
  47. // no op
  48. }
  49. public WagonFactoryRequest( String protocol, Map<String, String> headers )
  50. {
  51. this.protocol = protocol;
  52. this.headers = headers;
  53. }
  54. public String getProtocol()
  55. {
  56. return protocol;
  57. }
  58. public void setProtocol( String protocol )
  59. {
  60. this.protocol = protocol;
  61. }
  62. public WagonFactoryRequest protocol( String protocol )
  63. {
  64. this.protocol = protocol;
  65. return this;
  66. }
  67. public Map<String, String> getHeaders()
  68. {
  69. if ( this.headers == null )
  70. {
  71. this.headers = new HashMap<>();
  72. }
  73. return headers;
  74. }
  75. public void setHeaders( Map<String, String> headers )
  76. {
  77. this.headers = headers;
  78. }
  79. public WagonFactoryRequest headers( Map<String, String> headers )
  80. {
  81. this.headers = headers;
  82. return this;
  83. }
  84. public String getUserAgent()
  85. {
  86. return userAgent;
  87. }
  88. public void setUserAgent( String userAgent )
  89. {
  90. this.userAgent = userAgent;
  91. }
  92. public WagonFactoryRequest userAgent( String userAgent )
  93. {
  94. this.userAgent = userAgent;
  95. return this;
  96. }
  97. public NetworkProxy getNetworkProxy()
  98. {
  99. return networkProxy;
  100. }
  101. public void setNetworkProxy( NetworkProxy networkProxy )
  102. {
  103. this.networkProxy = networkProxy;
  104. }
  105. public WagonFactoryRequest networkProxy( NetworkProxy networkProxy )
  106. {
  107. this.networkProxy = networkProxy;
  108. return this;
  109. }
  110. @Override
  111. public boolean equals( Object o )
  112. {
  113. if ( this == o )
  114. {
  115. return true;
  116. }
  117. if ( !( o instanceof WagonFactoryRequest ) )
  118. {
  119. return false;
  120. }
  121. WagonFactoryRequest that = (WagonFactoryRequest) o;
  122. if ( protocol != null ? !protocol.equals( that.protocol ) : that.protocol != null )
  123. {
  124. return false;
  125. }
  126. if ( userAgent != null ? !userAgent.equals( that.userAgent ) : that.userAgent != null )
  127. {
  128. return false;
  129. }
  130. return true;
  131. }
  132. @Override
  133. public int hashCode()
  134. {
  135. int result = protocol != null ? protocol.hashCode() : 0;
  136. result = 31 * result + ( userAgent != null ? userAgent.hashCode() : 0 );
  137. return result;
  138. }
  139. @Override
  140. public String toString()
  141. {
  142. return "WagonFactoryRequest{" +
  143. "protocol='" + protocol + '\'' +
  144. ", headers=" + headers +
  145. ", userAgent='" + userAgent + '\'' +
  146. ", networkProxy=" + networkProxy +
  147. '}';
  148. }
  149. }