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

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


    if (loadedContent == null) {
      context.provideLocations(null);
    } else {
      Locations locations = (Locations) loadedContent;
      if (!locations.getUserId().equalsIgnoreCase(userId))
        throw new ProcessExecutionException(String.format(
            "The wrong locations have been loaded. Required: %s. Got: %s.", userId,
            locations.getUserId()));

      context.provideLocations(locations);
    }
View Full Code Here


    // file node is null, first look it up in the user profile
    UserProfile profile = null;
    try {
      profile = session.getProfileManager().getUserProfile(getID(), false);
    } catch (GetFailedException e) {
      throw new ProcessExecutionException(e);
    }

    Index fileNode = profile.getFileByPath(file, session.getRoot());
    if (fileNode == null) {
      throw new ProcessExecutionException(
          "File does not exist in user profile. Consider uploading a new file.");
    }

    // set the corresponding content protection keys
    protectionContext.provideProtectionKeys(fileNode.getProtectionKeys());
View Full Code Here

    MetaFileSmall metaFileSmall = (MetaFileSmall) context.consumeMetaFile();
    byte[] newMD5;
    try {
      newMD5 = EncryptionUtil.generateMD5Hash(context.getFile());
    } catch (IOException e) {
      throw new ProcessExecutionException(
          "The new MD5 hash for the user profile could not be generated.", e);
    }

    try {
      UserProfile userProfile = profileManager.getUserProfile(getID(), true);
      FileIndex index = (FileIndex) userProfile.getFileById(metaFileSmall.getId());

      // store hash of meta file
      index.setMetaFileHash(context.consumeHash());

      // store for backup
      originalMD5 = index.getMD5();
      if (H2HEncryptionUtil.compareMD5(originalMD5, newMD5)) {
        throw new ProcessExecutionException("Try to create new version with same content.");
      }

      // make and put modifications
      index.setMD5(newMD5);
      logger.debug("Updating the MD5 hash in the user profile.");
      profileManager.readyToPut(userProfile, getID());

      // store for notification
      context.provideIndex(index);
    } catch (GetFailedException | PutFailedException e) {
      throw new ProcessExecutionException(e);
    }
  }
View Full Code Here

  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {

    NetworkContent loadedContent = get(credentials.getProfileLocationKey(), H2HConstants.USER_PROFILE);

    if (loadedContent == null) {
      throw new ProcessExecutionException("User profile not found.");
    } else {
      // decrypt user profile
      EncryptedNetworkContent encryptedContent = (EncryptedNetworkContent) loadedContent;

      SecretKey decryptionKey = PasswordUtil.generateAESKeyFromPassword(credentials.getPassword(),
          credentials.getPin(), H2HConstants.KEYLENGTH_USER_PROFILE);

      NetworkContent decryptedContent = null;
      try {
        decryptedContent = H2HEncryptionUtil.decryptAES(encryptedContent, decryptionKey);
      } catch (DataLengthException | IllegalStateException | InvalidCipherTextException
          | ClassNotFoundException | IOException e) {
        throw new ProcessExecutionException("User profile could not be decrypted.");
      }

      UserProfile profile = (UserProfile) decryptedContent;
      profile.setVersionKey(loadedContent.getVersionKey());
      profile.setBasedOnKey(loadedContent.getBasedOnKey());
View Full Code Here

public class FailingProcessStep extends ProcessStep {

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
   
    throw new ProcessExecutionException("Test process step that must fail.");
  }
View Full Code Here

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    try {
      verifyFiles();
    } catch (NoSessionException | IllegalArgumentException e) {
      throw new ProcessExecutionException(String.format("File verification failed. reason = '%s'",
          e.getMessage()), e);
    }

    try {
      getFileKeys();
    } catch (GetFailedException | NoSessionException | IllegalStateException e) {
      throw new ProcessExecutionException(String.format(
          "File keys could not be fetched. reason = '%s'", e.getMessage()), e);
    }

    try {
      // move the file
      Files.move(context.getSource().toPath(), context.getDestination().toPath(),
          StandardCopyOption.ATOMIC_MOVE);
      logger.debug("Moved the file from '{}' to '{}'.", context.getSource().getAbsolutePath(), context
          .getDestination().getAbsolutePath());
    } catch (IOException e) {
      throw new ProcessExecutionException("File could not be moved to destination.", e);
    }
  }
View Full Code Here

 
  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    super.doExecute();
 
    throw new ProcessExecutionException("Test process that must fail.");
  }
View Full Code Here

    locations.setBasedOnKey(locations.getVersionKey());
    try {
      locations.generateVersionKey();
    } catch (IOException e) {
      throw new ProcessExecutionException("Could not generate version key.", e);
    }

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

  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    if (context.consumeMetaFile() == null) {
      throw new ProcessExecutionException("Meta document is null.");
    }

    logger.debug("Adding a new version to the meta file.");

    // create a new version and add it to the meta file
View Full Code Here

    DataManager dataManager;
    try {
      dataManager = networkManager.getDataManager();
    } catch (NoPeerConnectionException e) {
      throw new ProcessExecutionException(e);
    }

    logger.debug("Get the next user profile task of user '{}'.", userId);
    NetworkContent content = dataManager.getUserProfileTask(userId);

    if (content == null) {
      logger.warn("Did not get an user profile task. User ID = '{}'.", userId);
      context.provideUserProfileTask(null);
    } else {
      logger.debug("Got encrypted user profile task. User ID = '{}'", userId);

      HybridEncryptedContent encrypted = (HybridEncryptedContent) content;
      PrivateKey key = null;
      try {
        key = networkManager.getSession().getKeyPair().getPrivate();
      } catch (NoSessionException e) {
        throw new ProcessExecutionException(e);
      }
      NetworkContent decrypted = null;
      try {
        decrypted = H2HEncryptionUtil.decryptHybrid(encrypted, key);
      } catch (InvalidKeyException | DataLengthException | IllegalBlockSizeException
          | BadPaddingException | IllegalStateException | InvalidCipherTextException
          | ClassNotFoundException | IOException e) {
        throw new ProcessExecutionException("Could not decrypt user profile task.", e);
      }
      context.provideUserProfileTask((UserProfileTask) decrypted);
      logger.debug("Successfully decrypted a user profile task. User ID = '{}'.", userId);

    }
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.