001/*
002 *  Copyright 2012 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.core.upload;
017
018import java.io.IOException;
019import java.io.InputStream;
020import java.util.NoSuchElementException;
021
022import org.apache.avalon.framework.component.Component;
023
024import org.ametys.core.user.UserIdentity;
025
026/**
027 * Manager for retrieving uploaded files.
028 */
029public interface UploadManager extends Component
030{
031    /** Avalon role. */
032    public static final String ROLE = UploadManager.class.getName();
033    
034    /**
035     * Stores a file uploaded by an user.
036     * @param user the user.
037     * @param filename the upload filename.
038     * @param is the upload data.
039     * @return the upload.
040     * @throws IOException if an error occurs.
041     */
042    Upload storeUpload(UserIdentity user, String filename, InputStream is) throws IOException;
043    
044    /**
045     * Retrieves a previous file uploaded by an user.
046     * @param user the user.
047     * @param id the upload id.
048     * @return the upload.
049     * @throws NoSuchElementException if there is no upload
050     *                                for this parameters.
051     */
052    Upload getUpload(UserIdentity user, String id) throws NoSuchElementException;
053}