001package org.apache.archiva.web.api; 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.rest.api.services.ArchivaRestServiceException; 022import org.apache.archiva.security.common.ArchivaRoleConstants; 023import org.apache.archiva.web.model.FileMetadata; 024import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; 025import org.apache.archiva.redback.authorization.RedbackAuthorization; 026 027import javax.ws.rs.Consumes; 028import javax.ws.rs.DELETE; 029import javax.ws.rs.GET; 030import javax.ws.rs.POST; 031import javax.ws.rs.Path; 032import javax.ws.rs.PathParam; 033import javax.ws.rs.Produces; 034import javax.ws.rs.QueryParam; 035import javax.ws.rs.core.MediaType; 036import java.util.List; 037 038/** 039 * @author Olivier Lamy 040 * @since 1.4-M3 041 */ 042@Path( "/fileUploadService/" ) 043public interface FileUploadService 044{ 045 046 String FILES_SESSION_KEY = FileUploadService.class.getName() + "files_session_key"; 047 048 @POST 049 @Consumes( MediaType.MULTIPART_FORM_DATA ) 050 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 051 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) 052 FileMetadata post( MultipartBody multipartBody ) 053 throws ArchivaRestServiceException; 054 055 @Path( "{fileName}" ) 056 @DELETE 057 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 058 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) 059 Boolean deleteFile( @PathParam( "fileName" ) String fileName ) 060 throws ArchivaRestServiceException; 061 062 063 @Path( "sessionFileMetadatas" ) 064 @GET 065 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 066 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) 067 List<FileMetadata> getSessionFileMetadatas() 068 throws ArchivaRestServiceException; 069 070 @Path( "save/{repositoryId}/{groupId}/{artifactId}/{version}/{packaging}" ) 071 @GET 072 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 073 @RedbackAuthorization( resource = "{repositoryId}", permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) 074 Boolean save( @PathParam( "repositoryId" ) String repositoryId, @PathParam( "groupId" ) String groupId, 075 @PathParam( "artifactId" ) String artifactId, @PathParam( "version" ) String version, 076 @PathParam( "packaging" ) String packaging, @QueryParam( "generatePom" ) boolean generatePom ) 077 throws ArchivaRestServiceException; 078 079 080 @Path( "clearUploadedFiles" ) 081 @GET 082 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) 083 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) 084 Boolean clearUploadedFiles() 085 throws ArchivaRestServiceException; 086 087}