This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.rest.api.services;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022
023import org.apache.archiva.maven2.model.Artifact;
024import org.apache.archiva.redback.authorization.RedbackAuthorization;
025import org.apache.archiva.rest.api.model.ChecksumSearch;
026import org.apache.archiva.rest.api.model.GroupIdList;
027import org.apache.archiva.rest.api.model.SearchRequest;
028import org.apache.archiva.rest.api.model.StringList;
029
030import javax.ws.rs.DefaultValue;
031import javax.ws.rs.GET;
032import javax.ws.rs.POST;
033import javax.ws.rs.Path;
034import javax.ws.rs.Produces;
035import javax.ws.rs.QueryParam;
036import javax.ws.rs.core.MediaType;
037import javax.ws.rs.core.Response;
038import java.util.List;
039
040@Path( "/searchService/" )
041public interface SearchService
042{
043    /*
044    * quick/general text search which returns a list of artifacts
045    * query for an artifact based on a checksum
046    * query for all available versions of an artifact, sorted in version significance order
047    * query for an artifact's direct dependencies
048    * <b>search will be apply on all repositories the current user has karma</b>
049    * TODO query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included)
050    * TODO query for all artifacts that depend on a given artifact
051    */
052    @Path( "quickSearch" )
053    @GET
054    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
055    @RedbackAuthorization( noPermission = true, noRestriction = true )
056    List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
057        throws ArchivaRestServiceException;
058
059    /**
060     * <b>if not repositories in SearchRequest: search will be apply on all repositories the current user has karma</b>
061     */
062    @Path( "quickSearchWithRepositories" )
063    @POST
064    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
065    @RedbackAuthorization( noPermission = true, noRestriction = true )
066    List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
067        throws ArchivaRestServiceException;
068
069    /**
070     * If searchRequest contains repositories, the search will be done only on those repositories.
071     * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
072     */
073    @Path( "searchArtifacts" )
074    @POST
075    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
076    @RedbackAuthorization( noPermission = true, noRestriction = true )
077    List<Artifact> searchArtifacts( SearchRequest searchRequest )
078        throws ArchivaRestServiceException;
079
080    /**
081     * <b>search will be apply on all repositories the current user has karma</b>
082     */
083    @Path( "getArtifactVersions" )
084    @GET
085    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
086    @RedbackAuthorization( noPermission = true, noRestriction = true )
087    List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId, //
088                                        @QueryParam( "artifactId" ) String artifactId, //
089                                        @QueryParam( "packaging" ) String packaging )
090        throws ArchivaRestServiceException;
091
092
093    /**
094     * <b>this method applies on Maven Indexer lucene index, so datas not yet indexed won't be available</b>
095     */
096    @Path( "getAllGroupIds" )
097    @GET
098    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
099    @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}