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.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.model.v2.Artifact;
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.security.common.ArchivaRoleConstants;
35 import javax.ws.rs.Consumes;
36 import javax.ws.rs.DELETE;
37 import javax.ws.rs.DefaultValue;
38 import javax.ws.rs.GET;
39 import javax.ws.rs.POST;
40 import javax.ws.rs.PUT;
41 import javax.ws.rs.Path;
42 import javax.ws.rs.PathParam;
43 import javax.ws.rs.Produces;
44 import javax.ws.rs.QueryParam;
45 import javax.ws.rs.core.MediaType;
46 import javax.ws.rs.core.Response;
47 import java.util.List;
49 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
50 import static org.apache.archiva.rest.api.services.v2.RestConfiguration.DEFAULT_PAGE_LIMIT;
53 * @author Martin Stockhammer <martin_s@apache.org>
56 @Schema( name = "ManagedRepositoryService", description = "Managing and configuration of managed repositories" )
57 @Path( "repositories/maven/managed" )
59 @Tag(name = "v2/Repositories")
60 public interface MavenManagedRepositoryService
64 @Produces( {APPLICATION_JSON} )
65 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
66 @Operation( summary = "Returns all managed repositories.",
68 @Parameter( name = "q", description = "Search term" ),
69 @Parameter( name = "offset", description = "The offset of the first element returned" ),
70 @Parameter( name = "limit", description = "Maximum number of items to return in the response" ),
71 @Parameter( name = "orderBy", description = "List of attribute used for sorting (key, value)" ),
72 @Parameter( name = "order", description = "The sort order. Either ascending (asc) or descending (desc)" )
76 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
80 @ApiResponse( responseCode = "200",
81 description = "If the list could be returned",
82 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = PagedResult.class ) )
84 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
85 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
88 PagedResult<MavenManagedRepository> getManagedRepositories(
89 @QueryParam( "q" ) @DefaultValue( "" ) String searchTerm,
90 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
91 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
92 @QueryParam( "orderBy" ) @DefaultValue( "id" ) List<String> orderBy,
93 @QueryParam( "order" ) @DefaultValue( "asc" ) String order )
94 throws ArchivaRestServiceException;
99 @Produces( {MediaType.APPLICATION_JSON} )
100 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
101 @Operation( summary = "Returns the managed repository with the given id.",
103 @SecurityRequirement(
104 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
108 @ApiResponse( responseCode = "200",
109 description = "If the managed repository could be returned",
110 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
112 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
113 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
114 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
115 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
118 MavenManagedRepository getManagedRepository( @PathParam( "id" ) String repositoryId )
119 throws ArchivaRestServiceException;
124 @Produces( {MediaType.APPLICATION_JSON} )
125 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
126 @Operation( summary = "Deletes the managed repository with the given id.",
128 @SecurityRequirement(
129 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
133 @ApiResponse( responseCode = "200",
134 description = "If the managed repository could be returned"
136 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
137 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
138 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
139 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
142 Response deleteManagedRepository( @PathParam( "id" ) String repositoryId,
143 @QueryParam( "deleteContent" ) boolean deleteContent )
144 throws ArchivaRestServiceException;
149 @Consumes( {MediaType.APPLICATION_JSON} )
150 @Produces( {MediaType.APPLICATION_JSON} )
151 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
152 @Operation( summary = "Creates the managed repository",
154 @SecurityRequirement(
155 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
159 @ApiResponse( responseCode = "201",
160 description = "If the managed repository could be created",
161 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
163 @ApiResponse( responseCode = "303", description = "The repository exists already",
165 @Header( name = "Location", description = "The URL of existing repository ", schema = @Schema( type = "string" ) )
168 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
169 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
170 @ApiResponse( responseCode = "422", description = "The body data is not valid",
171 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
174 MavenManagedRepository addManagedRepository( MavenManagedRepository managedRepository )
175 throws ArchivaRestServiceException;
180 @Consumes( {MediaType.APPLICATION_JSON} )
181 @Produces( {MediaType.APPLICATION_JSON} )
182 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
183 @Operation( summary = "Updates the managed repository with the given id",
185 @SecurityRequirement(
186 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
190 @ApiResponse( responseCode = "200",
191 description = "If the managed repository could be updated",
192 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = MavenManagedRepository.class ) )
194 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
195 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
196 @ApiResponse( responseCode = "422", description = "The body data is not valid",
197 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
198 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist",
199 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
202 MavenManagedRepository updateManagedRepository( MavenManagedRepository managedRepository )
203 throws ArchivaRestServiceException;
206 @Path( "{id}/a/{filePath: .+}" )
208 @Produces( {MediaType.APPLICATION_JSON} )
209 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
210 @Operation( summary = "Returns the status of a given file in the repository",
212 @SecurityRequirement(
213 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
217 @ApiResponse( responseCode = "200",
218 description = "If the file status is returned",
219 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = FileInfo.class ) )
221 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to add repositories",
222 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
223 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the file does not exist.",
224 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
227 FileInfo getFileStatus( @PathParam( "id" ) String repositoryId, @PathParam( "filePath" ) String fileLocation )
228 throws ArchivaRestServiceException;
232 * permissions are checked in impl
233 * will copy an artifact from the source repository to the target repository
235 @Path ("{srcId}/a/{path: .+}/copyto/{dstId}")
237 @Produces({APPLICATION_JSON})
238 @RedbackAuthorization (noPermission = true)
239 @Operation( summary = "Copies a artifact from the source repository to the destination repository",
241 @SecurityRequirement(
242 name = ArchivaRoleConstants.OPERATION_RUN_INDEXER
246 @ApiResponse( responseCode = "200",
247 description = "If the artifact was copied"
249 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
250 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
251 @ApiResponse( responseCode = "404", description = "The repository does not exist, or if the artifact was not found",
252 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
255 Response copyArtifact( @PathParam( "srcId" ) String srcRepositoryId, @PathParam( "dstId" ) String dstRepositoryId,
256 @PathParam( "path" ) String path )
257 throws ArchivaRestServiceException;
260 @Path ("{id}/a/{path: .+}")
262 @Consumes ({ APPLICATION_JSON })
263 @RedbackAuthorization (noPermission = true)
264 @Operation( summary = "Deletes a artifact in the repository.",
266 @SecurityRequirement(
267 name = ArchivaRoleConstants.OPERATION_RUN_INDEXER
271 @ApiResponse( responseCode = "200",
272 description = "If the artifact was deleted"
274 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
275 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
276 @ApiResponse( responseCode = "404", description = "The repository or the artifact does not exist",
277 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
280 Response deleteArtifact( @PathParam( "id" ) String repositoryId, @PathParam( "path" ) String path )
281 throws ArchivaRestServiceException;
283 @Path ("{id}/c/{namespace}/{projectId}/{version}")
285 @Produces ({ MediaType.APPLICATION_JSON })
286 @RedbackAuthorization (noPermission = true)
287 @Operation( summary = "Removes a version tree in the repository",
289 @SecurityRequirement(
290 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
294 @ApiResponse( responseCode = "200",
295 description = "If the deletion was successful"
297 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
298 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
299 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the version does not exist.",
300 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
303 Response removeProjectVersion( @PathParam ( "id" ) String repositoryId,
304 @PathParam ( "namespace" ) String namespace, @PathParam ( "projectId" ) String projectId,
305 @PathParam ( "version" ) String version )
306 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
309 @Path ( "{id}/c/{namespace}/{projectId}" )
311 @Produces ({ MediaType.APPLICATION_JSON })
312 @RedbackAuthorization (noPermission = true)
313 @Operation( summary = "Removes a project tree in the repository",
315 @SecurityRequirement(
316 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
320 @ApiResponse( responseCode = "200",
321 description = "If the deletion was successful"
323 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete in repositories",
324 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
325 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the project does not exist.",
326 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
329 Response deleteProject( @PathParam ("id") String repositoryId, @PathParam ( "namespace" ) String namespace, @PathParam ("projectId") String projectId )
330 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;
332 @Path ( "{id}/c/{namespace}" )
334 @Produces ({ MediaType.APPLICATION_JSON })
335 @RedbackAuthorization (noPermission = true)
336 @Operation( summary = "Removes a namespace tree in the repository",
338 @SecurityRequirement(
339 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
343 @ApiResponse( responseCode = "200",
344 description = "If the deletion was successful"
346 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to delete namespaces in repositories",
347 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) ),
348 @ApiResponse( responseCode = "404", description = "The managed repository with this id does not exist. Or the namespace does not exist.",
349 content = @Content( mediaType = APPLICATION_JSON, schema = @Schema( implementation = ArchivaRestError.class ) ) )
352 Response deleteNamespace( @PathParam ("id") String repositoryId, @PathParam ( "namespace" ) String namespace )
353 throws org.apache.archiva.rest.api.services.ArchivaRestServiceException;