org.eclipse.emf.emfstore.internal.client.model.filetransfer
Class FileTransferManager

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.filetransfer.FileTransferManager

public class FileTransferManager
extends Object

The main managing class on the client side for file transfers. Each project space has an associated FileTransferManager. All file-related request from the project space are delegated to that manager. The manager provides methods to add files, get files and retrieve additional information about files.

Author:
jfinis

Constructor Summary
FileTransferManager(ProjectSpaceBase projectSpaceImpl)
          Constructor that creates a file transfer manager for a specific project space.
 
Method Summary
 FileIdentifier addFile(File file)
          Adds a file to be transferred (uploaded).
 FileIdentifier addFile(File file, String id)
          Adds a file to be transferred (uploaded).
 void cancelPendingUpload(FileIdentifier fileIdentifier)
          Cancels a pending upload.
 FileDownloadStatus getFile(FileIdentifier fileIdentifier, boolean isTriggeredByUI)
          Returns the download status of the file that is associated with the given FileIdentifier.
 FileDownloadStatus getFile(FileIdentifier fileIdentifier, boolean isTriggeredByUI, boolean forceDownload)
          Returns the download status of the file that is associated with the given FileIdentifier.
 FileInformation getFileInfo(FileIdentifier fileIdentifier)
          returns a file information object for a specific file identifier.
 boolean hasWaitingUpload(FileIdentifier fileIdentifier)
          Return if a specific file is in the pending upload queue.
 void uploadQueuedFiles(org.eclipse.core.runtime.IProgressMonitor progress)
          Uploads all files in the commit queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransferManager

public FileTransferManager(ProjectSpaceBase projectSpaceImpl)
Constructor that creates a file transfer manager for a specific project space. Only to be called in the init of a project space!

Parameters:
projectSpaceImpl - the project space to which this transfer manager belongs
Method Detail

addFile

public FileIdentifier addFile(File file)
                       throws FileTransferException
Adds a file to be transferred (uploaded).

Parameters:
file - the file to be transferred
Returns:
the FileIdentifier that associates the file with its ID
Throws:
FileTransferException - in case the file is either null, a directory or does not exist

addFile

public FileIdentifier addFile(File file,
                              String id)
                       throws FileTransferException
Adds a file to be transferred (uploaded).

Parameters:
file - the file to be transferred
id - the ID that will be associated with the file being uploaded
Returns:
the FileIdentifier that associates the file with its ID
Throws:
FileTransferException - in case the file is either null, a directory or does not exist

uploadQueuedFiles

public void uploadQueuedFiles(org.eclipse.core.runtime.IProgressMonitor progress)
Uploads all files in the commit queue. Is called upon committing the project space.

Parameters:
progress - progress monitor

getFile

public FileDownloadStatus getFile(FileIdentifier fileIdentifier,
                                  boolean isTriggeredByUI,
                                  boolean forceDownload)
                           throws FileTransferException
Returns the download status of the file that is associated with the given FileIdentifier.

Parameters:
fileIdentifier - the file identifier whose download status should be retrieved
isTriggeredByUI - whether the download of the file has been triggered by the UI
forceDownload - whether to re-fetch the file even, if a file with the same identifier is already present; set this to true in case you have files, which will be updated but keep the same identifier
Returns:
the download status of the file
Throws:
FileTransferException - in case the given file identifier is null

getFile

public FileDownloadStatus getFile(FileIdentifier fileIdentifier,
                                  boolean isTriggeredByUI)
                           throws FileTransferException
Returns the download status of the file that is associated with the given FileIdentifier.

Parameters:
fileIdentifier - the file identifier whose download status should be retrieved
isTriggeredByUI - whether the download of the file has been triggered by the UI
Returns:
the download status of the file
Throws:
FileTransferException - in case the given file identifier is null

hasWaitingUpload

public boolean hasWaitingUpload(FileIdentifier fileIdentifier)
Return if a specific file is in the pending upload queue.

Parameters:
fileIdentifier - the file to be looked up
Returns:
true, if the file is in the queue

cancelPendingUpload

public void cancelPendingUpload(FileIdentifier fileIdentifier)
Cancels a pending upload. That means that the upload is removed from the queue and deleted from cache. If the file is not in the queue, nothing is done. If it is in the queue but not in the cache, then it is only removed from the queue.

Parameters:
fileIdentifier - the file to be canceled

getFileInfo

public FileInformation getFileInfo(FileIdentifier fileIdentifier)
returns a file information object for a specific file identifier.

Parameters:
fileIdentifier - the identifier
Returns:
the file information for that identifier


Copyright © 2015. All Rights Reserved.