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.

AbstractRepositoryConnectorConfiguration.java 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. package org.apache.archiva.configuration.model;
  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. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * Class AbstractRepositoryConnectorConfiguration.
  21. *
  22. * @version $Revision$ $Date$
  23. */
  24. @SuppressWarnings( "all" )
  25. public class AbstractRepositoryConnectorConfiguration
  26. implements java.io.Serializable
  27. {
  28. //--------------------------/
  29. //- Class/Member Variables -/
  30. //--------------------------/
  31. /**
  32. *
  33. * The Repository Source for this connector.
  34. *
  35. */
  36. private String sourceRepoId;
  37. /**
  38. *
  39. * The Repository Target for this connector.
  40. *
  41. */
  42. private String targetRepoId;
  43. /**
  44. *
  45. * The network proxy ID to use for this connector.
  46. *
  47. */
  48. private String proxyId;
  49. /**
  50. * Field blackListPatterns.
  51. */
  52. private java.util.List<String> blackListPatterns;
  53. /**
  54. * Field whiteListPatterns.
  55. */
  56. private java.util.List<String> whiteListPatterns;
  57. /**
  58. * Field policies.
  59. */
  60. private java.util.Map policies;
  61. /**
  62. * Field properties.
  63. */
  64. private java.util.Map properties;
  65. /**
  66. *
  67. * If the the repository proxy connector is
  68. * disabled or not
  69. * .
  70. */
  71. private boolean disabled = false;
  72. //-----------/
  73. //- Methods -/
  74. //-----------/
  75. /**
  76. * Method addBlackListPattern.
  77. *
  78. * @param string
  79. */
  80. public void addBlackListPattern( String string )
  81. {
  82. getBlackListPatterns().add( string );
  83. } //-- void addBlackListPattern( String )
  84. /**
  85. * Method addPolicy.
  86. *
  87. * @param key
  88. * @param value
  89. */
  90. public void addPolicy( String key, String value )
  91. {
  92. getPolicies().put( key, value );
  93. } //-- void addPolicy( Object, String )
  94. /**
  95. * Method addProperty.
  96. *
  97. * @param key
  98. * @param value
  99. */
  100. public void addProperty( String key, String value )
  101. {
  102. getProperties().put( key, value );
  103. } //-- void addProperty( Object, String )
  104. /**
  105. * Method addWhiteListPattern.
  106. *
  107. * @param string
  108. */
  109. public void addWhiteListPattern( String string )
  110. {
  111. getWhiteListPatterns().add( string );
  112. } //-- void addWhiteListPattern( String )
  113. /**
  114. * Method getBlackListPatterns.
  115. *
  116. * @return List
  117. */
  118. public java.util.List<String> getBlackListPatterns()
  119. {
  120. if ( this.blackListPatterns == null )
  121. {
  122. this.blackListPatterns = new java.util.ArrayList<String>();
  123. }
  124. return this.blackListPatterns;
  125. } //-- java.util.List<String> getBlackListPatterns()
  126. /**
  127. * Method getPolicies.
  128. *
  129. * @return Map
  130. */
  131. public java.util.Map<String, String> getPolicies()
  132. {
  133. if ( this.policies == null )
  134. {
  135. this.policies = new java.util.HashMap();
  136. }
  137. return this.policies;
  138. } //-- java.util.Map getPolicies()
  139. /**
  140. * Method getProperties.
  141. *
  142. * @return Map
  143. */
  144. public java.util.Map<String, String> getProperties()
  145. {
  146. if ( this.properties == null )
  147. {
  148. this.properties = new java.util.HashMap();
  149. }
  150. return this.properties;
  151. } //-- java.util.Map getProperties()
  152. /**
  153. * Get the network proxy ID to use for this connector.
  154. *
  155. * @return String
  156. */
  157. public String getProxyId()
  158. {
  159. return this.proxyId;
  160. } //-- String getProxyId()
  161. /**
  162. * Get the Repository Source for this connector.
  163. *
  164. * @return String
  165. */
  166. public String getSourceRepoId()
  167. {
  168. return this.sourceRepoId;
  169. } //-- String getSourceRepoId()
  170. /**
  171. * Get the Repository Target for this connector.
  172. *
  173. * @return String
  174. */
  175. public String getTargetRepoId()
  176. {
  177. return this.targetRepoId;
  178. } //-- String getTargetRepoId()
  179. /**
  180. * Method getWhiteListPatterns.
  181. *
  182. * @return List
  183. */
  184. public java.util.List<String> getWhiteListPatterns()
  185. {
  186. if ( this.whiteListPatterns == null )
  187. {
  188. this.whiteListPatterns = new java.util.ArrayList<String>();
  189. }
  190. return this.whiteListPatterns;
  191. } //-- java.util.List<String> getWhiteListPatterns()
  192. /**
  193. * Get if the the repository proxy connector is disabled or
  194. * not.
  195. *
  196. * @return boolean
  197. */
  198. public boolean isDisabled()
  199. {
  200. return this.disabled;
  201. } //-- boolean isDisabled()
  202. /**
  203. * Method removeBlackListPattern.
  204. *
  205. * @param string
  206. */
  207. public void removeBlackListPattern( String string )
  208. {
  209. getBlackListPatterns().remove( string );
  210. } //-- void removeBlackListPattern( String )
  211. /**
  212. * Method removeWhiteListPattern.
  213. *
  214. * @param string
  215. */
  216. public void removeWhiteListPattern( String string )
  217. {
  218. getWhiteListPatterns().remove( string );
  219. } //-- void removeWhiteListPattern( String )
  220. /**
  221. * Set the list of blacklisted patterns for this connector.
  222. *
  223. * @param blackListPatterns
  224. */
  225. public void setBlackListPatterns( java.util.List<String> blackListPatterns )
  226. {
  227. this.blackListPatterns = blackListPatterns;
  228. } //-- void setBlackListPatterns( java.util.List )
  229. /**
  230. * Set if the the repository proxy connector is disabled or
  231. * not.
  232. *
  233. * @param disabled
  234. */
  235. public void setDisabled( boolean disabled )
  236. {
  237. this.disabled = disabled;
  238. } //-- void setDisabled( boolean )
  239. /**
  240. * Set policy configuration for the connector.
  241. *
  242. * @param policies
  243. */
  244. public void setPolicies( java.util.Map policies )
  245. {
  246. this.policies = policies;
  247. } //-- void setPolicies( java.util.Map )
  248. /**
  249. * Set configuration for the connector.
  250. *
  251. * @param properties
  252. */
  253. public void setProperties( java.util.Map properties )
  254. {
  255. this.properties = properties;
  256. } //-- void setProperties( java.util.Map )
  257. /**
  258. * Set the network proxy ID to use for this connector.
  259. *
  260. * @param proxyId
  261. */
  262. public void setProxyId( String proxyId )
  263. {
  264. this.proxyId = proxyId;
  265. } //-- void setProxyId( String )
  266. /**
  267. * Set the Repository Source for this connector.
  268. *
  269. * @param sourceRepoId
  270. */
  271. public void setSourceRepoId( String sourceRepoId )
  272. {
  273. this.sourceRepoId = sourceRepoId;
  274. } //-- void setSourceRepoId( String )
  275. /**
  276. * Set the Repository Target for this connector.
  277. *
  278. * @param targetRepoId
  279. */
  280. public void setTargetRepoId( String targetRepoId )
  281. {
  282. this.targetRepoId = targetRepoId;
  283. } //-- void setTargetRepoId( String )
  284. /**
  285. * Set the list of whitelisted patterns for this connector.
  286. *
  287. * @param whiteListPatterns
  288. */
  289. public void setWhiteListPatterns( java.util.List<String> whiteListPatterns )
  290. {
  291. this.whiteListPatterns = whiteListPatterns;
  292. } //-- void setWhiteListPatterns( java.util.List )
  293. /**
  294. * Obtain a specific policy from the underlying connector.
  295. *
  296. * @param policyId the policy id to fetch.
  297. * @param defaultValue the default value for the policy id.
  298. * @return the configured policy value (or default value if not found).
  299. */
  300. public String getPolicy( String policyId, String defaultValue )
  301. {
  302. if ( this.getPolicies() == null )
  303. {
  304. return null;
  305. }
  306. Object value = this.getPolicies().get( policyId );
  307. if ( value == null )
  308. {
  309. return defaultValue;
  310. }
  311. return (String) value;
  312. }
  313. }