Package org.hive2hive.core.processes.framework.exceptions

Examples of org.hive2hive.core.processes.framework.exceptions.ProcessExecutionException


    EncryptedNetworkContent encryptedProfile = null;
    try {
      encryptedProfile = H2HEncryptionUtil.encryptAES(userProfile, encryptionKey);
    } catch (DataLengthException | IllegalStateException | InvalidCipherTextException | IOException e) {
      throw new ProcessExecutionException("User profile could not be encrypted.");
    }

    try {
      encryptedProfile.generateVersionKey();
    } catch (IOException e) {
      throw new ProcessExecutionException("User profile version key could not be generated.", e);
    }

    // assign ttl value
    encryptedProfile.setTimeToLive(userProfile.getTimeToLive());
   
    // put encrypted user profile
    try {
      put(credentials.getProfileLocationKey(), H2HConstants.USER_PROFILE, encryptedProfile,
          userProfile.getProtectionKeys());
      logger.debug("User profile successfully put for user {}.", credentials.getUserId());
    } catch (PutFailedException e) {
      throw new ProcessExecutionException(e);
    }
  }
View Full Code Here


    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);

    // add the next steps here
    if (index.isFolder()) {
      logger.info("No download of the file needed since '{}' is a folder.", index.getFullPath());
      getParent().add(new CreateFolderStep(context, networkManager));
    } else {
      logger.info("Initalize the process for downloading file '{}'.", index.getFullPath());
      try {
        IDataManager dataManager = networkManager.getDataManager();
        getParent().add(new GetMetaFileStep(context, context, dataManager));
        PeerAddress ownPeerAddress = networkManager.getConnection().getPeer().getPeerAddress();
        getParent().add(
            new InitDownloadChunksStep(context, networkManager.getSession(), ownPeerAddress));
      } catch (NoPeerConnectionException | NoSessionException e) {
        throw new ProcessExecutionException(e);
      }
    }
  }
View Full Code Here

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    try {
      remove(locationKey, H2HConstants.FILE_CHUNK, protectionKeys);
    } catch (RemoveFailedException e) {
      throw new ProcessExecutionException("Removal of chunk failed.", e);
    }
  }
View Full Code Here

  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    if (context.consumeMetaFile() == null) {
      throw new ProcessExecutionException("No meta document given.");
    }
    if (context.consumeProtectionKeys() == null) {
      throw new ProcessExecutionException("No protection keys given.");
    }

    List<MetaChunk> metaChunks = new ArrayList<MetaChunk>();
    MetaFile metaFile = context.consumeMetaFile();
View Full Code Here

        .setHash(context.getHash());

    boolean success = dataManager.changeProtectionKey(parameters);
    changePerformed = true;
    if (!success) {
      throw new ProcessExecutionException(String.format("Could not change content protection keys. %s",
          parameters.toString()));
    }
  }
View Full Code Here

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    MetaFile metaFile = context.consumeMetaFile();
    if (metaFile == null) {
      throw new ProcessExecutionException("Meta File not found");
    } else if (!(metaFile.isSmall())) {
      logger.debug("No need to update any chunks for a large meta file");
      return;
    }
View Full Code Here

  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    // write the current state to a meta file
    try {
      FileUtil.writePersistentMetaData(root, keyManager, downloadManager);
    } catch (IOException e) {
      throw new ProcessExecutionException("Meta data could not be persisted.", e);
    }
  }
View Full Code Here

    // get user profile
    UserProfile profile = null;
    try {
      profile = profileManager.getUserProfile(getID(), true);
    } catch (GetFailedException e) {
      throw new ProcessExecutionException("Could not get user profile.", e);
    }

    index = profile.getFileByPath(file, root);

    // validate
    if (index == null) {
      throw new ProcessExecutionException("File index not found in user profile");
    } else if (!index.canWrite()) {
      throw new ProcessExecutionException("Not allowed to delete this file (read-only permissions)");
    }

    // check preconditions
    if (index.isFolder()) {
      FolderIndex folder = (FolderIndex) index;
      if (!folder.getChildren().isEmpty()) {
        throw new ProcessExecutionException("Cannot delete a directory that is not empty.");
      }
    }

    // remove the node from the tree
    FolderIndex parentIndex = index.getParent();
    parentIndex.removeChild(index);

    // store for later
    context.provideIndex(index);
    context.setParentNode(parentIndex);

    // store for rollback
    this.parentIndexKey = parentIndex.getFilePublicKey();

    try {
      profileManager.readyToPut(profile, getID());
    } catch (PutFailedException e) {
      throw new ProcessExecutionException("Could not put user profile.");
    }

    if (index.isFile()) {
      /**
       * Delete the meta file and all chunks
View Full Code Here

  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {

    Locations locations = context.consumeLocations();

    if (locations == null) {
      throw new ProcessExecutionException("Locations not found.");
    } else {

      // remove peer
      locations.removePeerAddress(networkManager.getConnection().getPeer().getPeerAddress());
      locations.setBasedOnKey(locations.getVersionKey());
      try {
        locations.generateVersionKey();
      } catch (IOException e) {
        throw new ProcessExecutionException("Version key could not be generated.", e);
      }

      // put updated locations
      String userId = context.consumeSession().getCredentials().getUserId();

      KeyPair protectionKeys = null;
      try {
        protectionKeys = context.consumeSession().getProfileManager().getDefaultProtectionKey();
      } catch (GetFailedException e) {
        throw new ProcessExecutionException("Default protection keys could not be loaded.", e);
      }

      try {
        put(userId, H2HConstants.USER_LOCATIONS, locations, protectionKeys);
      } catch (PutFailedException e) {
        throw new ProcessExecutionException(e);
      }
    }
  }
View Full Code Here

      } else {
        FileIndex fileIndex = (FileIndex) index;
        initForFile(fileIndex);
      }
    } catch (NoSessionException | NoPeerConnectionException e) {
      throw new ProcessExecutionException(e);
    }

  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.processes.framework.exceptions.ProcessExecutionException

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.