This project has retired. For details please refer to its Attic page.
SearchService xref
View Javadoc
1   package org.apache.archiva.rest.api.services;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  
23  import org.apache.archiva.maven2.model.Artifact;
24  import org.apache.archiva.redback.authorization.RedbackAuthorization;
25  import org.apache.archiva.rest.api.model.ChecksumSearch;
26  import org.apache.archiva.rest.api.model.GroupIdList;
27  import org.apache.archiva.rest.api.model.SearchRequest;
28  import org.apache.archiva.rest.api.model.StringList;
29  
30  import javax.ws.rs.DefaultValue;
31  import javax.ws.rs.GET;
32  import javax.ws.rs.POST;
33  import javax.ws.rs.Path;
34  import javax.ws.rs.Produces;
35  import javax.ws.rs.QueryParam;
36  import javax.ws.rs.core.MediaType;
37  import javax.ws.rs.core.Response;
38  import java.util.List;
39  
40  @Path( "/searchService/" )
41  public interface SearchService
42  {
43      /*
44      * quick/general text search which returns a list of artifacts
45      * query for an artifact based on a checksum
46      * query for all available versions of an artifact, sorted in version significance order
47      * query for an artifact's direct dependencies
48      * <b>search will be apply on all repositories the current user has karma</b>
49      * TODO query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included)
50      * TODO query for all artifacts that depend on a given artifact
51      */
52      @Path( "quickSearch" )
53      @GET
54      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
55      @RedbackAuthorization( noPermission = true, noRestriction = true )
56      List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
57          throws ArchivaRestServiceException;
58  
59      /**
60       * <b>if not repositories in SearchRequest: search will be apply on all repositories the current user has karma</b>
61       */
62      @Path( "quickSearchWithRepositories" )
63      @POST
64      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
65      @RedbackAuthorization( noPermission = true, noRestriction = true )
66      List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
67          throws ArchivaRestServiceException;
68  
69      /**
70       * If searchRequest contains repositories, the search will be done only on those repositories.
71       * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
72       */
73      @Path( "searchArtifacts" )
74      @POST
75      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
76      @RedbackAuthorization( noPermission = true, noRestriction = true )
77      List<Artifact> searchArtifacts( SearchRequest searchRequest )
78          throws ArchivaRestServiceException;
79  
80      /**
81       * <b>search will be apply on all repositories the current user has karma</b>
82       */
83      @Path( "getArtifactVersions" )
84      @GET
85      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
86      @RedbackAuthorization( noPermission = true, noRestriction = true )
87      List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId, //
88                                          @QueryParam( "artifactId" ) String artifactId, //
89                                          @QueryParam( "packaging" ) String packaging )
90          throws ArchivaRestServiceException;
91  
92  
93      /**
94       * <b>this method applies on Maven Indexer lucene index, so datas not yet indexed won't be available</b>
95       */
96      @Path( "getAllGroupIds" )
97      @GET
98      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
99      @RedbackAuthorization( noPermission = true, noRestriction = false )
100     GroupIdList getAllGroupIds( @QueryParam( "selectedRepos" ) List<String> selectedRepos )
101         throws ArchivaRestServiceException;
102 
103     /**
104      * @since 1.4-M3
105      */
106     @Path( "observableRepoIds" )
107     @GET
108     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
109     @RedbackAuthorization( noPermission = true, noRestriction = true )
110     StringList getObservablesRepoIds()
111         throws ArchivaRestServiceException;
112 
113     /*
114     @Path( "getDependencies" )
115     @GET
116     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
117     @RedbackAuthorization( noPermission = true, noRestriction = true )
118     List<Dependency> getDependencies( @QueryParam( "groupId" ) String groupId,
119                                       @QueryParam( "artifactId" ) String artifactId,
120                                       @QueryParam( "version" ) String version )
121         throws ArchivaRestServiceException;
122     */
123 
124     /**
125      * Returns a redirect to a artifact file, that matches given search parameter
126      * @param repositoryId The repository id (optional)
127      * @param groupId The search pattern for the group id of the artifact (required)
128      * @param artifactId  The search pattern for the artifact id of the artifact (required)
129      * @param version The search pattern for the version of the artifact (required)
130      *                LATEST returns the latest version of the artifact.
131      * @param packaging the packaging
132      * @param classifier the artifact classifier
133      * @param literalVersion true, if the version string should be treated literally, which means
134      *                       LATEST search for versions with LATEST in the version string.
135      *                       false, is default and treats v=LATEST special
136      * @return the redirect response, if a artifact was found
137      * @throws ArchivaRestServiceException
138      */
139     @GET
140     @Path( "/artifact" )
141     @Produces( "text/html" )
142     @RedbackAuthorization( noPermission = true, noRestriction = true )
143     Response redirectToArtifactFile( @QueryParam( "r" ) String repositoryId, //
144                                      @QueryParam( "g" ) String groupId, //
145                                      @QueryParam( "a" ) String artifactId, //
146                                      @QueryParam( "v" ) String version, //
147                                      @QueryParam( "p" ) String packaging, //
148                                      @QueryParam( "c" ) String classifier,
149                                      @DefaultValue( "false" )
150                                      @QueryParam( "literalVersion" ) Boolean literalVersion)
151         throws ArchivaRestServiceException;
152 
153 
154     /**
155      * If searchRequest contains repositories, the search will be done only on those repositories.
156      * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
157      */
158     @Path( "artifactsByChecksum" )
159     @POST
160     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
161     @RedbackAuthorization( noPermission = true, noRestriction = true )
162     List<Artifact> getArtifactByChecksum( ChecksumSearch checksumSearch )
163         throws ArchivaRestServiceException;
164 
165 
166 }