Class FileImporter

  • Direct Known Subclasses:
    AesFileImporter

    public abstract class FileImporter
    extends java.lang.Object
    Import IFile(s) into a VirtualDrive.
    • Constructor Detail

      • FileImporter

        public FileImporter()
    • Method Detail

      • onPrepare

        protected abstract void onPrepare​(IVirtualFile targetFile,
                                          boolean integrity)
                                   throws java.io.IOException
        Runs before import
        Parameters:
        targetFile - The target file imported
        integrity - If integrity verification is enabled
        Throws:
        java.io.IOException - If there is a problem with the file preparation.
      • getMinimumPartSize

        protected abstract long getMinimumPartSize​(IVirtualFile file)
                                            throws java.io.IOException
        Get the minimum part of file that can be imported in parallel.
        Parameters:
        file - The file
        Returns:
        The number of bytes
        Throws:
        java.io.IOException - If there was a problem calculating the size.
      • initialize

        public void initialize​(int bufferSize,
                               int threads)
        Constructs a file importer that can be used to import files into the drive
        Parameters:
        bufferSize - Buffer size to be used when encrypting files. If using integrity this value has to be a multiple of the Chunk size. If not using integrity it should be a multiple of the AES block size for better performance
        threads - The threads to use for import
      • stop

        public void stop()
        Stops all current importing tasks
      • isRunning

        public boolean isRunning()
        Check if importer is currently running a job.
        Returns:
        True if running
      • importFile

        public IVirtualFile importFile​(IFile fileToImport,
                                       IVirtualFile dir)
                                throws java.lang.Exception
        Imports a real file into the drive.
        Parameters:
        fileToImport - The source file that will be imported in into the drive.
        dir - The target directory in the drive that the file will be imported
        Returns:
        The imported file
        Throws:
        java.lang.Exception - Thrown if error occurs during import
      • importFile

        public IVirtualFile importFile​(IFile fileToImport,
                                       IVirtualFile dir,
                                       FileImporter.FileImportOptions options)
                                throws java.lang.Exception
        Imports a real file into the drive.
        Parameters:
        fileToImport - The source file that will be imported in into the drive.
        dir - The target directory in the drive that the file will be imported
        options - The options
        Returns:
        The imported file
        Throws:
        java.lang.Exception - Thrown if error occurs during import
      • close

        public void close()
        Stops the current import