001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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     */
016    package org.kuali.kfs.sys.batch.service;
017    
018    import java.io.File;
019    import java.io.FileNotFoundException;
020    import java.io.InputStream;
021    import java.util.Map;
022    import java.util.Set;
023    
024    import org.kuali.kfs.sys.batch.BatchInputFileSetType;
025    import org.kuali.kfs.sys.exception.FileStorageException;
026    import org.kuali.rice.kim.bo.Person;
027    import org.kuali.rice.kns.exception.AuthorizationException;
028    
029    /**
030     * This interface defines the methods needed to save/download/delete file sets in the batch upload system
031     */
032    public interface BatchInputFileSetService {
033    
034        /**
035         * Stores the input streams (the values in the Map parameter) as files on the server, identified by the given user file name and
036         * file user identifier
037         * 
038         * @param user - user who is requesting the save
039         * @param inputType - instance of a BatchInputFileSetType
040         * @param fileUserIdentifer - file identifier specified by user
041         * @param typeToStreamMap - contents of the uploaded files, keyed by the input file type
042         * @return a Map of type to file name mappings of the saved files
043         * @throws FileStorageException - if errors were encountered while attempting to write the file
044         */
045        public Map<String, String> save(Person user, BatchInputFileSetType inputType, String fileUserIdentifer, Map<String, InputStream> typeToStreamMap) throws AuthorizationException, FileStorageException;
046    
047        /**
048         * Checks if the batch input type is active (can be used for upload).
049         * 
050         * @param BatchInputFileSetType - input type to check is active
051         * @return boolean - true if type is active, false if not active
052         */
053        public boolean isBatchInputTypeActive(BatchInputFileSetType batchInputFileSetType);
054    
055        /**
056         * Returns whether a file set identifier is properly formatted.
057         * 
058         * @param fileUserIdentifier
059         * @return
060         */
061        public boolean isFileUserIdentifierProperlyFormatted(String fileUserIdentifier);
062    }
063