Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.Index


  }

  @Override
  protected void doExecute() throws InvalidProcessStateException {
    // get the recently added index
    Index index = context.consumeIndex();

    // get the users belonging to that index
    HashSet<String> users = new HashSet<String>();
    users.addAll(index.getCalculatedUserList());
    context.provideUsersToNotify(users);

    // prepare the file tree node for sending to other users
    PublicKey parentKey = index.getParent().getFilePublicKey();
    index.setParent(null);

    UploadNotificationMessageFactory messageFactory = new UploadNotificationMessageFactory(index,
        parentKey);
    context.provideMessageFactory(messageFactory);
  }
View Full Code Here


    // 2. add the file with an AddFileProcess (which also notifies other clients)
    try {
      // find the node at the user profile
      UserProfileManager profileManager = networkManager.getSession().getProfileManager();
      UserProfile userProfile = profileManager.getUserProfile(getID(), false);
      Index selectedNode = userProfile.getFileById(metaFileSmall.getId());
      if (selectedNode == null) {
        throw new Hive2HiveException("File node not found");
      }

      // ask the user for the new file name
      String originalFileName = context.getFile().getName();
      String noSuffix = FilenameUtils.removeExtension(originalFileName);
      String extension = FilenameUtils.getExtension(originalFileName);
      String recoveredFileName = selector.getRecoveredFileName(originalFileName, noSuffix, extension);
      if (recoveredFileName == null || originalFileName.equals(recoveredFileName)) {
        // generate a new file name indicating that the file is restored
        logger.warn("Replacing the given file name with a custom file name because it was invalid.");
        Date versionDate = new Date(selected.getDate());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
        recoveredFileName = noSuffix + "-" + sdf.format(versionDate) + "." + extension;
      }

      logger.debug("Starting to download the restored file under the name '{}'.", recoveredFileName);
      File destination = new File(context.getFile().getParentFile(), recoveredFileName);

      // add the process to download the file
      ProcessComponent downloadProcess = ProcessFactory.instance().createDownloadFileProcess(
          selectedNode.getFilePublicKey(), selected.getIndex(), destination, networkManager);
      getParent().add(downloadProcess);

      // add the process to upload the file
      ProcessComponent addProcess = ProcessFactory.instance().createNewFileProcess(destination,
          networkManager);
View Full Code Here

TOP

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

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.