org.kuali.kfs.sys.batch.service.impl
Class BatchInputFileServiceImpl

java.lang.Object
  extended by org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl
All Implemented Interfaces:
BatchInputFileService

public class BatchInputFileServiceImpl
extends Object
implements BatchInputFileService

Provides batch input file management, including listing files, parsing, downloading, storing, and deleting.


Nested Class Summary
protected  class BatchInputFileServiceImpl.DoneFilenameFilter
          Retrieves files in a directory with the .done extension.
 
Constructor Summary
BatchInputFileServiceImpl()
           
 
Method Summary
protected  void createDoneFile(File batchFile)
          Creates a '.done' file with the name of the batch file.
protected  File generateDoneFileObject(File batchInputFile)
          This method is responsible for creating a File object that represents the done file.
 boolean isBatchInputTypeActive(BatchInputFileType batchInputFileType)
          Checks if the batch input type is active (can be used for upload).
 boolean isFileUserIdentifierProperlyFormatted(String fileUserIdentifier)
          For this implementation, a file user identifier must consist of letters and digits
 List<String> listBatchTypeFilesForUser(BatchInputFileType batchInputFileType, org.kuali.rice.kim.bo.Person user)
          Fetches workgroup for batch type from system parameter and verifies user is a member.
protected  List<File> listBatchTypeFilesForUserAsFiles(BatchInputFileType batchInputFileType, org.kuali.rice.kim.bo.Person user)
           
protected  File[] listFilesInBatchTypeDirectory(BatchInputFileType batchInputFileType)
          Returns List of filenames for existing files in the directory given by the batch input type.
 List<String> listInputFileNamesWithDoneFile(BatchInputFileType batchInputFileType)
          Returns a list of existing input files for the batch type that have an associated .done file
 Object parse(BatchInputFileType batchInputFileType, byte[] fileByteContent)
          Delegates to the batch input file type to parse the file.
 String save(org.kuali.rice.kim.bo.Person user, BatchInputFileType batchInputFileType, String fileUserIdentifier, InputStream fileContents, Object parsedObject)
          Stores the inputstream as a file on the server, identified by the given user file name.
 boolean validate(BatchInputFileType batchInputFileType, Object parsedObject)
          Defers to batch type to do any validation on the parsed contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchInputFileServiceImpl

public BatchInputFileServiceImpl()
Method Detail

parse

public Object parse(BatchInputFileType batchInputFileType,
                    byte[] fileByteContent)
Delegates to the batch input file type to parse the file.

Specified by:
parse in interface BatchInputFileService
Parameters:
batchInputFileType - - batch input file type for the file to parse
fileByteContent - - byte contents of file to parse
Returns:
- Object built from the file contents based on its xml unmarshalling rules
See Also:
BatchInputFileService.parse(org.kuali.kfs.sys.batch.BatchInputFileType, byte[])

validate

public boolean validate(BatchInputFileType batchInputFileType,
                        Object parsedObject)
Defers to batch type to do any validation on the parsed contents.

Specified by:
validate in interface BatchInputFileService
Parameters:
batchInputFileType - - instance of a BatchInputFileType
parsedObject - - the Object built from parsing xml contents
Returns:
boolean - true if validation was successful, false if there were errors
See Also:
BatchInputFileService.validate(org.kuali.kfs.sys.batch.BatchInputFileType, java.lang.Object)

save

public String save(org.kuali.rice.kim.bo.Person user,
                   BatchInputFileType batchInputFileType,
                   String fileUserIdentifier,
                   InputStream fileContents,
                   Object parsedObject)
            throws org.kuali.rice.kns.exception.AuthorizationException,
                   FileStorageException
Description copied from interface: BatchInputFileService
Stores the inputstream as a file on the server, identified by the given user file name.

Specified by:
save in interface BatchInputFileService
Parameters:
user - - user who is requesting the save
batchInputFileType - - instance of a BatchInputFileType
fileUserIdentifier - - file identifier specified by user
fileContents - - contents of the uploaded file
parsedObject - - object parsed from the input file
Returns:
String - name of file that was saved, or null if errors were enountered
Throws:
FileStorageException - - if errors were encountered while attempting to write the file
org.kuali.rice.kns.exception.AuthorizationException
See Also:
org.kuali.kfs.sys.batch.service.BatchInputFileService#save(org.kuali.rice.kim.bo.Person, org.kuali.kfs.sys.batch.BatchInputFileType, java.lang.String, java.io.InputStream)

createDoneFile

protected void createDoneFile(File batchFile)
Creates a '.done' file with the name of the batch file.


generateDoneFileObject

protected File generateDoneFileObject(File batchInputFile)
This method is responsible for creating a File object that represents the done file. The real file represented on disk may not exist

Parameters:
batchInputFile -
Returns:
a File object representing the done file. The real file may not exist on disk, but the return value can be used to create that file.

isBatchInputTypeActive

public boolean isBatchInputTypeActive(BatchInputFileType batchInputFileType)
Description copied from interface: BatchInputFileService
Checks if the batch input type is active (can be used for upload).

Specified by:
isBatchInputTypeActive in interface BatchInputFileService
Parameters:
batchInputFileType - - input type to check is active
Returns:
boolean - true if type is active, false if not active
See Also:
BatchInputFileService.isBatchInputTypeActive(org.kuali.kfs.sys.batch.BatchInputFileType)

listBatchTypeFilesForUser

public List<String> listBatchTypeFilesForUser(BatchInputFileType batchInputFileType,
                                              org.kuali.rice.kim.bo.Person user)
                                       throws org.kuali.rice.kns.exception.AuthorizationException
Fetches workgroup for batch type from system parameter and verifies user is a member. Then a list of all files for the batch type are retrieved. For each file, the file and user is sent through the checkAuthorization method of the batch input type implementation for finer grained security. If the method returns true, the filename is added to the user's list.

Specified by:
listBatchTypeFilesForUser in interface BatchInputFileService
user - - user for checking permissions
Returns:
List - List of filenames
Throws:
org.kuali.rice.kns.exception.AuthorizationException
See Also:
BatchInputFileService.listBatchTypeFilesForUser(org.kuali.kfs.sys.batch.BatchInputFileType, org.kuali.rice.kim.bo.Person)

listBatchTypeFilesForUserAsFiles

protected List<File> listBatchTypeFilesForUserAsFiles(BatchInputFileType batchInputFileType,
                                                      org.kuali.rice.kim.bo.Person user)
                                               throws org.kuali.rice.kns.exception.AuthorizationException
Throws:
org.kuali.rice.kns.exception.AuthorizationException

listFilesInBatchTypeDirectory

protected File[] listFilesInBatchTypeDirectory(BatchInputFileType batchInputFileType)
Returns List of filenames for existing files in the directory given by the batch input type.


listInputFileNamesWithDoneFile

public List<String> listInputFileNamesWithDoneFile(BatchInputFileType batchInputFileType)
Description copied from interface: BatchInputFileService
Returns a list of existing input files for the batch type that have an associated .done file

Specified by:
listInputFileNamesWithDoneFile in interface BatchInputFileService
Parameters:
batchInputFileType - - batch type to retieve files for
Returns:
List - List of filenames
See Also:
BatchInputFileService.listInputFileNamesWithDoneFile(org.kuali.kfs.sys.batch.BatchInputFileType)

isFileUserIdentifierProperlyFormatted

public boolean isFileUserIdentifierProperlyFormatted(String fileUserIdentifier)
For this implementation, a file user identifier must consist of letters and digits

Specified by:
isFileUserIdentifierProperlyFormatted in interface BatchInputFileService
Returns:
See Also:
BatchInputFileService.isFileUserIdentifierProperlyFormatted(java.lang.String)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.