Package org.hive2hive.core

Examples of org.hive2hive.core.H2HSession


  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    UserProfile userProfile = context.consumeUserProfile();

    H2HSession session;
    try {
      // get the persistently cached items
      PersistentMetaData metaData = FileUtil.readPersistentMetaData(params.getRoot());

      // create the key manager
      PublicKeyManager keyManager = new PublicKeyManager(userProfile.getUserId(),
          userProfile.getEncryptionKeys(), networkManager.getDataManager());

      // read eventually cached keys and add them to the key manager
      Map<String, PublicKey> publicKeyCache = metaData.getPublicKeyCache();
      for (String userId : publicKeyCache.keySet()) {
        keyManager.putPublicKey(userId, publicKeyCache.get(userId));
      }
      params.setKeyManager(keyManager);

      // create the download manager
      DownloadManager downloadManager = new DownloadManager(networkManager.getDataManager(),
          networkManager.getMessageManager(), keyManager, params.getFileConfig());

      // read the cached downloads and add them to the download manager
      for (BaseDownloadTask task : metaData.getDownloads()) {
        task.reinitializeAfterDeserialization();
        downloadManager.submit(task);
      }
      params.setDownloadManager(downloadManager);

      // create session
      session = new H2HSession(params);
    } catch (IOException | NoPeerConnectionException e) {
      throw new ProcessExecutionException("Session could not be created.", e);
    }

    // set session
View Full Code Here


    move();
  }

  private void move() {
    try {
      H2HSession session = networkManager.getSession();
      UserProfileManager profileManager = session.getProfileManager();
      UserProfile userProfile = profileManager.getUserProfile(UUID.randomUUID().toString(), false);

      Index oldParent = userProfile.getFileById(oldParentKey);
      Index newParent = userProfile.getFileById(newParentKey);
      FileUtil.moveFile(session.getRoot(), sourceFileName, destFileName, oldParent, newParent);
    } catch (NoSessionException | GetFailedException | IOException e) {
      logger.error("Could not process the notification message.", e);
    }

  }
View Full Code Here

  }

  @Override
  public void start() {
    try {
      H2HSession session = networkManager.getSession();

      // remove dead link from user profile
      Index toDelete = updateUserProfile(session.getProfileManager());

      if (toDelete == null)
        return;

      // remove the file on disk
      removeFileOnDisk(session.getRoot(), toDelete);

      // notify others
      startNotification(toDelete);
    } catch (Hive2HiveException e) {
      logger.error("Could not execute the task.", e);
View Full Code Here

    delete();
  }

  private void delete() {
    try {
      H2HSession session = networkManager.getSession();
      String pid = UUID.randomUUID().toString();

      Path root = session.getRoot();
      UserProfile userProfile = session.getProfileManager().getUserProfile(pid, false);
      Index parentNode = userProfile.getFileById(parentFileKey);

      if (parentNode == null) {
        throw new FileNotFoundException("Got notified about a file we don't know the parent of.");
      } else {
View Full Code Here

TOP

Related Classes of org.hive2hive.core.H2HSession

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.