Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.UserProfile


  public void start() {
    try {
      // get the user profile first
      String randomPID = UUID.randomUUID().toString();
      UserProfileManager profileManager = networkManager.getSession().getProfileManager();
      UserProfile userProfile = profileManager.getUserProfile(randomPID, true);
      FolderIndex parentNode = (FolderIndex) userProfile.getFileById(parentKey);
      if (parentNode == null) {
        logger.error("Could not process the task because the parent node has not been found.");
        return;
      }
View Full Code Here


      md5 = calculateHash(file);
    }

    logger.trace("Start updating the user profile where adding the file '{}'.", file.getName());
    try {
      UserProfile userProfile = profileManager.getUserProfile(getID(), true);

      // find the parent node using the relative path to navigate there
      FolderIndex parentNode = (FolderIndex) userProfile.getFileByPath(file.getParentFile(), root);

      // validate the write protection
      if (!parentNode.canWrite()) {
        throw new ProcessExecutionException("This directory is write protected (and we don't have the keys).");
      }
View Full Code Here

  @Override
  protected void doRollback(RollbackReason reason) throws InvalidProcessStateException {
    if (modified) {
      // remove the file from the user profile
      UserProfile userProfile;
      try {
        userProfile = profileManager.getUserProfile(getID(), true);
      } catch (GetFailedException e) {
        return;
      }
      FolderIndex parentNode = (FolderIndex) userProfile.getFileById(parentKey);
      Index childNode = parentNode.getChildByName(context.getFile().getName());
      parentNode.removeChild(childNode);
      try {
        profileManager.readyToPut(userProfile, getID());
        modified = false;
View Full Code Here

  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
    protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
      try {
        UserProfile userProfile = profileManager.getUserProfile(getID(), operation == Operation.PUT);

        if (operation == Operation.MODIFY) {
          new FolderIndex(userProfile.getRoot(), null, NetworkTestUtil.randomString());
        }

        if (operation == Operation.PUT) {
          profileManager.readyToPut(userProfile, getID());
        }
View Full Code Here

        keys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_META_FILE);
        md5Hash = EncryptionUtil.generateMD5Hash(file);
      }

      String pid = UUID.randomUUID().toString();
      UserProfile profile = profileManager.getUserProfile(pid, true);

      List<FolderIndex> indexes = getIndexList(profile.getRoot());

      if (isFolder) {
        new FolderIndex(indexes.get(random.nextInt(indexes.size())), null, NetworkTestUtil.randomString());
      } else {
        new FileIndex(indexes.get(random.nextInt(indexes.size())), keys, file.getName(), md5Hash);
View Full Code Here

    this.context = context;
  }

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

    UserPublicKey publicKey = new UserPublicKey(profile.getEncryptionKeys().getPublic());
    try {
      put(profile.getUserId(), H2HConstants.USER_PUBLIC_KEY, publicKey, profile.getProtectionKeys());
    } catch (PutFailedException e) {
      throw new ProcessExecutionException(e);
    }
  }
View Full Code Here

   */
  private Index updateUserProfile(UserProfileManager profileManager) throws GetFailedException,
      PutFailedException {
    String randomPID = UUID.randomUUID().toString();

    UserProfile userProfile = profileManager.getUserProfile(randomPID, true);
    Index toDelete = userProfile.getFileById(fileKey);
    if (toDelete == null) {
      logger.warn("Could not delete the file because it does not exist anymore.");
      return null;
    }

View Full Code Here

  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    // get the user profile
    UserProfile profile = null;
    try {
      profile = profileManager.getUserProfile(getID(), false);
    } catch (GetFailedException e) {
      throw new ProcessExecutionException("User profile could not be loaded.");
    }

    // the result set
    result.clear();

    // build the digest recursively
    FolderIndex root = profile.getRoot();
    List<Index> digest = Index.getIndexList(root);
    for (Index index : digest) {
      if (index.equals(root)) {
        // skip the root
        continue;
View Full Code Here

    this.networkManager = networkManager;
  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    UserProfile userProfile = null;
    try {
      UserProfileManager profileManager = networkManager.getSession().getProfileManager();
      userProfile = profileManager.getUserProfile(getID(), false);
    } catch (GetFailedException | NoSessionException e) {
      throw new ProcessExecutionException(e);
    }

    Index index = userProfile.getFileById(context.getFileKey());
    if (index == null) {
      throw new ProcessExecutionException("File key not found in user profile.");
    }

    context.provideIndex(index);
View Full Code Here

TOP

Related Classes of org.hive2hive.core.model.UserProfile

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.