1 package org.apache.archiva.rest.api.services.v2;
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.OAuthScope;
27 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import org.apache.archiva.components.rest.model.PagedResult;
30 import org.apache.archiva.redback.authorization.RedbackAuthorization;
31 import org.apache.archiva.rest.api.model.v2.FileInfo;
32 import org.apache.archiva.rest.api.model.v2.MavenManagedRepository;
33 import org.apache.archiva.rest.api.model.v2.MavenManagedRepositoryUpdate;
34 import org.apache.archiva.security.common.ArchivaRoleConstants;
36 import javax.ws.rs.Consumes;
37 import javax.ws.rs.DELETE;
38 import javax.ws.rs.DefaultValue;
39 import javax.ws.rs.GET;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.PUT;
42 import javax.ws.rs.Path;
43 import javax.ws.rs.PathParam;
44 import javax.ws.rs.Produces;
45 import javax.ws.rs.QueryParam;
46 import javax.ws.rs.core.MediaType;
47 import javax.ws.rs.core.Response;
48 import java.util.List;
50 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
51 import static org.apache.archiva.rest.api.services.v2.RestConfiguration.DEFAULT_PAGE_LIMIT;
54 * @author Martin Stockhammer <martin_s@apache.org>
57 @Schema( name = "ManagedRepositoryService", description = "Managing and configuration of managed repositories" )
58 @Path( "repositories/maven/managed" )
60 @Tag(name = "v2/Repositories")
61 public interface MavenManagedRepositoryService
65 @Produces( {APPLICATION_JSON} )
66 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
67 @Operation( summary = "Returns all managed repositories.",
69 @Parameter( name = "q", description = "Search term" ),
70 @Parameter( name = "offset", description = "The offset of the first element returned" ),
71 @Parameter( name = "limit", description = "Maximum number of items to return in the response" ),
72 @Parameter( name = "orderBy", description = "List of attribute used for sorting (key, value)" ),
73 @Parameter( name = "order", description = "The sort order. Either ascending (asc) or descending (desc)" )
77 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
81 @ApiResponse( responseCode = "200",
82 description = "If the list could be returned",
83 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = PagedResult.class ) )
85 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
86 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
89 PagedResult<MavenManagedRepository> getManagedRepositories(
90 @QueryParam( "q" ) @DefaultValue( "" ) String searchTerm,
91 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
92 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
93 @QueryParam( "orderBy" ) @DefaultValue( "id" ) List<String> orderBy,
94 @QueryParam( "order" ) @DefaultValue( "asc" ) String order )
95 throws ArchivaRestServiceException;
100 @Produces( {MediaType.APPLICATION_JSON} )
101 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
102 @Operation( summary = "Returns the managed repository with the given id.",
104 @SecurityRequirement(
105 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
109 @ApiResponse( responseCode = "200",
110 description = "If the managed repository could be returned",
111 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
113 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
114 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
115 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
116 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
119 MavenManagedRepository getManagedRepository( @PathParam( "id" ) String repositoryId )
120 throws ArchivaRestServiceException;
125 @Produces( {MediaType.APPLICATION_JSON} )
126 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
127 @Operation( summary = "Deletes the managed repository with the given id.",
129 @SecurityRequirement(
130 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
134 @ApiResponse( responseCode = "200",
135 description = "If the managed repository could be returned"
137 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
138 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
139 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
140 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
143 Response deleteManagedRepository( @PathParam( "id" ) String repositoryId,
144 @QueryParam( "deleteContent" ) boolean deleteContent )
145 throws ArchivaRestServiceException;
150 @Consumes( {MediaType.APPLICATION_JSON} )
151 @Produces( {MediaType.APPLICATION_JSON} )
152 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
153 @Operation( summary = "Creates the managed repository",
155 @SecurityRequirement(
156 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
160 @ApiResponse( responseCode = "201",
161 description = "If the managed repository could be created",
162 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
164 @ApiResponse( responseCode = "303", description = "The repository exists already",
166 @Header( name = "Location", description = "The URL of existing repository ", schema = @Schema( type = "string" ) )
169 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
170 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
171 @ApiResponse( responseCode = "422", description = "The body data is not valid",
172 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
175 MavenManagedRepository addManagedRepository( MavenManagedRepository managedRepository )
176 throws ArchivaRestServiceException;
181 @Consumes( {MediaType.APPLICATION_JSON} )
182 @Produces( {MediaType.APPLICATION_JSON} )
183 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
184 @Operation( summary = "Updates the managed repository with the given id",
186 @SecurityRequirement(
187 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
191 @ApiResponse( responseCode = "200",
192 description = "If the managed repository could be updated",
193 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
195 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
196 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
197 @ApiResponse( responseCode = "422", description = "The body data is not valid",
198 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
199 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
200 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
203 MavenManagedRepository updateManagedRepository( @PathParam( "id" ) String repositoryId, MavenManagedRepositoryUpdate managedRepository )
204 throws ArchivaRestServiceException;
207 @Path( "{id}/path/{filePath: .+}" )
209 @Produces( {MediaType.APPLICATION_JSON} )
210 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, resource = "{id}")
211 @Operation( summary = "Returns the status of a given file in the repository",
213 @SecurityRequirement(
214 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
218 @ApiResponse( responseCode = "200",
219 description = "If the file status is returned",
220 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = FileInfo.class ) )
222 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
223 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
224 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the file does not exist.",
225 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
228 FileInfo getFileStatus( @PathParam( "id" ) String repositoryId, @PathParam( "filePath" ) String fileLocation )
229 throws ArchivaRestServiceException;
233 * Permissions are checked in impl
234 * will copy an artifact from the source repository to the target repository
236 @Path ("{srcId}/path/{path: .+}/copyto/{dstId}")
238 @Produces({APPLICATION_JSON})
239 @RedbackAuthorization (noPermission = true)
240 @Operation( summary = "Copies a artifact from the source repository to the destination repository",
242 @SecurityRequirement(
243 name = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS,
248 @SecurityRequirement(
249 name= ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD,
257 @ApiResponse( responseCode = "200",
258 description = "If the artifact was copied"
260 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
261 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
262 @ApiResponse( responseCode = "404", description = "The repository does not exist, or if the artifact was not found",
263 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
266 Response copyArtifact( @PathParam( "srcId" ) String srcRepositoryId, @PathParam( "dstId" ) String dstRepositoryId,
267 @PathParam( "path" ) String path )
268 throws ArchivaRestServiceException;
271 @Path ("{id}/path/{path: .+}")
273 @Consumes ({ APPLICATION_JSON })
274 @RedbackAuthorization (noPermission = true)
275 @Operation( summary = "Deletes a artifact in the repository.",
277 @SecurityRequirement(
278 name = ArchivaRoleConstants.OPERATION_RUN_INDEXER
282 @ApiResponse( responseCode = "200",
283 description = "If the artifact was deleted"
285 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
286 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
287 @ApiResponse( responseCode = "404", description = "The repository or the artifact does not exist",
288 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
291 Response deleteArtifact( @PathParam( "id" ) String repositoryId, @PathParam( "path" ) String path )
292 throws ArchivaRestServiceException;
294 @Path ( "{id}/co/{group}/{project}/{version}" )
296 @Produces ({ MediaType.APPLICATION_JSON })
297 @RedbackAuthorization (noPermission = true)
298 @Operation( summary = "Removes a version tree in the repository",
300 @SecurityRequirement(
301 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
305 @ApiResponse( responseCode = "200",
306 description = "If the deletion was successful"
308 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
309 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
310 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the version does not exist.",
311 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
314 Response removeProjectVersion( @PathParam ( "id" ) String repositoryId,
315 @PathParam ( "group" ) String namespace, @PathParam ( "project" ) String projectId,
316 @PathParam ( "version" ) String version )
317 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
320 @Path ( "{id}/co/{group}/{project}" )
322 @Produces ({ MediaType.APPLICATION_JSON })
323 @RedbackAuthorization (noPermission = true)
324 @Operation( summary = "Removes a project tree in the repository",
326 @SecurityRequirement(
327 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
331 @ApiResponse( responseCode = "200",
332 description = "If the deletion was successful"
334 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
335 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
336 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the project does not exist.",
337 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
340 Response deleteProject( @PathParam ("id") String repositoryId, @PathParam ( "group" ) String namespace, @PathParam ( "project" ) String projectId )
341 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
343 @Path ( "{id}/co/{namespace}" )
345 @Produces ({ MediaType.APPLICATION_JSON })
346 @RedbackAuthorization (noPermission = true)
347 @Operation( summary = "Removes a namespace tree in the repository",
349 @SecurityRequirement(
350 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
354 @ApiResponse( responseCode = "200",
355 description = "If the deletion was successful"
357 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete namespaces in repositories",
358 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
359 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the namespace does not exist.",
360 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
363 Response deleteNamespace( @PathParam ("id") String repositoryId, @PathParam ( "namespace" ) String namespace )
364 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;