This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.rest.api.services;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.archiva.admin.model.beans.ManagedRepository;
022import org.apache.archiva.maven2.model.Artifact;
023import org.apache.archiva.maven2.model.TreeEntry;
024import org.apache.archiva.metadata.model.ProjectVersionMetadata;
025import org.apache.archiva.redback.authorization.RedbackAuthorization;
026import org.apache.archiva.rest.api.model.ArtifactContent;
027import org.apache.archiva.rest.api.model.ArtifactContentEntry;
028import org.apache.archiva.rest.api.model.BrowseResult;
029import org.apache.archiva.rest.api.model.Entry;
030import org.apache.archiva.rest.api.model.MetadataAddRequest;
031import org.apache.archiva.rest.api.model.VersionsList;
032
033import javax.ws.rs.DELETE;
034import javax.ws.rs.GET;
035import javax.ws.rs.POST;
036import javax.ws.rs.PUT;
037import javax.ws.rs.Path;
038import javax.ws.rs.PathParam;
039import javax.ws.rs.Produces;
040import javax.ws.rs.QueryParam;
041import javax.ws.rs.core.MediaType;
042import java.util.List;
043
044/**
045 * @author Olivier Lamy
046 * @since 1.4-M3
047 */
048@Path("/browseService/")
049public interface BrowseService
050{
051    @Path("rootGroups")
052    @GET
053    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
054    @RedbackAuthorization(noPermission = true, noRestriction = true)
055    BrowseResult getRootGroups( @QueryParam("repositoryId") String repositoryId )
056        throws ArchivaRestServiceException;
057
058    /**
059     * @param groupId      groupId to browse
060     * @param repositoryId optionnal (repository to browse if <code>null</code> all available user repositories are used)
061     */
062    @Path("browseGroupId/{groupId}")
063    @GET
064    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
065    @RedbackAuthorization(noPermission = true, noRestriction = true)
066    BrowseResult browseGroupId( @PathParam("groupId") String groupId, @QueryParam("repositoryId") String repositoryId )
067        throws ArchivaRestServiceException;
068
069    @Path("versionsList/{g}/{a}")
070    @GET
071    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
072    @RedbackAuthorization(noPermission = true, noRestriction = true)
073    VersionsList getVersionsList( @PathParam("g") String groupId, @PathParam("a") String artifactId,
074                                  @QueryParam("repositoryId") String repositoryId )
075        throws ArchivaRestServiceException;
076
077    @Path("projectVersionMetadata/{g}/{a}")
078    @GET
079    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
080    @RedbackAuthorization(noPermission = true, noRestriction = true)
081    ProjectVersionMetadata getProjectVersionMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
082                                                      @QueryParam("repositoryId") String repositoryId )
083        throws ArchivaRestServiceException;
084
085    @Path("projectVersionMetadata/{g}/{a}/{v}")
086    @GET
087    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
088    @RedbackAuthorization(noPermission = true, noRestriction = true)
089    ProjectVersionMetadata getProjectMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId,
090                                               @PathParam("v") String version,
091                                               @QueryParam("repositoryId") String repositoryId )
092        throws ArchivaRestServiceException;
093
094    /**
095     * @return List of managed repositories current user can read
096     */
097    @Path("userRepositories")
098    @GET
099    @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}