Package org.syncany.database.PartialFileHistory

Examples of org.syncany.database.PartialFileHistory.FileHistoryId


    assertEquals("12", FileHistoryId.parseFileId("12").toString());
  }
 
  @Test
  public void testFileHistoryIdRandom() {
    FileHistoryId secureRandomFileId1 = FileHistoryId.secureRandomFileId();
    FileHistoryId secureRandomFileId2 = FileHistoryId.secureRandomFileId();
   
    assertNotNull(secureRandomFileId1);
    assertEquals(20*2, secureRandomFileId1.toString().length());
   
    assertNotSame(secureRandomFileId1, secureRandomFileId2);
    assertNotNull(secureRandomFileId2);
    assertEquals(20*2, secureRandomFileId2.toString().length());   
  }
View Full Code Here


    try (PreparedStatement preparedStatement = getStatement("filehistory.select.master.expandFileHistoryId.sql")) {
      preparedStatement.setString(1, fileHistoryIdPrefixLikeQuery);

      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        if (resultSet.next()) {
          FileHistoryId fullFileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
         
          boolean nonUniqueResult = resultSet.next();
         
          if (nonUniqueResult) {
            return null;
View Full Code Here

    Map<FileHistoryId, PartialFileHistory> fileHistories = new HashMap<FileHistoryId, PartialFileHistory>();;
    PartialFileHistory fileHistory = null;

    while (resultSet.next()) {
      FileVersion lastFileVersion = fileVersionDao.createFileVersionFromRow(resultSet);
      FileHistoryId fileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
     
      // Old history (= same filehistory identifier)
      if (fileHistory != null && fileHistory.getFileHistoryId().equals(fileHistoryId)) { // Same history!
        fileHistory.addFileVersion(lastFileVersion);
      }
View Full Code Here

    List<PartialFileHistory> fileHistories = new ArrayList<PartialFileHistory>();

    try (PreparedStatement preparedStatement = getStatement("filehistory.select.master.getFileHistoriesWithLastVersion.sql")) {
      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
          FileHistoryId fileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
          FileVersion lastFileVersion = fileVersionDao.createFileVersionFromRow(resultSet);
 
          PartialFileHistory fileHistory = new PartialFileHistory(fileHistoryId);
          fileHistory.addFileVersion(lastFileVersion);
 
View Full Code Here

    try (PreparedStatement preparedStatement = getStatement("fileversion.select.all.getPurgeFileHistoriesWithFileVersionsByVectorClock.sql")) {
      preparedStatement.setString(1, purgeDatabaseVersionVectorClock.toString());

      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
          FileHistoryId purgeFileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
         
          // Create max purge version with dummy values (mandatory for XML serialization)
          FileVersion maxPurgeFileVersion = new FileVersion();
         
          maxPurgeFileVersion.setFileHistoryId(purgeFileHistoryId);
View Full Code Here

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file1.jpg");
    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertEquals(fileHistory1, database.getFileHistory("file1.jpg"));

    // Round 2: Add new version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file2.jpg", fileVersion1);
    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    database.addDatabaseVersion(databaseVersion2);

    assertNotNull(database.getFileHistory("file2.jpg"));
    assertEquals(2, database.getFileHistory("file2.jpg").getFileVersions().size());
    assertNull(database.getFileHistory("file1.jpg"));

    // Round 3: Add deleted version
    DatabaseVersion databaseVersion3 = TestDatabaseUtil.createDatabaseVersion(databaseVersion2);

    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("file2.jpg", fileVersion2);
    fileVersion3.setStatus(FileStatus.DELETED);

    FileHistoryId idFile3 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // same ID

    fileHistory3.addFileVersion(fileVersion3);
    databaseVersion3.addFileHistory(fileHistory3);
View Full Code Here

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file1.jpg");
    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertEquals(fileHistory1, database.getFileHistory("file1.jpg"));

    // Round 2: Add new version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - delete file1.jpg
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file1.jpg", fileVersion1);
    fileVersion2.setStatus(FileStatus.DELETED);

    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    // - add file1.jpg (as FOLDER!)
    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("file1.jpg"); // new file!
    fileVersion3.setType(FileType.FOLDER);

    FileHistoryId idFile3 = FileHistoryId.parseFileId("1111111111111112"); // different ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // same ID

    fileHistory3.addFileVersion(fileVersion3);
    databaseVersion2.addFileHistory(fileHistory3);
View Full Code Here

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("samechecksum1.jpg");
    fileVersion1.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertNotNull(database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })));
    assertEquals(1, database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })).size());

    // Round 2: Add two other versions with same checksum to new database version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - history 1, version 2
    FileVersion fileVersion11 = TestDatabaseUtil.createFileVersion("samechecksum2-renamed.jpg", fileVersion1);
    fileVersion11.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
    fileVersion11.setStatus(FileStatus.RENAMED);

    FileHistoryId idFile11 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory11 = new PartialFileHistory(idFile11); // same ID as above

    fileHistory11.addFileVersion(fileVersion11);
    databaseVersion2.addFileHistory(fileHistory11);

    // - history 2, version 1
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("samechecksum2.jpg");
    fileVersion2.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!

    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111122222222"); // different ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    // - history 3, version 1
    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("samechecksum3.jpg");
    fileVersion3.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!

    FileHistoryId idFile3 = FileHistoryId.parseFileId("aaaaaaaa22222222"); // different ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // different ID

    fileHistory3.addFileVersion(fileVersion3);
    databaseVersion2.addFileHistory(fileHistory3);
View Full Code Here

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("samechecksum1.jpg");
    fileVersion1.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    FileHistoryId idFile1Get = FileHistoryId.parseFileId("1111111111111111");
    assertNotNull(database.getFileHistory(idFile1Get));
    assertEquals(fileHistory1, database.getFileHistory(idFile1Get));

    // Round 2: Add two other versions with same checksum to new database version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - history 1, version 2
    FileVersion fileVersion11 = TestDatabaseUtil.createFileVersion("samechecksum2-renamed.jpg", fileVersion1);
    fileVersion11.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
    fileVersion11.setStatus(FileStatus.RENAMED);

    FileHistoryId idFile11 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory11 = new PartialFileHistory(idFile11);

    fileHistory11.addFileVersion(fileVersion11);
    databaseVersion2.addFileHistory(fileHistory11);

    database.addDatabaseVersion(databaseVersion2);

    FileHistoryId idFile111 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    assertNotNull(database.getFileHistory(idFile111));
    assertEquals(2, database.getFileHistory(idFile111).getFileVersions().size());
  }
View Full Code Here

    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file.jpg");

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);
   
    // - history 1, version 2   
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file.jpg", fileVersion1);

    FileHistoryId idFile1b = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1b = new PartialFileHistory(idFile1b);

    fileHistory1b.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory1b);
View Full Code Here

TOP

Related Classes of org.syncany.database.PartialFileHistory.FileHistoryId

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.