@Override protected String validateName(String name) throws StorageException { if (!NAME_FORMAT.equals(name)) { throw new StorageException(name + ": remote filename pattern does not match: " + NAME_FORMAT + " expected."); } return name; } }
@Override protected String validateName(String name) throws StorageException { if (!NAME_FORMAT.equals(name)) { throw new StorageException(name + ": remote filename pattern does not match: " + NAME_FORMAT + " expected."); } return name; } }
@Override protected String validateName(String name) throws StorageException { Matcher matcher = NAME_PATTERN.matcher(name); if (!matcher.matches()) { throw new StorageException(name + ": remote filename pattern does not match: " + NAME_PATTERN.pattern() + " expected."); } return name; } }
@Override protected String validateName(String name) throws StorageException { Matcher matcher = NAME_PATTERN.matcher(name); if (!matcher.matches()) { throw new StorageException(name + ": remote filename pattern does not match: " + NAME_PATTERN.pattern() + " expected."); } cleanupNumber = Long.parseLong(matcher.group(1)); return name; }
@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; }
@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; } }
protected TransferSettings updateTransferSettings(TransferSettings transferSettings) throws StorageException { try { return askPluginSettings(transferSettings, new HashMap<String, String>()); } catch (Exception e) { logger.log(Level.SEVERE, "Unable to reload old plugin settings", e); throw new StorageException("Unable to reload old plugin settings: " + e.getMessage()); } }
private void cleanLocalRepository(Exception e) throws Exception { try { deleteAppDirs(options.getLocalDir()); } catch (Exception e1) { throw new StorageException("Couldn't upload to remote repo. Cleanup failed. There may be local directories left"); } throw new StorageException("Couldn't upload to remote repo. Cleaned local repository.", e); }
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); } }
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); } }
private MasterTO readMasterFile(File tmpMasterFile) throws StorageException { try { Serializer serializer = new Persister(); return serializer.read(MasterTO.class, tmpMasterFile); } catch (Exception e) { throw new StorageException("Master file corrupt.", e); } } }
@Validate public void validate() throws StorageException { if (baz != null && !baz.equalsIgnoreCase("baz")) { throw new StorageException("Only allowed value for baz field is 'baz'"); } } }
@Override public void upload(final File localFile, final RemoteFile remoteFile) throws StorageException { final RemoteFile pathAwareRemoteFile = createPathAwareRemoteFile(remoteFile); if (!createFolder(pathAwareRemoteFile)) { throw new StorageException("Unable to create path for " + pathAwareRemoteFile); } underlyingTransferManager.upload(localFile, pathAwareRemoteFile); }
@Override public <T extends RemoteFile> Map<String, T> list(Class<T> remoteFileClass) throws StorageException { String operationType = "list"; String operationDescription = "list(" + remoteFileClass.getSimpleName() + ")"; if (isNextOperationSuccessful(operationType, operationDescription)) { return super.list(remoteFileClass); } else { throw new StorageException("Operation failed: " + operationDescription); } } }
@Override public void connect() throws StorageException { String operationType = "connect"; String operationDescription = "connect"; if (isNextOperationSuccessful(operationType, operationDescription)) { super.connect(); } else { throw new StorageException("Operation failed: " + operationDescription); } }
@Override public void move(final RemoteFile sourceFile, final RemoteFile targetFile) throws StorageException { final RemoteFile pathAwareSourceFile = createPathAwareRemoteFile(sourceFile); final RemoteFile pathAwareTargetFile = createPathAwareRemoteFile(targetFile); if (!createFolder(pathAwareTargetFile)) { throw new StorageException("Unable to create path for " + pathAwareTargetFile); } underlyingTransferManager.move(pathAwareSourceFile, pathAwareTargetFile); removeFolder(pathAwareSourceFile); }
@Override public void init(boolean createIfRequired) throws StorageException { String operationType = "init"; String operationDescription = "init"; if (isNextOperationSuccessful(operationType, operationDescription)) { super.init(createIfRequired); } else { throw new StorageException("Operation failed: " + operationDescription); } }
@Override public void upload(File localFile, RemoteFile remoteFile) throws StorageException { String operationType = "upload"; String operationDescription = "upload(" + localFile.getAbsolutePath() + ", " + remoteFile.getName() + ")"; if (isNextOperationSuccessful(operationType, operationDescription)) { super.upload(localFile, remoteFile); } else { throw new StorageException("Operation failed: " + operationDescription); } }
@Override public boolean delete(RemoteFile remoteFile) throws StorageException { String operationType = "delete"; String operationDescription = "delete(" + remoteFile.getName() + ")"; if (isNextOperationSuccessful(operationType, operationDescription)) { return super.delete(remoteFile); } else { throw new StorageException("Operation failed: " + operationDescription); } }
@Override public void move(RemoteFile sourceFile, RemoteFile targetFile) throws StorageException { String operationType = "move"; String operationDescription = "move(" + sourceFile.getName() + "," + targetFile.getName() + ")"; if (isNextOperationSuccessful(operationType, operationDescription)) { super.move(sourceFile, targetFile); } else { throw new StorageException("Operation failed: " + operationDescription); } }