Skip to content

Commit

Permalink
Bug 501970 - Do not log/throw FileNotOnServerException but treat as
Browse files Browse the repository at this point in the history
cancelled

Change-Id: I7d2b5057d3dae43aa8b540f5e3cdcecb06894f06
Signed-off-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
  • Loading branch information
jfaltermeier committed Jan 26, 2017
1 parent 4fc2c3e commit 63293de
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ private boolean executeTransfer(IProgressMonitor monitor) throws RemoteException
// download file chunk to retrieve filesize (file chunk is discarded)
FileChunk fileChunk = null;
fileChunk = getConnectionManager().downloadFileChunk(getSessionId(), getProjectId(), getFileInformation());
if (fileChunk == null) {
status.transferCancelled();
return false;
}

getFileInformation().setFileSize(fileChunk.getFileSize());
initializeMonitor(monitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class FileDownloadStatus {
private final ProjectSpace transferringProjectSpace;
private final Observable finishedObservable = new Obs();
private final Observable failedObservable = new Obs();
private final Observable cancelledObservable = new Obs();

private final FileTransferStatistics statistics = new FileTransferStatistics(this);
private Status status;
Expand All @@ -55,7 +56,7 @@ private FileDownloadStatus(ProjectSpace transferringProjectSpace, FileIdentifier
*
* @author jfinis
*/
public static enum Status {
public enum Status {
/**
* The file transfer was not yet started.
*/
Expand Down Expand Up @@ -127,6 +128,16 @@ public void addTransferFinishedObserver(Observer o) {
}
}

private void addTransferCancelledObserver(Observer o) {
// Add
cancelledObservable.addObserver(o);

// Instantly notify if the transfer is already finished
if (status == Status.CANCELLED) {
o.update(cancelledObservable, this);
}
}

/**
* Adds an observer which is notified if the transfer fails due to an
* exception. The getException method can then be used to retrieve the
Expand Down Expand Up @@ -225,7 +236,6 @@ public File getTransferredFile() throws FileTransferException {
* in case of an error during transfer
*/
public File getTransferredFile(boolean block) throws FileTransferException {

if (!isTransferFinished() && block) {
/**
* TODO: Double-check this code
Expand All @@ -240,6 +250,7 @@ public void update(Observable arg0, Object arg1) {
};
addTransferFailedObserver(observer);
addTransferFinishedObserver(observer);
addTransferCancelledObserver(observer);
try {
synchronized (observer) {
observer.wait();
Expand Down Expand Up @@ -279,6 +290,7 @@ void transferCancelled() {
}
statistics.registerStop();
status = Status.CANCELLED;
cancelledObservable.notifyObservers(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.emf.emfstore.internal.server.accesscontrol.AccessControl;
import org.eclipse.emf.emfstore.internal.server.connection.xmlrpc.util.ShareProjectAdapter;
import org.eclipse.emf.emfstore.internal.server.exceptions.AccessControlException;
import org.eclipse.emf.emfstore.internal.server.exceptions.FileNotOnServerException;
import org.eclipse.emf.emfstore.internal.server.exceptions.InvalidVersionSpecException;
import org.eclipse.emf.emfstore.internal.server.filetransfer.FileChunk;
import org.eclipse.emf.emfstore.internal.server.filetransfer.FileTransferInformation;
Expand Down Expand Up @@ -152,8 +153,12 @@ public void deleteProject(SessionId sessionId, ProjectId projectId, boolean dele
*/
public FileChunk downloadFileChunk(SessionId sessionId, ProjectId projectId,
FileTransferInformation fileInformation)
throws ESException {
return getEmfStore().downloadFileChunk(sessionId, projectId, fileInformation);
throws ESException {
try {
return getEmfStore().downloadFileChunk(sessionId, projectId, fileInformation);
} catch (final FileNotOnServerException ex) {
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.emf.emfstore.internal.server.core.AbstractSubEmfstoreInterface;
import org.eclipse.emf.emfstore.internal.server.core.MonitorProvider;
import org.eclipse.emf.emfstore.internal.server.exceptions.FatalESException;
import org.eclipse.emf.emfstore.internal.server.exceptions.FileNotOnServerException;
import org.eclipse.emf.emfstore.internal.server.exceptions.FileTransferException;
import org.eclipse.emf.emfstore.internal.server.exceptions.InvalidInputException;
import org.eclipse.emf.emfstore.internal.server.filetransfer.FileChunk;
Expand Down Expand Up @@ -86,7 +85,8 @@ public FileChunk downloadFileChunk(ProjectId projectId, FileTransferInformation
try {
file = findFile(fileInformation, projectId);
} catch (final FileNotFoundException e) {
throw new FileNotOnServerException(projectId, fileInformation.getFileIdentifier());
// throw new FileNotOnServerException(projectId, fileInformation.getFileIdentifier());
return null;
}

return FilePartitionerUtil.readChunk(file, fileInformation);
Expand Down

0 comments on commit 63293de

Please sign in to comment.