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.

BrowseService.java 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. package org.apache.archiva.rest.api.services;
  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 io.swagger.v3.oas.annotations.tags.Tag;
  21. import org.apache.archiva.admin.model.beans.ManagedRepository;
  22. import org.apache.archiva.maven2.model.Artifact;
  23. import org.apache.archiva.maven2.model.TreeEntry;
  24. import org.apache.archiva.metadata.model.ProjectVersionMetadata;
  25. import org.apache.archiva.redback.authorization.RedbackAuthorization;
  26. import org.apache.archiva.rest.api.model.ActionStatus;
  27. import org.apache.archiva.rest.api.model.ArtifactContent;
  28. import org.apache.archiva.rest.api.model.ArtifactContentEntry;
  29. import org.apache.archiva.rest.api.model.AvailabilityStatus;
  30. import org.apache.archiva.rest.api.model.BrowseResult;
  31. import org.apache.archiva.rest.api.model.Entry;
  32. import org.apache.archiva.rest.api.model.MetadataAddRequest;
  33. import org.apache.archiva.rest.api.model.VersionsList;
  34. import javax.ws.rs.DELETE;
  35. import javax.ws.rs.GET;
  36. import javax.ws.rs.POST;
  37. import javax.ws.rs.PUT;
  38. import javax.ws.rs.Path;
  39. import javax.ws.rs.PathParam;
  40. import javax.ws.rs.Produces;
  41. import javax.ws.rs.QueryParam;
  42. import javax.ws.rs.core.MediaType;
  43. import java.util.List;
  44. /**
  45. * @author Olivier Lamy
  46. * @since 1.4-M3
  47. */
  48. @Path("/browseService/")
  49. @Tag( name = "Browse", description = "Repository Browse Service")
  50. public interface BrowseService
  51. {
  52. @Path("rootGroups")
  53. @GET
  54. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  55. @RedbackAuthorization(noPermission = true, noRestriction = true)
  56. BrowseResult getRootGroups( @QueryParam("repositoryId") String repositoryId )
  57. throws ArchivaRestServiceException;
  58. /**
  59. * @param groupId groupId to browse
  60. * @param repositoryId optionnal (repository to browse if <code>null</code> all available user repositories are used)
  61. */
  62. @Path("browseGroupId/{groupId}")
  63. @GET
  64. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  65. @RedbackAuthorization(noPermission = true, noRestriction = true)
  66. BrowseResult browseGroupId( @PathParam("groupId") String groupId, @QueryParam("repositoryId") String repositoryId )
  67. throws ArchivaRestServiceException;
  68. @Path("versionsList/{g}/{a}")
  69. @GET
  70. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  71. @RedbackAuthorization(noPermission = true, noRestriction = true)
  72. VersionsList getVersionsList( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  73. @QueryParam("repositoryId") String repositoryId )
  74. throws ArchivaRestServiceException;
  75. @Path("projectVersionMetadata/{g}/{a}")
  76. @GET
  77. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  78. @RedbackAuthorization(noPermission = true, noRestriction = true)
  79. ProjectVersionMetadata getProjectVersionMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  80. @QueryParam("repositoryId") String repositoryId )
  81. throws ArchivaRestServiceException;
  82. @Path("projectVersionMetadata/{g}/{a}/{v}")
  83. @GET
  84. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  85. @RedbackAuthorization(noPermission = true, noRestriction = true)
  86. ProjectVersionMetadata getProjectMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  87. @PathParam("v") String version,
  88. @QueryParam("repositoryId") String repositoryId )
  89. throws ArchivaRestServiceException;
  90. /**
  91. * @return List of managed repositories current user can read
  92. */
  93. @Path("userRepositories")
  94. @GET
  95. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  96. @RedbackAuthorization(noPermission = true, noRestriction = true)
  97. List<ManagedRepository> getUserRepositories()
  98. throws ArchivaRestServiceException;
  99. /**
  100. * @return List of repositories current user can manage
  101. */
  102. @Path("userManagableRepositories")
  103. @GET
  104. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  105. @RedbackAuthorization(noPermission = true, noRestriction = true)
  106. List<ManagedRepository> getUserManagableRepositories()
  107. throws ArchivaRestServiceException;
  108. /**
  109. * return the dependency Tree for an artifacts
  110. * <b>the List result has only one entry</b>
  111. */
  112. @Path("treeEntries/{g}/{a}/{v}")
  113. @GET
  114. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  115. @RedbackAuthorization(noPermission = true, noRestriction = true)
  116. List<TreeEntry> getTreeEntries( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  117. @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
  118. throws ArchivaRestServiceException;
  119. /**
  120. * List of artifacts using the artifact passed in parameter.
  121. */
  122. @Path("dependees/{g}/{a}/{v}")
  123. @GET
  124. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  125. @RedbackAuthorization(noPermission = true, noRestriction = true)
  126. List<Artifact> getDependees( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  127. @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
  128. throws ArchivaRestServiceException;
  129. @Path("metadatas/{g}/{a}/{v}")
  130. @GET
  131. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  132. @RedbackAuthorization(noPermission = true, noRestriction = true)
  133. List<Entry> getMetadatas( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  134. @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
  135. throws ArchivaRestServiceException;
  136. @Path("metadata/{g}/{a}/{v}/{key}/{value}")
  137. @PUT
  138. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  139. @RedbackAuthorization( permissions = "archiva-add-metadata", resource = "{repositoryId}")
  140. ActionStatus addMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  141. @PathParam("v") String version, @PathParam("key") String key, @PathParam("value") String value,
  142. @QueryParam("repositoryId") String repositoryId )
  143. throws ArchivaRestServiceException;
  144. @Path("metadata/{g}/{a}/{v}/{key}")
  145. @DELETE
  146. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  147. @RedbackAuthorization( permissions = "archiva-add-metadata", resource = "{repositoryId}")
  148. ActionStatus deleteMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  149. @PathParam("v") String version, @PathParam("key") String key,
  150. @QueryParam("repositoryId") String repositoryId )
  151. throws ArchivaRestServiceException;
  152. @Path("importMetadata")
  153. @POST
  154. @RedbackAuthorization( permissions = "archiva-add-metadata", resource = "{repository}")
  155. ActionStatus importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam("repository") String repository )
  156. throws ArchivaRestServiceException;
  157. @Path("artifactContentEntries/{g}/{a}/{v}")
  158. @GET
  159. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  160. @RedbackAuthorization(noPermission = true, noRestriction = true)
  161. List<ArtifactContentEntry> getArtifactContentEntries( @PathParam("g") String groupId,
  162. @PathParam("a") String artifactId,
  163. @PathParam("v") String version,
  164. @QueryParam("c") String classifier,
  165. @QueryParam("t") String type, @QueryParam("p") String path,
  166. @QueryParam("repositoryId") String repositoryId )
  167. throws ArchivaRestServiceException;
  168. @Path("artifactDownloadInfos/{g}/{a}/{v}")
  169. @GET
  170. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  171. @RedbackAuthorization(noPermission = true, noRestriction = true)
  172. List<Artifact> getArtifactDownloadInfos( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  173. @PathParam("v") String version,
  174. @QueryParam("repositoryId") String repositoryId )
  175. throws ArchivaRestServiceException;
  176. /**
  177. * if path is empty content of the file is returned (for pom view)
  178. */
  179. @Path("artifactContentText/{g}/{a}/{v}")
  180. @GET
  181. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  182. @RedbackAuthorization(noPermission = true, noRestriction = true)
  183. ArtifactContent getArtifactContentText( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  184. @PathParam("v") String version, @QueryParam("c") String classifier,
  185. @QueryParam("t") String type, @QueryParam("p") String path,
  186. @QueryParam("repositoryId") String repositoryId )
  187. throws ArchivaRestServiceException;
  188. /**
  189. * verify if an artifact is available locally if not download from proxies will be try
  190. *
  191. * @since 1.4-M3
  192. */
  193. @Path("artifactAvailable/{g}/{a}/{v}")
  194. @GET
  195. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  196. @RedbackAuthorization(noPermission = true, noRestriction = true)
  197. AvailabilityStatus artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId,
  198. @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
  199. throws ArchivaRestServiceException;
  200. /**
  201. * verify if an artifact is available locally if not download from proxies will be try
  202. *
  203. * @since 1.4-M4
  204. */
  205. @Path( "artifactAvailable/{g}/{a}/{v}/{c}" )
  206. @GET
  207. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  208. @RedbackAuthorization( noPermission = true, noRestriction = true )
  209. AvailabilityStatus artifactAvailable( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
  210. @PathParam( "v" ) String version, @PathParam( "c" ) String classifier,
  211. @QueryParam( "repositoryId" ) String repositoryId )
  212. throws ArchivaRestServiceException;
  213. /**
  214. * return List of all artifacts from this repository
  215. *
  216. * @param repositoryId
  217. * @return
  218. * @throws ArchivaRestServiceException
  219. * @since 1.4-M3
  220. */
  221. @Path("artifacts/{r}")
  222. @GET
  223. @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  224. @RedbackAuthorization(noPermission = true, noRestriction = true)
  225. List<Artifact> getArtifacts( @PathParam("r") String repositoryId )
  226. throws ArchivaRestServiceException;
  227. /**
  228. * Return List of artifacts from this repository with project version level metadata key matching value. If
  229. * repository is not provided the search runs in all repositories.
  230. *
  231. * @param key
  232. * @param value
  233. * @param repositoryId
  234. * @return
  235. * @throws ArchivaRestServiceException
  236. * @since 2.2
  237. */
  238. @Path( "artifactsByProjectVersionMetadata/{key}/{value}" )
  239. @GET
  240. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  241. @RedbackAuthorization( noPermission = true, noRestriction = true )
  242. List<Artifact> getArtifactsByProjectVersionMetadata( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
  243. @QueryParam("repositoryId") String repositoryId )
  244. throws ArchivaRestServiceException;
  245. /**
  246. * Return List of artifacts from this repository with artifact metadata key matching value.
  247. * If repository is not provided the search runs in all repositories.
  248. *
  249. * @param key
  250. * @param value
  251. * @param repositoryId
  252. * @return
  253. * @throws ArchivaRestServiceException
  254. * @since 2.2
  255. */
  256. @Path( "artifactsByMetadata/{key}/{value}" )
  257. @GET
  258. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  259. @RedbackAuthorization( noPermission = true, noRestriction = true )
  260. List<Artifact> getArtifactsByMetadata( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
  261. @QueryParam("repositoryId") String repositoryId )
  262. throws ArchivaRestServiceException;
  263. /**
  264. * Return List of artifacts from this repository with property key matching value.
  265. * If repository is not provided the search runs in all repositories.
  266. *
  267. * @param key
  268. * @param value
  269. * @param repositoryId
  270. * @return
  271. * @throws ArchivaRestServiceException
  272. * @since 2.2
  273. */
  274. @Path( "artifactsByProperty/{key}/{value}" )
  275. @GET
  276. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  277. @RedbackAuthorization( noPermission = true, noRestriction = true )
  278. List<Artifact> getArtifactsByProperty( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
  279. @QueryParam("repositoryId") String repositoryId )
  280. throws ArchivaRestServiceException;
  281. /**
  282. * Search artifacts with any property matching text. If repository is not provided the search runs in all
  283. * repositories. If exact is true only the artifacts whose property match exactly are returned.
  284. *
  285. * @param text
  286. * @param repositoryId
  287. * @param exact
  288. * @return
  289. * @throws ArchivaRestServiceException
  290. * @since 2.2
  291. */
  292. @Path( "searchArtifacts/{text}" )
  293. @GET
  294. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  295. @RedbackAuthorization( noPermission = true, noRestriction = true )
  296. List<Artifact> searchArtifacts( @PathParam( "text" ) String text,
  297. @QueryParam( "repositoryId" ) String repositoryId,
  298. @QueryParam( "exact" ) Boolean exact )
  299. throws ArchivaRestServiceException;
  300. /**
  301. * Search artifacts with the property specified by key matching text. If repository is not provided the search runs
  302. * in all repositories. If exact is true only the artifacts whose property match exactly are returned.
  303. *
  304. * @param key
  305. * @param text
  306. * @param repositoryId
  307. * @param exact
  308. * @return
  309. * @throws ArchivaRestServiceException
  310. * @since 2.2
  311. */
  312. @Path( "searchArtifacts/{key}/{text}" )
  313. @GET
  314. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  315. @RedbackAuthorization( noPermission = true, noRestriction = true )
  316. List<Artifact> searchArtifacts( @PathParam( "key" ) String key, @PathParam( "text" ) String text,
  317. @QueryParam( "repositoryId" ) String repositoryId,
  318. @QueryParam( "exact" ) Boolean exact )
  319. throws ArchivaRestServiceException;
  320. }