001    package 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    
023    import org.apache.archiva.maven2.model.Artifact;
024    import org.apache.archiva.rest.api.model.GroupIdList;
025    import org.apache.archiva.rest.api.model.SearchRequest;
026    import org.apache.archiva.rest.api.model.StringList;
027    import org.apache.archiva.redback.authorization.RedbackAuthorization;
028    
029    import javax.ws.rs.GET;
030    import javax.ws.rs.POST;
031    import javax.ws.rs.Path;
032    import javax.ws.rs.Produces;
033    import javax.ws.rs.QueryParam;
034    import javax.ws.rs.core.MediaType;
035    import java.util.List;
036    
037    @Path( "/searchService/" )
038    public interface SearchService
039    {
040        /*
041        * quick/general text search which returns a list of artifacts
042        * query for an artifact based on a checksum
043        * query for all available versions of an artifact, sorted in version significance order
044        * query for an artifact's direct dependencies
045        * <b>search will be apply on all repositories the current user has karma</b>
046        * TODO query for an artifact's dependency tree (as with mvn dependency:tree - no duplicates should be included)
047        * TODO query for all artifacts that depend on a given artifact
048        */
049        @Path( "quickSearch" )
050        @GET
051        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
052        @RedbackAuthorization( noPermission = true, noRestriction = true )
053        List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
054            throws ArchivaRestServiceException;
055    
056        /**
057         * <b>if not repositories in SearchRequest: search will be apply on all repositories the current user has karma</b>
058         */
059        @Path( "quickSearchWithRepositories" )
060        @POST
061        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
062        @RedbackAuthorization( noPermission = true, noRestriction = true )
063    
064       List<Artifact> quickSearchWithRepositories( SearchRequest searchRequest )
065            throws ArchivaRestServiceException;
066    
067        /**
068         * If searchRequest contains repositories, the search will be done only on those repositories.
069         * <b>if no repositories, the search will be apply on all repositories the current user has karma</b>
070         */
071        @Path( "searchArtifacts" )
072        @POST
073        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
074        @RedbackAuthorization( noPermission = true, noRestriction = true )
075        List<Artifact> searchArtifacts( SearchRequest searchRequest )
076            throws ArchivaRestServiceException;
077    
078        /**
079         * <b>search will be apply on all repositories the current user has karma</b>
080         */
081        @Path( "getArtifactVersions" )
082        @GET
083        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
084        @RedbackAuthorization( noPermission = true, noRestriction = true )
085        List<Artifact> getArtifactVersions( @QueryParam( "groupId" ) String groupId,
086                                            @QueryParam( "artifactId" ) String artifactId,
087                                            @QueryParam( "packaging" ) String packaging )
088            throws ArchivaRestServiceException;
089    
090    
091        /**
092         * <b>this method applies on Maven Indexer lucene index, so datas not yet indexed won't be available</b>
093         */
094        @Path( "getAllGroupIds" )
095        @GET
096        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
097        @RedbackAuthorization( noPermission = true, noRestriction = false )
098        GroupIdList getAllGroupIds( @QueryParam( "selectedRepos" ) List<String> selectedRepos )
099            throws ArchivaRestServiceException;
100    
101        /**
102         * @since 1.4-M3
103         */
104        @Path( "observableRepoIds" )
105        @GET
106        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
107        @RedbackAuthorization( noPermission = true, noRestriction = true )
108        StringList getObservablesRepoIds()
109            throws ArchivaRestServiceException;
110    
111        /*
112        @Path( "getDependencies" )
113        @GET
114        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
115        @RedbackAuthorization( noPermission = true, noRestriction = true )
116        List<Dependency> getDependencies( @QueryParam( "groupId" ) String groupId,
117                                          @QueryParam( "artifactId" ) String artifactId,
118                                          @QueryParam( "version" ) String version )
119            throws ArchivaRestServiceException;
120    
121    
122        @Path( "getArtifactByChecksum" )
123        @GET
124        @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
125        @RedbackAuthorization( noPermission = true, noRestriction = true )
126        List<Artifact> getArtifactByChecksum( @QueryParam( "checksum" ) String checksum )
127            throws ArchivaRestServiceException;
128        */
129    
130    }