Package org.syncany.plugins.transfer

Examples of org.syncany.plugins.transfer.StorageException


      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);
    }
  }
View Full Code Here


    try {
      FileUtils.moveFile(sourceRemoteFile, targetRemoteFile);
    }
    catch (IOException ex) {
      throw new StorageException("Unable to move file " + sourceRemoteFile + " to destination " + targetRemoteFile, ex);
    }
  }
View Full Code Here

      return;
    }

    // No such local file
    if (!localFile.exists()) {
      throw new StorageException("No such file on local disk: " + localFile);
    }

    try {
      FileUtils.copyFile(localFile, tempRepoFile);
      FileUtils.moveFile(tempRepoFile, repoFile);
    }
    catch (IOException ex) {
      throw new StorageException("Unable to copy file " + localFile + " to local repository " + repoFile, ex);
    }
  }
View Full Code Here

    File remoteFilePath = getRemoteFilePath(remoteFileClass);
    File[] files = remoteFilePath.listFiles();

    if (files == null) {
      logger.log(Level.FINE, remoteFilePath.getAbsolutePath());
      throw new StorageException("Unable to read local respository " + repoPath);
    }

    // Create RemoteFile objects
    Map<String, T> remoteFiles = new HashMap<String, T>();
View Full Code Here

  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);
  }
View Full Code Here

      maxRounds--;
      clientFileClock++;
    }
   
    if (!isLoadableDatabaseFile) {
      throw new StorageException("Cannot find suitable database remote file to load range.");
    }
   
    return databaseFileForRange;
  }
View Full Code Here

    return String.format(LINK_SHORT_API_URL_GET_FORMAT, shortLinkId);
  }

  private String resolveLink(String httpApplicationLink, int redirectCount) throws StorageException {
    if (redirectCount >= LINK_HTTP_MAX_REDIRECT_COUNT) {
      throw new StorageException("Max. redirect count of " + LINK_HTTP_MAX_REDIRECT_COUNT + " for URL reached. Canot find syncany:// link.");
    }

    try {
      logger.log(Level.INFO, "- Retrieving HTTP HEAD for " + httpApplicationLink + " ...");

      HttpHead headMethod = new HttpHead(httpApplicationLink);
      HttpResponse httpResponse = createHttpClient().execute(headMethod);

      // Find syncany:// link
      Header locationHeader = httpResponse.getLastHeader("Location");

      if (locationHeader == null) {
        throw new Exception("Link does not redirect to a syncany:// link.");
      }

      String locationHeaderUrl = locationHeader.getValue();
      Matcher locationHeaderMatcher = LINK_PATTERN.matcher(locationHeaderUrl);
      boolean isApplicationLink = locationHeaderMatcher.find();

      if (isApplicationLink) {
        String applicationLink = locationHeaderMatcher.group(0);
        logger.log(Level.INFO, "Resolved application link is: " + applicationLink);

        return applicationLink;
      }
      else {
        return resolveLink(locationHeaderUrl, ++redirectCount);
      }
    }
    catch (Exception e) {
      throw new StorageException(e.getMessage(), e);
    }
  }
View Full Code Here

  private void parseLink(String applicationLink) throws StorageException {
    Matcher linkMatcher = LINK_PATTERN.matcher(applicationLink);

    if (!linkMatcher.matches()) {
      throw new StorageException("Invalid link provided, must start with syncany:// and match link pattern.");
    }

    encrypted = linkMatcher.group(LINK_PATTERN_GROUP_NOT_ENCRYPTED_FLAG) == null;

    if (encrypted) {
View Full Code Here

    // Create transfer settings object
    try {
      TransferPlugin plugin = Plugins.get(pluginId, TransferPlugin.class);

      if (plugin == null) {
        throw new StorageException("Link contains unknown connection type '" + pluginId + "'. Corresponding plugin not found.");
      }

      Class<? extends TransferSettings> pluginTransferSettingsClass = TransferPluginUtil.getTransferSettingsClass(plugin.getClass());
      TransferSettings transferSettings = new Persister().read(pluginTransferSettingsClass, pluginSettings);

      logger.log(Level.INFO, "(Decrypted) link contains: " + pluginId + " -- " + pluginSettings);

      return transferSettings;
    }
    catch (Exception e) {
      throw new StorageException(e);
    }
  }
View Full Code Here

        TransferSettings transferSettings = applicationLink.createTransferSettings();
        configTO.setTransferSettings(transferSettings);
      }
    }
    catch (Exception e) {
      throw new StorageException("Unable to extract connection settings: " + e.getMessage(), e);
    }

    return configTO;
  }
View Full Code Here

TOP

Related Classes of org.syncany.plugins.transfer.StorageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.