use of org.syncany.plugins.transfer.StorageException in project syncany by syncany.
the class TransactionAwareFeatureTransferManager method retrieveRemoteTransactions.
private Map<TransactionTO, TransactionRemoteFile> retrieveRemoteTransactions() throws StorageException {
Map<String, TransactionRemoteFile> transactionFiles = list(TransactionRemoteFile.class);
Map<TransactionTO, TransactionRemoteFile> transactions = new HashMap<TransactionTO, TransactionRemoteFile>();
for (TransactionRemoteFile transaction : transactionFiles.values()) {
try {
File transactionFile = createTempFile("transaction");
try {
// Download transaction file
download(transaction, transactionFile);
} catch (StorageFileNotFoundException e) {
// This happens if the file is deleted between listing and downloading. It is now final, so we skip it.
logger.log(Level.INFO, "Could not find transaction file: " + transaction);
continue;
}
Transformer transformer = config == null ? null : config.getTransformer();
TransactionTO transactionTO = TransactionTO.load(transformer, transactionFile);
// Extract final locations
transactions.put(transactionTO, transaction);
transactionFile.delete();
} catch (Exception e) {
throw new StorageException("Failed to read transactionFile", e);
}
}
return transactions;
}
use of org.syncany.plugins.transfer.StorageException in project syncany by syncany.
the class ActionRemoteFile method validateName.
@Override
protected String validateName(String name) throws StorageException {
Matcher matcher = NAME_PATTERN.matcher(name);
if (!matcher.matches()) {
throw new StorageException(name + ": remote database filename pattern does not match: " + NAME_PATTERN.pattern() + " expected.");
}
operationName = matcher.group(1);
clientName = matcher.group(2);
timestamp = Long.parseLong(matcher.group(3));
return name;
}
use of org.syncany.plugins.transfer.StorageException in project syncany by syncany.
the class DatabaseRemoteFile method validateName.
@Override
protected String validateName(String name) throws StorageException {
Matcher matcher = NAME_PATTERN.matcher(name);
if (!matcher.matches()) {
throw new StorageException(name + ": remote database filename pattern does not match: " + NAME_PATTERN.pattern() + " expected.");
}
clientName = matcher.group(1);
clientVersion = Long.parseLong(matcher.group(2));
return name;
}
use of org.syncany.plugins.transfer.StorageException in project syncany by syncany.
the class ConnectOperation method downloadFile.
protected File downloadFile(TransferManager transferManager, RemoteFile remoteFile) throws StorageException {
try {
File tmpRepoFile = File.createTempFile("syncanyfile", "tmp");
transferManager.download(remoteFile, tmpRepoFile);
return tmpRepoFile;
} catch (Exception e) {
throw new StorageException("Unable to connect to repository.", e);
}
}
use of org.syncany.plugins.transfer.StorageException in project syncany by syncany.
the class ConnectOperation method verifyRepoFile.
private void verifyRepoFile(String repoFileStr) throws StorageException {
try {
Serializer serializer = new Persister();
serializer.read(RepoTO.class, repoFileStr);
} catch (Exception e) {
throw new StorageException("Repo file corrupt.", e);
}
}
Aggregations