001    package 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    
021    import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
022    import org.apache.archiva.security.common.ArchivaRoleConstants;
023    import org.apache.archiva.web.model.FileMetadata;
024    import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
025    import org.apache.archiva.redback.authorization.RedbackAuthorization;
026    
027    import javax.ws.rs.Consumes;
028    import javax.ws.rs.DELETE;
029    import javax.ws.rs.GET;
030    import javax.ws.rs.POST;
031    import javax.ws.rs.Path;
032    import javax.ws.rs.PathParam;
033    import javax.ws.rs.Produces;
034    import javax.ws.rs.QueryParam;
035    import javax.ws.rs.core.MediaType;
036    import java.util.List;
037    
038    /**
039     * @author Olivier Lamy
040     * @since 1.4-M3
041     */
042    @Path( "/fileUploadService/" )
043    public 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( 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    }