Java Examples for org.syncany.plugins.transfer.StorageFileNotFoundException

The following java examples will help you to understand the usage of org.syncany.plugins.transfer.StorageFileNotFoundException. These source code samples are taken from different open source projects.

Example 1
Project: syncany-plugin-gui-master  File: TransactionAwareFeatureTransferManager.java View source code
/**
	 * Downloads all transaction files and looks for the corresponding temporary file
	 * for the given remote file. If there is a temporary file, the file is downloaded
	 * instead of the original file.
	 *
	 * <p>This method is <b>expensive</b>, but it is only called by {@link #download(RemoteFile, File) download()}
	 * if a file does not exist.
	 */
private void downloadDeletedTempFileInTransaction(RemoteFile remoteFile, File localFile) throws StorageException {
    logger.log(Level.INFO, "File {0} not found, checking if it is being deleted ...", remoteFile.getName());
    Set<TransactionTO> transactions = retrieveRemoteTransactions().keySet();
    TempRemoteFile tempRemoteFile = null;
    // Find file: If the file is being deleted and the name matches, download temporary file instead.
    for (TransactionTO transaction : transactions) {
        for (ActionTO action : transaction.getActions()) {
            if (action.getType().equals(ActionType.DELETE) && action.getRemoteFile().equals(remoteFile)) {
                tempRemoteFile = action.getTempRemoteFile();
                break;
            }
        }
    }
    // Download file, or throw exception
    if (tempRemoteFile != null) {
        logger.log(Level.INFO, "-> File {0} in process of being deleted; downloading corresponding temp. file {1} ...", new Object[] { remoteFile.getName(), tempRemoteFile.getName() });
        underlyingTransferManager.download(tempRemoteFile, localFile);
    } else {
        logger.log(Level.WARNING, "-> File {0} does not exist and is not in any transaction. Throwing exception.", remoteFile.getName());
        throw new StorageFileNotFoundException("File " + remoteFile.getName() + " does not exist and is not in any transaction");
    }
}
Example 2
Project: syncany-plugin-dropbox-master  File: TransactionAwareFeatureTransferManager.java View source code
/**
	 * Downloads all transaction files and looks for the corresponding temporary file
	 * for the given remote file. If there is a temporary file, the file is downloaded
	 * instead of the original file.
	 *
	 * <p>This method is <b>expensive</b>, but it is only called by {@link #download(RemoteFile, File) download()}
	 * if a file does not exist.
	 */
private void downloadDeletedTempFileInTransaction(RemoteFile remoteFile, File localFile) throws StorageException {
    logger.log(Level.INFO, "File {0} not found, checking if it is being deleted ...", remoteFile.getName());
    Set<TransactionTO> transactions = retrieveRemoteTransactions().keySet();
    TempRemoteFile tempRemoteFile = null;
    // Find file: If the file is being deleted and the name matches, download temporary file instead.
    for (TransactionTO transaction : transactions) {
        for (ActionTO action : transaction.getActions()) {
            if (action.getType().equals(ActionType.DELETE) && action.getRemoteFile().equals(remoteFile)) {
                tempRemoteFile = action.getTempRemoteFile();
                break;
            }
        }
    }
    // Download file, or throw exception
    if (tempRemoteFile != null) {
        logger.log(Level.INFO, "-> File {0} in process of being deleted; downloading corresponding temp. file {1} ...", new Object[] { remoteFile.getName(), tempRemoteFile.getName() });
        underlyingTransferManager.download(tempRemoteFile, localFile);
    } else {
        logger.log(Level.WARNING, "-> File {0} does not exist and is not in any transaction. Throwing exception.", remoteFile.getName());
        throw new StorageFileNotFoundException("File " + remoteFile.getName() + " does not exist and is not in any transaction");
    }
}
Example 3
Project: syncany-plugin-s3-master  File: TransactionAwareFeatureTransferManager.java View source code
/**
	 * Downloads all transaction files and looks for the corresponding temporary file
	 * for the given remote file. If there is a temporary file, the file is downloaded
	 * instead of the original file.
	 *
	 * <p>This method is <b>expensive</b>, but it is only called by {@link #download(RemoteFile, File) download()}
	 * if a file does not exist.
	 */
private void downloadDeletedTempFileInTransaction(RemoteFile remoteFile, File localFile) throws StorageException {
    logger.log(Level.INFO, "File {0} not found, checking if it is being deleted ...", remoteFile.getName());
    Set<TransactionTO> transactions = retrieveRemoteTransactions().keySet();
    TempRemoteFile tempRemoteFile = null;
    // Find file: If the file is being deleted and the name matches, download temporary file instead.
    for (TransactionTO transaction : transactions) {
        for (ActionTO action : transaction.getActions()) {
            if (action.getType().equals(ActionType.DELETE) && action.getRemoteFile().equals(remoteFile)) {
                tempRemoteFile = action.getTempRemoteFile();
                break;
            }
        }
    }
    // Download file, or throw exception
    if (tempRemoteFile != null) {
        logger.log(Level.INFO, "-> File {0} in process of being deleted; downloading corresponding temp. file {1} ...", new Object[] { remoteFile.getName(), tempRemoteFile.getName() });
        underlyingTransferManager.download(tempRemoteFile, localFile);
    } else {
        logger.log(Level.WARNING, "-> File {0} does not exist and is not in any transaction. Throwing exception.", remoteFile.getName());
        throw new StorageFileNotFoundException("File " + remoteFile.getName() + " does not exist and is not in any transaction");
    }
}
Example 4
Project: syncany-master  File: TransactionAwareFeatureTransferManager.java View source code
/**
	 * Downloads all transaction files and looks for the corresponding temporary file
	 * for the given remote file. If there is a temporary file, the file is downloaded
	 * instead of the original file.
	 *
	 * <p>This method is <b>expensive</b>, but it is only called by {@link #download(RemoteFile, File) download()}
	 * if a file does not exist.
	 */
private void downloadDeletedTempFileInTransaction(RemoteFile remoteFile, File localFile) throws StorageException {
    logger.log(Level.INFO, "File {0} not found, checking if it is being deleted ...", remoteFile.getName());
    Set<TransactionTO> transactions = retrieveRemoteTransactions().keySet();
    TempRemoteFile tempRemoteFile = null;
    // Find file: If the file is being deleted and the name matches, download temporary file instead.
    for (TransactionTO transaction : transactions) {
        for (ActionTO action : transaction.getActions()) {
            if (action.getType().equals(ActionType.DELETE) && action.getRemoteFile().equals(remoteFile)) {
                tempRemoteFile = action.getTempRemoteFile();
                break;
            }
        }
    }
    // Download file, or throw exception
    if (tempRemoteFile != null) {
        logger.log(Level.INFO, "-> File {0} in process of being deleted; downloading corresponding temp. file {1} ...", new Object[] { remoteFile.getName(), tempRemoteFile.getName() });
        underlyingTransferManager.download(tempRemoteFile, localFile);
    } else {
        logger.log(Level.WARNING, "-> File {0} does not exist and is not in any transaction. Throwing exception.", remoteFile.getName());
        throw new StorageFileNotFoundException("File " + remoteFile.getName() + " does not exist and is not in any transaction");
    }
}
Example 5
Project: syncany-plugin-flickr-master  File: LocalTransferManager.java View source code
@Override
public void download(RemoteFile remoteFile, File localFile) throws StorageException {
    connect();
    File repoFile = getRemoteFile(remoteFile);
    if (!repoFile.exists()) {
        throw new StorageFileNotFoundException("No such file in local repository: " + repoFile);
    }
    try {
        File tempLocalFile = createTempFile("local-tm-download");
        tempLocalFile.deleteOnExit();
        FileUtils.copyFile(repoFile, tempLocalFile);
        localFile.delete();
        FileUtils.moveFile(tempLocalFile, localFile);
        tempLocalFile.delete();
    } catch (IOException ex) {
        throw new StorageException("Unable to copy file " + repoFile + " from local repository to " + localFile, ex);
    }
}
Example 6
Project: syncany-plugin-sftp-master  File: LocalTransferManager.java View source code
@Override
public void download(RemoteFile remoteFile, File localFile) throws StorageException {
    connect();
    File repoFile = getRemoteFile(remoteFile);
    if (!repoFile.exists()) {
        throw new StorageFileNotFoundException("No such file in local repository: " + repoFile);
    }
    try {
        File tempLocalFile = createTempFile("local-tm-download");
        tempLocalFile.deleteOnExit();
        FileUtils.copyFile(repoFile, tempLocalFile);
        localFile.delete();
        FileUtils.moveFile(tempLocalFile, localFile);
        tempLocalFile.delete();
    } catch (IOException ex) {
        throw new StorageException("Unable to copy file " + repoFile + " from local repository to " + localFile, ex);
    }
}