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.

SearchService.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.maven.model.Artifact;
  22. import org.apache.archiva.redback.authorization.RedbackAuthorization;
  23. import org.apache.archiva.rest.api.model.ChecksumSearch;
  24. import org.apache.archiva.rest.api.model.GroupIdList;
  25. import org.apache.archiva.rest.api.model.SearchRequest;
  26. import org.apache.archiva.rest.api.model.StringList;
  27. import javax.ws.rs.GET;
  28. import javax.ws.rs.POST;
  29. import javax.ws.rs.Path;
  30. import javax.ws.rs.Produces;
  31. import javax.ws.rs.QueryParam;
  32. import javax.ws.rs.core.MediaType;
  33. import javax.ws.rs.core.Response;
  34. import java.util.List;
  35. @Path( "/searchService/" )
  36. @Tag( name="Search", description = "Searching repositories")
  37. public interface SearchService
  38. {
  39. /*
  40. * quick/general text search which returns a list of artifacts
  41. * query for an artifact based on a checksum
  42. * query for all available versions of an artifact, sorted in version significance order
  43. * query for an artifact's direct dependencies
  44. * <b>search will be apply on all repositories the current user has karma</b>
  45. * TODO query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included)
  46. * TODO query for all artifacts that depend on a given artifact
  47. */
  48. @Path( "quickSearch" )
  49. @GET
  50. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  51. @RedbackAuthorization( noPermission = true, noRestriction = true )
  52. List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
  53. throws ArchivaRestServiceException;
  54. /**
  55. * <b>if not repositories in SearchRequest: search will be apply on all repositories the current user has karma</b>
  56. */
  57. @Path( "quickSearchWithRepositories" )
  58. @POST
  59. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  60. @RedbackAuthorization( noPermission = true, noRestriction = true )
  61. List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
  62. throws ArchivaRestServiceException;
  63. /**
  64. * If searchRequest contains repositories, the search will be done only on those repositories.
  65. * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
  66. */
  67. @Path( "searchArtifacts" )
  68. @POST
  69. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  70. @RedbackAuthorization( noPermission = true, noRestriction = true )
  71. List<Artifact> searchArtifacts( SearchRequest searchRequest )
  72. throws ArchivaRestServiceException;
  73. /**
  74. * <b>search will be apply on all repositories the current user has karma</b>
  75. */
  76. @Path( "getArtifactVersions" )
  77. @GET
  78. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  79. @RedbackAuthorization( noPermission = true, noRestriction = true )
  80. List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId, //
  81. @QueryParam( "artifactId" ) String artifactId, //
  82. @QueryParam( "packaging" ) String packaging )
  83. throws ArchivaRestServiceException;
  84. /**
  85. * <b>this method applies on Maven Indexer lucene index, so datas not yet indexed won't be available</b>
  86. */
  87. @Path( "getAllGroupIds" )
  88. @GET
  89. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  90. @RedbackAuthorization( noPermission = true, noRestriction = false )
  91. GroupIdList getAllGroupIds( @QueryParam( "selectedRepos" ) List<String> selectedRepos )
  92. throws ArchivaRestServiceException;
  93. /**
  94. * @since 1.4-M3
  95. */
  96. @Path( "observableRepoIds" )
  97. @GET
  98. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  99. @RedbackAuthorization( noPermission = true, noRestriction = true )
  100. StringList getObservablesRepoIds()
  101. throws ArchivaRestServiceException;
  102. /*
  103. @Path( "getDependencies" )
  104. @GET
  105. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
  106. @RedbackAuthorization( noPermission = true, noRestriction = true )
  107. List<Dependency> getDependencies( @QueryParam( "groupId" ) String groupId,
  108. @QueryParam( "artifactId" ) String artifactId,
  109. @QueryParam( "version" ) String version )
  110. throws ArchivaRestServiceException;
  111. */
  112. @GET
  113. @Path( "/artifact" )
  114. @Produces( "text/html" )
  115. @RedbackAuthorization( noPermission = true, noRestriction = true )
  116. Response redirectToArtifactFile( @QueryParam( "r" ) String repositoryId, //
  117. @QueryParam( "g" ) String groupId, //
  118. @QueryParam( "a" ) String artifactId, //
  119. @QueryParam( "v" ) String version, //
  120. @QueryParam( "p" ) String packaging, //
  121. @QueryParam( "c" ) String classifier )
  122. throws ArchivaRestServiceException;
  123. /**
  124. * If searchRequest contains repositories, the search will be done only on those repositories.
  125. * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
  126. */
  127. @Path( "artifactsByChecksum" )
  128. @POST
  129. @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
  130. @RedbackAuthorization( noPermission = true, noRestriction = true )
  131. List<Artifact> getArtifactByChecksum( ChecksumSearch checksumSearch )
  132. throws ArchivaRestServiceException;
  133. }