1 package org.apache.archiva.rest.api.v2.svc.maven;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 import io.swagger.v3.oas.annotations.Operation;
21 import io.swagger.v3.oas.annotations.Parameter;
22 import io.swagger.v3.oas.annotations.headers.Header;
23 import io.swagger.v3.oas.annotations.media.Content;
24 import io.swagger.v3.oas.annotations.media.Schema;
25 import io.swagger.v3.oas.annotations.responses.ApiResponse;
26 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
27 import io.swagger.v3.oas.annotations.tags.Tag;
28 import org.apache.archiva.components.rest.model.PagedResult;
29 import org.apache.archiva.redback.authorization.RedbackAuthorization;
30 import org.apache.archiva.rest.api.v2.model.FileInfo;
31 import org.apache.archiva.rest.api.v2.model.MavenManagedRepository;
32 import org.apache.archiva.rest.api.v2.model.MavenManagedRepositoryUpdate;
33 import org.apache.archiva.rest.api.v2.svc.ArchivaRestError;
34 import org.apache.archiva.rest.api.v2.svc.ArchivaRestServiceException;
35 import org.apache.archiva.security.common.ArchivaRoleConstants;
37 import javax.ws.rs.Consumes;
38 import javax.ws.rs.DELETE;
39 import javax.ws.rs.DefaultValue;
40 import javax.ws.rs.GET;
41 import javax.ws.rs.POST;
42 import javax.ws.rs.PUT;
43 import javax.ws.rs.Path;
44 import javax.ws.rs.PathParam;
45 import javax.ws.rs.Produces;
46 import javax.ws.rs.QueryParam;
47 import javax.ws.rs.core.MediaType;
48 import javax.ws.rs.core.Response;
49 import java.util.List;
51 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
52 import static org.apache.archiva.rest.api.v2.svc.RestConfiguration.DEFAULT_PAGE_LIMIT;
55 * Service interface for managing managed maven repositories
57 * @author Martin Stockhammer <martin_s@apache.org>
60 @Schema( name = "ManagedRepositoryService", description = "Managing and configuration of managed repositories" )
61 @Path( "repositories/maven/managed" )
63 @Tag(name = "v2/Repositories")
64 public interface MavenManagedRepositoryService
68 @Produces( {APPLICATION_JSON} )
69 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
70 @Operation( summary = "Returns all managed repositories.",
72 @Parameter( name = "q", description = "Search term" ),
73 @Parameter( name = "offset", description = "The offset of the first element returned" ),
74 @Parameter( name = "limit", description = "Maximum number of items to return in the response" ),
75 @Parameter( name = "orderBy", description = "List of attribute used for sorting (key, value)" ),
76 @Parameter( name = "order", description = "The sort order. Either ascending (asc) or descending (desc)" )
80 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
84 @ApiResponse( responseCode = "200",
85 description = "If the list could be returned",
86 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = PagedResult.class ) )
88 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
89 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
92 PagedResult<MavenManagedRepository> getManagedRepositories(
93 @QueryParam( "q" ) @DefaultValue( "" ) String searchTerm,
94 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
95 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
96 @QueryParam( "orderBy" ) @DefaultValue( "id" ) List<String> orderBy,
97 @QueryParam( "order" ) @DefaultValue( "asc" ) String order )
98 throws ArchivaRestServiceException;
103 @Produces( {MediaType.APPLICATION_JSON} )
104 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
105 @Operation( summary = "Returns the managed repository with the given id.",
107 @SecurityRequirement(
108 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
112 @ApiResponse( responseCode = "200",
113 description = "If the managed repository could be returned",
114 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
116 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
117 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
118 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
119 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
122 MavenManagedRepository getManagedRepository( @PathParam( "id" ) String repositoryId )
123 throws ArchivaRestServiceException;
128 @Produces( {MediaType.APPLICATION_JSON} )
129 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
130 @Operation( summary = "Deletes the managed repository with the given id.",
132 @SecurityRequirement(
133 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
137 @ApiResponse( responseCode = "200",
138 description = "If the managed repository could be returned"
140 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
141 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
142 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
143 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
146 Response deleteManagedRepository( @PathParam( "id" ) String repositoryId,
147 @QueryParam( "deleteContent" ) boolean deleteContent )
148 throws ArchivaRestServiceException;
153 @Consumes( {MediaType.APPLICATION_JSON} )
154 @Produces( {MediaType.APPLICATION_JSON} )
155 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
156 @Operation( summary = "Creates the managed repository",
158 @SecurityRequirement(
159 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
163 @ApiResponse( responseCode = "201",
164 description = "If the managed repository could be created",
165 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
167 @ApiResponse( responseCode = "303", description = "The repository exists already",
169 @Header( name = "Location", description = "The URL of existing repository ", schema = @Schema( type = "string" ) )
172 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
173 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
174 @ApiResponse( responseCode = "422", description = "The body data is not valid",
175 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
178 MavenManagedRepository addManagedRepository( MavenManagedRepository managedRepository )
179 throws ArchivaRestServiceException;
184 @Consumes( {MediaType.APPLICATION_JSON} )
185 @Produces( {MediaType.APPLICATION_JSON} )
186 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
187 @Operation( summary = "Updates the managed repository with the given id",
189 @SecurityRequirement(
190 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
194 @ApiResponse( responseCode = "200",
195 description = "If the managed repository could be updated",
196 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
198 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
199 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
200 @ApiResponse( responseCode = "422", description = "The body data is not valid",
201 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
202 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
203 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
206 MavenManagedRepository updateManagedRepository( @PathParam( "id" ) String repositoryId, MavenManagedRepositoryUpdate managedRepository )
207 throws ArchivaRestServiceException;
210 @Path( "{id}/path/{filePath: .+}" )
212 @Produces( {MediaType.APPLICATION_JSON} )
213 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, resource = "{id}")
214 @Operation( summary = "Returns the status of a given file in the repository",
216 @SecurityRequirement(
217 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
221 @ApiResponse( responseCode = "200",
222 description = "If the file status is returned",
223 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = FileInfo.class ) )
225 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
226 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
227 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the file does not exist.",
228 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
231 FileInfo getFileStatus( @PathParam( "id" ) String repositoryId, @PathParam( "filePath" ) String fileLocation )
232 throws ArchivaRestServiceException;
236 * Permissions are checked in impl
237 * will copy an artifact from the source repository to the target repository
239 @Path ("{srcId}/path/{path: .+}/copyto/{dstId}")
241 @Produces({APPLICATION_JSON})
242 @RedbackAuthorization (noPermission = true)
243 @Operation( summary = "Copies a artifact from the source repository to the destination repository",
245 @SecurityRequirement(
246 name = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS,
251 @SecurityRequirement(
252 name= ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD,
260 @ApiResponse( responseCode = "200",
261 description = "If the artifact was copied"
263 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
264 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
265 @ApiResponse( responseCode = "404", description = "The repository does not exist, or if the artifact was not found",
266 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
269 Response copyArtifact( @PathParam( "srcId" ) String srcRepositoryId, @PathParam( "dstId" ) String dstRepositoryId,
270 @PathParam( "path" ) String path )
271 throws ArchivaRestServiceException;
274 @Path ("{id}/path/{path: .+}")
276 @Consumes ({ APPLICATION_JSON })
277 @RedbackAuthorization (noPermission = true)
278 @Operation( summary = "Deletes a artifact in the repository.",
280 @SecurityRequirement(
281 name = ArchivaRoleConstants.OPERATION_RUN_INDEXER
285 @ApiResponse( responseCode = "200",
286 description = "If the artifact was deleted"
288 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
289 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
290 @ApiResponse( responseCode = "404", description = "The repository or the artifact does not exist",
291 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
294 Response deleteArtifact( @PathParam( "id" ) String repositoryId, @PathParam( "path" ) String path )
295 throws ArchivaRestServiceException;
297 @Path ( "{id}/co/{group}/{project}/{version}" )
299 @Produces ({ MediaType.APPLICATION_JSON })
300 @RedbackAuthorization (noPermission = true)
301 @Operation( summary = "Removes a version tree in the repository",
303 @SecurityRequirement(
304 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
308 @ApiResponse( responseCode = "200",
309 description = "If the deletion was successful"
311 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
312 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
313 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the version does not exist.",
314 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
317 Response removeProjectVersion( @PathParam ( "id" ) String repositoryId,
318 @PathParam ( "group" ) String namespace, @PathParam ( "project" ) String projectId,
319 @PathParam ( "version" ) String version )
320 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
323 @Path ( "{id}/co/{group}/{project}" )
325 @Produces ({ MediaType.APPLICATION_JSON })
326 @RedbackAuthorization (noPermission = true)
327 @Operation( summary = "Removes a project tree in the repository",
329 @SecurityRequirement(
330 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
334 @ApiResponse( responseCode = "200",
335 description = "If the deletion was successful"
337 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
338 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
339 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the project does not exist.",
340 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
343 Response deleteProject( @PathParam ("id") String repositoryId, @PathParam ( "group" ) String namespace, @PathParam ( "project" ) String projectId )
344 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
346 @Path ( "{id}/co/{namespace}" )
348 @Produces ({ MediaType.APPLICATION_JSON })
349 @RedbackAuthorization (noPermission = true)
350 @Operation( summary = "Removes a namespace tree in the repository",
352 @SecurityRequirement(
353 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
357 @ApiResponse( responseCode = "200",
358 description = "If the deletion was successful"
360 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete namespaces in repositories",
361 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
362 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the namespace does not exist.",
363 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
366 Response deleteNamespace( @PathParam ("id") String repositoryId, @PathParam ( "namespace" ) String namespace )
367 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;