View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.batch.service;
17  
18  import java.io.InputStream;
19  import java.util.List;
20  
21  import org.kuali.ole.sys.batch.BatchInputFileType;
22  import org.kuali.ole.sys.exception.FileStorageException;
23  import org.kuali.rice.kim.api.identity.Person;
24  import org.kuali.rice.krad.exception.AuthorizationException;
25  
26  /**
27   * Interface defining methods to manage batch input files.
28   */
29  public interface BatchInputFileService {
30      /**
31       * Unmarshalls the file contents to an Object using the digestor and digestor rules file specified in the batch input type.
32       * 
33       * @param batchInputFileType - batch input file type for the file to parse
34       * @param fileByteContent - byte contents of file to parse
35       * @return - Object built from the file contents based on its xml unmarshalling rules
36       */
37      public Object parse(BatchInputFileType batchInputFileType, byte[] fileByteContent);
38  
39      /**
40       * Using the input type object parses and validates the file contents by calling validate on the batch input type. If there were
41       * validation errors, GlobalVariables.errorMap will contain the error messages.
42       * 
43       * @param inputType - instance of a BatchInputFileType
44       * @param parsedObject - the Object built from parsing xml contents
45       * @return boolean - true if validation was successful, false if there were errors
46       */
47      public boolean validate(BatchInputFileType inputType, Object parsedObject);
48      /**
49       * Stores the inputstream as a file on the server, identified by the given user file name.
50       * 
51       * @param user - user who is requesting the save
52       * @param inputType - instance of a BatchInputFileType
53       * @param fileUserIdentifier - file identifier specified by user
54       * @param fileContents - contents of the uploaded file
55       * @param parsedObject - object parsed from the input file
56       * @return String - name of file that was saved, or null if errors were enountered
57       * @throws FileStorageException - if errors were encountered while attempting to write the file
58       */
59      public String save(Person user, BatchInputFileType inputType, String fileUserIdentifier, InputStream fileContents, Object parsedObject) throws AuthorizationException, FileStorageException;
60      
61      /**
62       * Stores the inputstream as a file on the server, identified by the given user file name.
63       * 
64       * @param user - user who is requesting the save
65       * @param inputType - instance of a BatchInputFileType
66       * @param fileUserIdentifier - file identifier specified by user
67       * @param fileContents - contents of the uploaded file
68       * @param parsedObject - object parsed from the input file
69       * @param destinationFilePath - destination path selected by user for storing the ole format xml.
70       * @param extension - extension of the file selected through marc file upload screen 
71       * @return String - name of file that was saved, or null if errors were enountered
72       * @throws FileStorageException - if errors were encountered while attempting to write the file
73       */
74      public String save(Person user, BatchInputFileType inputType, String fileUserIdentifier, InputStream fileContents, Object parsedObject,String destinationFilePath,String extension) throws AuthorizationException, FileStorageException;
75  
76      /**
77       * Checks if the batch input type is active (can be used for upload).
78       * 
79       * @param batchInputFileType - input type to check is active
80       * @return boolean - true if type is active, false if not active
81       */
82      public boolean isBatchInputTypeActive(BatchInputFileType batchInputFileType);
83  
84      /**
85       * Returns a list of batch type file names (without path) that the given user has permissions to manage. Path is intentionally
86       * excluded to prevent security problems arising from giving users access to the full path.
87       * 
88       * @param user - user for checking permissions
89       * @return List<String> - List of filenames
90       */
91      public List<String> listBatchTypeFilesForUser(BatchInputFileType batchInputFileType, Person user) throws AuthorizationException;
92  
93      /**
94       * Returns a list of existing input files for the batch type that have an associated .done file
95       * 
96       * @param batchInputFileType - batch type to retieve files for
97       * @return List<String> - List of filenames
98       */
99      public List<String> listInputFileNamesWithDoneFile(BatchInputFileType batchInputFileType);
100 
101     /**
102      * Returns whether a file user identifier is properly formatted.
103      * 
104      * @param fileUserIdentifier
105      * @return
106      */
107     public boolean isFileUserIdentifierProperlyFormatted(String fileUserIdentifier);
108    
109 }
110