Class MCRUploadHandlerIFS

All Implemented Interfaces:
MCRListenableProgressable, MCRProcessable, MCRProgressable

public class MCRUploadHandlerIFS extends MCRUploadHandler
handles uploads and store files directly into the IFS.
Version:
$Revision$ $Date$
Author:
Thomas Scheffler (yagee), Frank Lützenkirchen
See Also:
  • Field Details

    • documentID

      protected String documentID
    • derivateID

      protected String derivateID
    • derivate

      protected MCRDerivate derivate
    • rootDir

      protected MCRPath rootDir
  • Constructor Details

    • MCRUploadHandlerIFS

      public MCRUploadHandlerIFS(String documentID, String derivateID)
    • MCRUploadHandlerIFS

      public MCRUploadHandlerIFS(String documentID, String derivateID, String returnURL)
  • Method Details

    • startUpload

      public void startUpload(int numFiles)
      Description copied from class: MCRUploadHandler
      Starts the upload session.
      Overrides:
      startUpload in class MCRUploadHandler
      Parameters:
      numFiles - the number of files that will be uploaded
    • setDefaultPermissions

      protected void setDefaultPermissions(MCRObjectID derivateID)
    • acceptFile

      public boolean acceptFile(String path, String checksum, long length) throws Exception
      Description copied from class: MCRUploadHandler
      This method is called to ask if this file should be uploaded and will be accepted by the server. The default implementation always returns true (always upload file), but subclasses should overwrite this method to decide whether the file's content must be uploaded. Decision can be based on the MD5 checksum, so unchanged files do not have to be uploaded again.
      Overrides:
      acceptFile in class MCRUploadHandler
      Parameters:
      path - the path and filename of the file
      checksum - the MD5 checksum computed at the client side
      length - the length of the file in bytes (file size)
      Returns:
      true, if the file should be uploaded, false if the file should be skipped
      Throws:
      Exception
    • receiveFile

      public long receiveFile(String path, InputStream in, long length, String checksum) throws IOException, MCRPersistenceException, MCRAccessException
      Description copied from class: MCRUploadHandler
      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 requires a database transaction.
      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.
      checksum - the md5 checksum calculated at the client side. This may be null, meaning that the md5 checksum is not known.
      Returns:
      the number of bytes that have been stored.
      Throws:
      IOException
      MCRPersistenceException
      MCRAccessException
    • finishUpload

      public void finishUpload() throws IOException, MCRAccessException
      Description copied from class: MCRUploadHandler
      After finishing uploading all files, this method is called so that the UploadHandler subclass can finish work and commit all saved files.
      Specified by:
      finishUpload in class MCRUploadHandler
      Throws:
      IOException
      MCRAccessException
    • getPathOfMainFile

      protected String getPathOfMainFile() throws IOException
      Throws:
      IOException
    • getDerivateID

      public String getDerivateID()
    • getDocumentID

      public String getDocumentID()