Examples of FileIndex


Examples of com.intellij.openapi.roots.FileIndex

    public PackageScope(@NotNull PsiPackage aPackage, boolean includeSubpackages, final boolean includeLibraries) {
      myPackage = aPackage;
      myIncludeSubpackages = includeSubpackages;

      Project project = myPackage.getProject();
      FileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
      myDirs = fileIndex.getDirsByPackageName(myPackage.getQualifiedName(), true).findAll();
      myIncludeLibraries = includeLibraries;
    }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

    file2d.mkdir();

    userProfile = new UserProfile("test-user");
    root = userProfile.getRoot();
    KeyPair keys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_META_FILE);
    node1f1 = new FileIndex(root, keys, "1f1", EncryptionUtil.generateMD5Hash(file1f1));
    node1f2 = new FileIndex(root, keys, "1f2", EncryptionUtil.generateMD5Hash(file1f2));
    node1d = new FolderIndex(root, keys, "1d");
    node2f = new FileIndex(node1d, keys, "2f", EncryptionUtil.generateMD5Hash(file2f));
    node2d = new FolderIndex(node1d, keys, "2d");

    // write the meta data now. Before creating the synchronizer, modify the file system as desired first.
    FileUtil.writePersistentMetaData(rootPath, null, null);
  }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

          "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);
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

  }

  @Test
  public void testAddedRemotely() throws IOException, ClassNotFoundException {
    KeyPair keys = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_META_FILE);
    Index node1f3 = new FileIndex(root, keys, "1f3", null);
    Index node2d2 = new FolderIndex(node1d, keys, "2d2");

    FileSynchronizer fileSynchronizer = new FileSynchronizer(rootPath, userProfile);
    List<Index> addedRemotely = fileSynchronizer.getAddedRemotely();
    Assert.assertEquals(2, addedRemotely.size());
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

    MetaFileSmall metaFileSmall = (MetaFileSmall) context.consumeMetaFile();
    if (metaFileSmall != null) {
      try {
        // return to original MD5 and put the userProfile
        UserProfile userProfile = profileManager.getUserProfile(getID(), true);
        FileIndex fileNode = (FileIndex) userProfile.getFileById(metaFileSmall.getId());
        fileNode.setMD5(originalMD5);
        profileManager.readyToPut(userProfile, getID());
      } catch (Exception e) {
        // ignore
      }
    }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

  private static void checkFileIndex(Path relativePath, byte[] md5Hash) throws GetFailedException,
      NoSessionException {
    UserProfile userProfileA = nodeA.getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    FileIndex indexA = (FileIndex) userProfileA.getFileByPath(relativePath);

    UserProfile userProfileB = nodeB.getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    FileIndex indexB = (FileIndex) userProfileB.getFileByPath(relativePath);

    // check if index is file
    Assert.assertTrue(indexA.isFile());
    Assert.assertTrue(indexB.isFile());

    // check if isShared flag is set
    Assert.assertTrue(indexA.isShared());
    Assert.assertTrue(indexB.isShared());

    // check write access
    Assert.assertTrue(indexA.canWrite());
    // user B isn't allowed to write
    Assert.assertFalse(indexB.canWrite());

    // check if md5 hash is the same
    Assert.assertTrue(Arrays.equals(indexA.getMD5(), md5Hash));
    Assert.assertTrue(Arrays.equals(indexB.getMD5(), md5Hash));

    // check if userA's content protection keys are other ones
    Assert.assertFalse(indexA.getProtectionKeys().getPrivate()
        .equals(userProfileA.getProtectionKeys().getPrivate()));
    Assert.assertFalse(indexA.getProtectionKeys().getPublic()
        .equals(userProfileA.getProtectionKeys().getPublic()));
    // check if user B has no content protection keys
    Assert.assertNull(indexB.getProtectionKeys());

    // check user permissions at A
    Set<String> usersA = indexA.getCalculatedUserList();
    Assert.assertEquals(2, usersA.size());
    Assert.assertTrue(usersA.contains(userA.getUserId()));
    Assert.assertTrue(usersA.contains(userB.getUserId()));

    // check user permissions at A
    Set<String> usersB = indexB.getCalculatedUserList();
    Assert.assertEquals(2, usersB.size());
    Assert.assertTrue(usersB.contains(userA.getUserId()));
    Assert.assertTrue(usersB.contains(userB.getUserId()));
  }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

  private static void checkFileIndex(Path relativePath, byte[] md5Hash) throws GetFailedException,
      NoSessionException {
    UserProfile userProfileA = network.get(0).getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    FileIndex indexA = (FileIndex) userProfileA.getFileByPath(relativePath);

    UserProfile userProfileB = network.get(1).getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    FileIndex indexB = (FileIndex) userProfileB.getFileByPath(relativePath);

    // check if index is file
    Assert.assertTrue(indexA.isFile());
    Assert.assertTrue(indexB.isFile());

    // check if md5 hash is the same
    Assert.assertTrue(Arrays.equals(indexA.getMD5(), md5Hash));
    Assert.assertTrue(Arrays.equals(indexB.getMD5(), md5Hash));

    // check if content protection keys are the same
    Assert.assertTrue(indexA.getProtectionKeys().getPrivate()
        .equals(indexB.getProtectionKeys().getPrivate()));
    Assert.assertTrue(indexA.getProtectionKeys().getPublic()
        .equals(indexB.getProtectionKeys().getPublic()));

    // check if isShared flag is set
    Assert.assertTrue(indexA.isShared());
    Assert.assertTrue(indexB.isShared());

    // check write access
    Assert.assertTrue(indexA.canWrite());
    Assert.assertTrue(indexB.canWrite());

    // check user permissions at A
    Set<String> usersA = indexA.getCalculatedUserList();
    Assert.assertEquals(2, usersA.size());
    Assert.assertTrue(usersA.contains(userA.getUserId()));
    Assert.assertTrue(usersA.contains(userB.getUserId()));

    // check user permissions at A
    Set<String> usersB = indexB.getCalculatedUserList();
    Assert.assertEquals(2, usersB.size());
    Assert.assertTrue(usersB.contains(userA.getUserId()));
    Assert.assertTrue(usersB.contains(userB.getUserId()));
  }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

      waiter.tickASecond();
    } while (!listener.hasFailed());

    // verify if the md5 hash did not change
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    FileIndex fileNode = (FileIndex) userProfile.getFileByPath(file, uploaderRoot);
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(file, fileNode.getMD5()));

    // verify that only one version was created
    MetaFileSmall metaDocument = (MetaFileSmall) UseCaseTestUtil.getMetaFile(downloader,
        fileNode.getFileKeys());
    Assert.assertEquals(1, metaDocument.getVersions().size());
  }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

    file2 = new File(root1, "file 2");
    Assert.assertEquals(file2Content, FileUtils.readFileToString(file2));

    /** verify if the local changes have been uploaded **/
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(network.get(1), userCredentials);
    FileIndex file1Node = (FileIndex) userProfile.getFileByPath(Paths.get("file 1"));
    // modifications have been uploaded
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(newMD5File1, file1Node.getMD5()));

    /** verify the file that has been modified remotely and locally **/
    FileIndex file3Node = (FileIndex) userProfile.getFileByPath(Paths.get("folder 1", "file 3"));
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(newMD5File3, file3Node.getMD5()));
  }
View Full Code Here

Examples of org.hive2hive.core.model.FileIndex

  private boolean validateDestination() throws InvalidProcessStateException {
    // verify before downloading
    if (destination != null && destination.exists()) {
      try {
        // can be cast because only files are downloaded
        FileIndex fileIndex = (FileIndex) context.consumeIndex();
        if (H2HEncryptionUtil.compareMD5(destination, fileIndex.getMD5())) {
          return false;
        } else {
          logger.warn("File already exists on disk. It will be overwritten.");
        }
      } catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.