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