org.mycore.frontend.fileupload
Class MCRUploadHandlerIFS

java.lang.Object
  extended by org.mycore.frontend.fileupload.MCRUploadHandler
      extended by org.mycore.frontend.fileupload.MCRUploadHandlerIFS
Direct Known Subclasses:
MCRSWFUploadHandlerIFS

public class MCRUploadHandlerIFS
extends MCRUploadHandler

handles uploads via the UploadApplet and store files directly into the IFS.

Version:
$Revision: 14986 $ $Date: 2009-03-20 21:41:45 +0100 (Fri, 20 Mar 2009) $
Author:
Thomas Scheffler (yagee)
See Also:
MCRUploadHandler

Field Summary
protected  MCRDerivate derivate
           
protected  boolean newDerivate
           
protected  MCRDirectory rootDir
           
 
Fields inherited from class org.mycore.frontend.fileupload.MCRUploadHandler
logger, uploadID, url
 
Constructor Summary
MCRUploadHandlerIFS(String docId, String derId, String url)
           
 
Method Summary
 boolean acceptFile(String path, String checksum, long length)
          Message from UploadApplet If you want all files transfered omit this method
protected  void commitTransaction()
           
protected  void createNewDerivate(String docId, MCRObjectID newDerID)
           
 void finishUpload()
          Finish upload, store derivate
protected static String getMainFilePath(MCRDirectory root)
           
protected  void init(String docId, String derId)
           
 long receiveFile(String path, InputStream in, long length, String md5)
          When the applet uploads a file, this method is called so that the UploadHandler subclass can store the file on the server side.
protected  void rollbackTransaction()
           
protected static void setDefaultPermissions(MCRObjectID derID)
           
protected  void startTransaction()
           
 void startUpload(int numFiles)
          Start Upload for MyCoRe
 
Methods inherited from class org.mycore.frontend.fileupload.MCRUploadHandler
cancelUpload, getID, getRedirectURL, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

derivate

protected MCRDerivate derivate

rootDir

protected MCRDirectory rootDir

newDerivate

protected boolean newDerivate
Constructor Detail

MCRUploadHandlerIFS

public MCRUploadHandlerIFS(String docId,
                           String derId,
                           String url)
Method Detail

init

protected void init(String docId,
                    String derId)

startUpload

public void startUpload(int numFiles)
                 throws Exception
Start Upload for MyCoRe

Specified by:
startUpload in class MCRUploadHandler
Parameters:
numFiles - the number of files that the applet will upload
Throws:
Exception

acceptFile

public boolean acceptFile(String path,
                          String checksum,
                          long length)
                   throws Exception
Message from UploadApplet If you want all files transfered omit this method

Overrides:
acceptFile in class MCRUploadHandler
Parameters:
path - file name
checksum - md5 checksum of of file
length - the length of the file in bytes (file size)
Returns:
true transfer file false don't send file
Throws:
Exception

receiveFile

public long receiveFile(String path,
                        InputStream in,
                        long length,
                        String md5)
                 throws Exception
Description copied from class: MCRUploadHandler
When the applet uploads a file, this method is called so that the UploadHandler subclass can store the file on the server side. When the UploadHandler could read less than length bytes from the InputStream at the time the InputStream has no data any more, the user at the remote side canceled upload during file transfer. The UploadHandler then can decide to delete the file, but must return the number of bytes stored. The UploadHandler can also compare the MD5 checksum calculated at the client side with its own checksum, to detect magical transfer errors. This method is not covered by a database transaction. The implementation has to handle transactions by itself.

Specified by:
receiveFile in class MCRUploadHandler
Parameters:
path - the path and filename of the file
in - the inputstream to read the content of the file from
length - the total file size as number of bytes. This may be 0, meaning that the file is empty or the file size is not known.
md5 - the md5 checksum calculated at the client applet side. This may be null, meaning that the md5 checksum is not known.
Returns:
the number of bytes that have been stored.
Throws:
Exception

finishUpload

public void finishUpload()
                  throws Exception
Finish upload, store derivate

Specified by:
finishUpload in class MCRUploadHandler
Throws:
Exception

createNewDerivate

protected void createNewDerivate(String docId,
                                 MCRObjectID newDerID)

getMainFilePath

protected static String getMainFilePath(MCRDirectory root)

setDefaultPermissions

protected static void setDefaultPermissions(MCRObjectID derID)

startTransaction

protected void startTransaction()

commitTransaction

protected void commitTransaction()

rollbackTransaction

protected void rollbackTransaction()