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.ametys.core.user.UserIdentity;
023
024/**
025 * Manager for retrieving uploaded files.
026 */
027public interface UploadManager
028{
029    /** Avalon role. */
030    public static final String ROLE = UploadManager.class.getName();
031    
032    /**
033     * Stores a file uploaded by an user.
034     * @param user the user.
035     * @param filename the upload filename.
036     * @param is the upload data.
037     * @return the upload.
038     * @throws IOException if an error occurs.
039     */
040    Upload storeUpload(UserIdentity user, String filename, InputStream is) throws IOException;
041    
042    /**
043     * Retrieves a previous file uploaded by an user.
044     * @param user the user.
045     * @param id the upload id.
046     * @return the upload.
047     * @throws NoSuchElementException if there is no upload
048     *                                for this parameters.
049     */
050    Upload getUpload(UserIdentity user, String id) throws NoSuchElementException;
051}