/plugins/maven/src/main/java/org/jetbrains/idea/maven/services/artifactory/Endpoint.java

https://bitbucket.org/nbargnesi/idea
Java | 420 lines | 292 code | 55 blank | 73 comment | 0 complexity | 9bb13b1825ea6b8a8387321ef21cfdd3 MD5 | raw file
  1. /*
  2. * Copyright 2000-2010 JetBrains s.r.o.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.jetbrains.idea.maven.services.artifactory;
  17. import org.jvnet.ws.wadl.util.DSDispatcher;
  18. import org.jvnet.ws.wadl.util.JAXBDispatcher;
  19. import org.jvnet.ws.wadl.util.UriBuilder;
  20. import javax.activation.DataSource;
  21. import javax.xml.bind.JAXBContext;
  22. import javax.xml.bind.JAXBException;
  23. import java.io.IOException;
  24. import java.net.MalformedURLException;
  25. import java.util.Collections;
  26. import java.util.HashMap;
  27. import java.util.List;
  28. /**
  29. *
  30. */
  31. public class Endpoint {
  32. public static DataSource getArtifactInfoByUri(String uri)
  33. throws IOException, MalformedURLException {
  34. DSDispatcher _dsDispatcher = new DSDispatcher();
  35. UriBuilder _uriBuilder = new UriBuilder();
  36. _uriBuilder.addPathSegment(uri);
  37. String _url = _uriBuilder.buildUri(Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap());
  38. DataSource _retVal =
  39. _dsDispatcher.doGET(_url, Collections.<String, Object>emptyMap(), "application/vnd.org.jfrog.artifactory.search.ArtifactSearchResult+json");
  40. return _retVal;
  41. }
  42. public static class Search {
  43. public static class Artifact {
  44. private DSDispatcher _dsDispatcher;
  45. private UriBuilder _uriBuilder;
  46. private JAXBContext _jc;
  47. private HashMap<String, Object> _templateAndMatrixParameterValues;
  48. /**
  49. * Create new instance
  50. *
  51. * @param url
  52. */
  53. public Artifact(final String url)
  54. throws JAXBException
  55. {
  56. _dsDispatcher = new DSDispatcher();
  57. _uriBuilder = new UriBuilder();
  58. List<String> _matrixParamSet;
  59. _matrixParamSet = _uriBuilder.addPathSegment(url);
  60. _matrixParamSet = _uriBuilder.addPathSegment("search");
  61. _matrixParamSet = _uriBuilder.addPathSegment("artifact");
  62. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  63. }
  64. public DataSource getArtifactSearchResultJson(String name, String repos)
  65. throws IOException, MalformedURLException
  66. {
  67. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  68. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  69. _queryParameterValues.put("name", name);
  70. _queryParameterValues.put("repos", repos);
  71. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  72. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.search.ArtifactSearchResult+json");
  73. return _retVal;
  74. }
  75. }
  76. public static class Gavc {
  77. private JAXBDispatcher _jaxbDispatcher;
  78. private DSDispatcher _dsDispatcher;
  79. private UriBuilder _uriBuilder;
  80. private JAXBContext _jc;
  81. private HashMap<String, Object> _templateAndMatrixParameterValues;
  82. /**
  83. * Create new instance
  84. *
  85. * @param url
  86. */
  87. public Gavc(final String url)
  88. throws JAXBException
  89. {
  90. _dsDispatcher = new DSDispatcher();
  91. _uriBuilder = new UriBuilder();
  92. List<String> _matrixParamSet;
  93. _matrixParamSet = _uriBuilder.addPathSegment(url);
  94. _matrixParamSet = _uriBuilder.addPathSegment("search");
  95. _matrixParamSet = _uriBuilder.addPathSegment("gavc");
  96. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  97. }
  98. public DataSource getGavcSearchResultJson(String g, String a, String v, String c, String repos)
  99. throws IOException, MalformedURLException
  100. {
  101. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  102. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  103. _queryParameterValues.put("g", g);
  104. _queryParameterValues.put("a", a);
  105. _queryParameterValues.put("v", v);
  106. _queryParameterValues.put("c", c);
  107. _queryParameterValues.put("repos", repos);
  108. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  109. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.search.GavcSearchResult+json");
  110. return _retVal;
  111. }
  112. }
  113. public static class Archive {
  114. private JAXBDispatcher _jaxbDispatcher;
  115. private DSDispatcher _dsDispatcher;
  116. private UriBuilder _uriBuilder;
  117. private JAXBContext _jc;
  118. private HashMap<String, Object> _templateAndMatrixParameterValues;
  119. /**
  120. * Create new instance
  121. *
  122. * @param url
  123. */
  124. public Archive(final String url)
  125. throws JAXBException
  126. {
  127. _dsDispatcher = new DSDispatcher();
  128. _uriBuilder = new UriBuilder();
  129. List<String> _matrixParamSet;
  130. _matrixParamSet = _uriBuilder.addPathSegment(url);
  131. _matrixParamSet = _uriBuilder.addPathSegment("search");
  132. _matrixParamSet = _uriBuilder.addPathSegment("archive");
  133. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  134. }
  135. public DataSource getArchiveSearchResultJson(String className, String repos)
  136. throws IOException, MalformedURLException
  137. {
  138. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  139. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  140. _queryParameterValues.put("name", className);
  141. _queryParameterValues.put("repos", repos);
  142. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  143. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.search.ArchiveEntrySearchResult+json");
  144. return _retVal;
  145. }
  146. }
  147. }
  148. public static class System {
  149. private JAXBDispatcher _jaxbDispatcher;
  150. private DSDispatcher _dsDispatcher;
  151. private UriBuilder _uriBuilder;
  152. private JAXBContext _jc;
  153. private HashMap<String, Object> _templateAndMatrixParameterValues;
  154. /**
  155. * Create new instance
  156. *
  157. * @param url
  158. */
  159. public System(final String url)
  160. throws JAXBException
  161. {
  162. _dsDispatcher = new DSDispatcher();
  163. _uriBuilder = new UriBuilder();
  164. List<String> _matrixParamSet;
  165. _matrixParamSet = _uriBuilder.addPathSegment(url);
  166. _matrixParamSet = _uriBuilder.addPathSegment("system");
  167. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  168. }
  169. public DataSource getAsApplicationXml()
  170. throws IOException, MalformedURLException
  171. {
  172. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  173. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  174. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  175. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/xml");
  176. return _retVal;
  177. }
  178. public static class Configuration {
  179. private JAXBDispatcher _jaxbDispatcher;
  180. private DSDispatcher _dsDispatcher;
  181. private UriBuilder _uriBuilder;
  182. private JAXBContext _jc;
  183. private HashMap<String, Object> _templateAndMatrixParameterValues;
  184. /**
  185. * Create new instance
  186. *
  187. * @param url
  188. */
  189. public Configuration(final String url)
  190. throws JAXBException
  191. {
  192. _dsDispatcher = new DSDispatcher();
  193. _uriBuilder = new UriBuilder();
  194. List<String> _matrixParamSet;
  195. _matrixParamSet = _uriBuilder.addPathSegment(url);
  196. _matrixParamSet = _uriBuilder.addPathSegment("system");
  197. _matrixParamSet = _uriBuilder.addPathSegment("configuration");
  198. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  199. }
  200. public DataSource postAsTextPlain(DataSource input)
  201. throws IOException, MalformedURLException
  202. {
  203. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  204. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  205. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  206. DataSource _retVal = _dsDispatcher.doPOST(input, "application/xml", _url, _headerParameterValues, "text/plain");
  207. return _retVal;
  208. }
  209. public DataSource getAsApplicationXml()
  210. throws IOException, MalformedURLException
  211. {
  212. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  213. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  214. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  215. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/xml");
  216. return _retVal;
  217. }
  218. public static class RemoteRepositories {
  219. private JAXBDispatcher _jaxbDispatcher;
  220. private DSDispatcher _dsDispatcher;
  221. private UriBuilder _uriBuilder;
  222. private JAXBContext _jc;
  223. private HashMap<String, Object> _templateAndMatrixParameterValues;
  224. /**
  225. * Create new instance
  226. *
  227. * @param url
  228. */
  229. public RemoteRepositories(final String url)
  230. throws JAXBException
  231. {
  232. _dsDispatcher = new DSDispatcher();
  233. _uriBuilder = new UriBuilder();
  234. List<String> _matrixParamSet;
  235. _matrixParamSet = _uriBuilder.addPathSegment(url);
  236. _matrixParamSet = _uriBuilder.addPathSegment("system");
  237. _matrixParamSet = _uriBuilder.addPathSegment("configuration");
  238. _matrixParamSet = _uriBuilder.addPathSegment("remoteRepositories");
  239. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  240. }
  241. public void put(DataSource input)
  242. throws IOException, MalformedURLException
  243. {
  244. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  245. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  246. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  247. DataSource _retVal = _dsDispatcher.doPUT(input, "application/xml", _url, _headerParameterValues, null);
  248. return ;
  249. }
  250. }
  251. }
  252. }
  253. public static class SystemVersion {
  254. private JAXBDispatcher _jaxbDispatcher;
  255. private DSDispatcher _dsDispatcher;
  256. private UriBuilder _uriBuilder;
  257. private JAXBContext _jc;
  258. private HashMap<String, Object> _templateAndMatrixParameterValues;
  259. /**
  260. * Create new instance
  261. *
  262. * @param url
  263. */
  264. public SystemVersion(final String url)
  265. throws JAXBException
  266. {
  267. _dsDispatcher = new DSDispatcher();
  268. _uriBuilder = new UriBuilder();
  269. List<String> _matrixParamSet;
  270. _matrixParamSet = _uriBuilder.addPathSegment(url);
  271. _matrixParamSet = _uriBuilder.addPathSegment("system/version");
  272. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  273. }
  274. public DataSource getSystemVersionJson()
  275. throws IOException, MalformedURLException
  276. {
  277. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  278. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  279. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  280. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.system.Version+json");
  281. return _retVal;
  282. }
  283. }
  284. /**
  285. * @author Gregory.Shrago
  286. */
  287. public static class Repositories {
  288. private JAXBDispatcher _jaxbDispatcher;
  289. private DSDispatcher _dsDispatcher;
  290. private UriBuilder _uriBuilder;
  291. private JAXBContext _jc;
  292. private HashMap<String, Object> _templateAndMatrixParameterValues;
  293. /**
  294. * Create new instance
  295. *
  296. * @param url
  297. */
  298. public Repositories(String url)
  299. throws JAXBException
  300. {
  301. _dsDispatcher = new DSDispatcher();
  302. _uriBuilder = new UriBuilder();
  303. List<String> _matrixParamSet;
  304. _matrixParamSet = _uriBuilder.addPathSegment(url);
  305. _matrixParamSet = _uriBuilder.addPathSegment("repositories");
  306. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  307. }
  308. public DataSource getRepositoryDetailsListJson(String type)
  309. throws IOException, MalformedURLException
  310. {
  311. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  312. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  313. _queryParameterValues.put("type", type);
  314. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  315. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.repositories.RepositoryDetailsList+json");
  316. return _retVal;
  317. }
  318. public static class RepoKeyConfiguration {
  319. private JAXBDispatcher _jaxbDispatcher;
  320. private DSDispatcher _dsDispatcher;
  321. private UriBuilder _uriBuilder;
  322. private JAXBContext _jc;
  323. private HashMap<String, Object> _templateAndMatrixParameterValues;
  324. /**
  325. * Create new instance
  326. *
  327. */
  328. public RepoKeyConfiguration(final String url, String repokey)
  329. throws JAXBException
  330. {
  331. _dsDispatcher = new DSDispatcher();
  332. _uriBuilder = new UriBuilder();
  333. List<String> _matrixParamSet;
  334. _matrixParamSet = _uriBuilder.addPathSegment(url);
  335. _matrixParamSet = _uriBuilder.addPathSegment("repositories");
  336. _matrixParamSet = _uriBuilder.addPathSegment("{repoKey}/configuration");
  337. _templateAndMatrixParameterValues = new HashMap<String, Object>();
  338. _templateAndMatrixParameterValues.put("repoKey", repokey);
  339. }
  340. /**
  341. * Get repoKey
  342. *
  343. */
  344. public String getRepoKey() {
  345. return ((String) _templateAndMatrixParameterValues.get("repoKey"));
  346. }
  347. /**
  348. * Set repoKey
  349. *
  350. */
  351. public void setRepoKey(String repokey) {
  352. _templateAndMatrixParameterValues.put("repoKey", repokey);
  353. }
  354. public DataSource getAsApplicationVndOrgJfrogArtifactoryRepositoriesRepositoryConfigurationJson()
  355. throws IOException, MalformedURLException
  356. {
  357. HashMap<String, Object> _queryParameterValues = new HashMap<String, Object>();
  358. HashMap<String, Object> _headerParameterValues = new HashMap<String, Object>();
  359. String _url = _uriBuilder.buildUri(_templateAndMatrixParameterValues, _queryParameterValues);
  360. DataSource _retVal = _dsDispatcher.doGET(_url, _headerParameterValues, "application/vnd.org.jfrog.artifactory.repositories.RepositoryConfiguration+json");
  361. return _retVal;
  362. }
  363. }
  364. }
  365. }