Package org.syncany.database

Examples of org.syncany.database.PartialFileHistory


    newDatabaseVersionHeader.setDate(new Date(1489977288000L));
    newDatabaseVersionHeader.setVectorClock(TestDatabaseUtil.createVectorClock("A5,C1"));
   
    newDatabaseVersion.setHeader(newDatabaseVersionHeader);
   
    PartialFileHistory newFileHistory = new PartialFileHistory(FileHistoryId.secureRandomFileId());
    FileVersion newFileVersion = new FileVersion();
   
    newFileVersion.setVersion(1L);
    newFileVersion.setPath("newfile");
    newFileVersion.setChecksum(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"));
    newFileVersion.setLinkTarget(null);
    newFileVersion.setPosixPermissions("rwxrwxrwx");
    newFileVersion.setDosAttributes(null);
    newFileVersion.setStatus(FileStatus.NEW);
    newFileVersion.setLastModified(new Date());
    newFileVersion.setUpdated(new Date());
    newFileVersion.setSize(1L);
    newFileVersion.setType(FileType.FILE);

    newFileHistory.addFileVersion(newFileVersion);
    newDatabaseVersion.addFileHistory(newFileHistory);

    ChunkEntry newChunkEntry = new ChunkEntry(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), 1);
    newDatabaseVersion.addChunk(newChunkEntry);
   
View Full Code Here


   
    FileVersion fileVersion2 = new FileVersion();
    fileVersion2.setVersion(2L);
    fileVersion2.setPath("/somepath");

    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
    fileHistory.addFileVersion(fileVersion1);
    fileHistory.addFileVersion(fileVersion2);
   
    PartialFileHistory fileHistoryClone = fileHistory.clone();
   
    assertEquals(fileHistory, fileHistoryClone);
    assertEquals(fileHistory.getFileVersions().size(), fileHistoryClone.getFileVersions().size());
    assertEquals(fileHistory.getFileVersions(), fileHistoryClone.getFileVersions());

    FileVersion fileVersion3 = new FileVersion();
    fileVersion3.setVersion(3L);
    fileVersion3.setPath("/somepath");
   
    fileHistoryClone.addFileVersion(fileVersion3);
    assertEquals(fileHistory.getFileVersions().size()+1, fileHistoryClone.getFileVersions().size());
 
View Full Code Here

    assertEquals("8ce24fc0ea8e685eb23bf6346713ad9fef920425", historiesFromA3.get(FileHistoryId.parseFileId("4fef2d605640813464792b18b16e1a5e07aa4e53")).getLastVersion().getChecksum().toString());
   
    assertNotNull(historiesFromB1);
    assertEquals(2, historiesFromB1.size());
   
    PartialFileHistory file1 = historiesFromB1.get(FileHistoryId.parseFileId("851c441915478a539a5bab2b263ffa4cc48e282f"));
    PartialFileHistory file2 = historiesFromB1.get(FileHistoryId.parseFileId("beef111111111111111111111111111111111111"));
   
    assertNotNull(file1);
    assertEquals("851c441915478a539a5bab2b263ffa4cc48e282f", file1.getFileHistoryId().toString());
    assertEquals("fe83f217d464f6fdfa5b2b1f87fe3a1a47371196", file1.getLastVersion().getChecksum().toString());
    assertEquals(2, (long) file1.getLastVersion().getVersion());

    assertNotNull(file2);
    assertEquals("beef111111111111111111111111111111111111", file2.getFileHistoryId().toString());
    assertEquals("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef", file2.getLastVersion().getChecksum().toString());
    assertEquals(1, (long) file2.getLastVersion().getVersion());   

    assertNotNull(historiesFromA4);
    assertEquals(1, historiesFromA4.size());
    assertEquals("851c441915478a539a5bab2b263ffa4cc48e282f", historiesFromA4.get(FileHistoryId.parseFileId("851c441915478a539a5bab2b263ffa4cc48e282f")).getFileHistoryId().toString());
    assertEquals("fe83f217d464f6fdfa5b2b1f87fe3a1a47371196", historiesFromA4.get(FileHistoryId.parseFileId("851c441915478a539a5bab2b263ffa4cc48e282f")).getLastVersion().getChecksum().toString());
View Full Code Here

    }
  }

  protected Map<FileHistoryId, PartialFileHistory> createFileHistoriesFromResult(ResultSet resultSet) throws SQLException {
    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);
      }
     
      // New history!     
      else {
        // Add the old history
        if (fileHistory != null) {
          fileHistories.put(fileHistory.getFileHistoryId(), fileHistory);
        }
       
        // Create a new one
        fileHistory = new PartialFileHistory(fileHistoryId);
        fileHistory.addFileVersion(lastFileVersion);
      }     
    }
   
    // Add the last history
    if (fileHistory != null) {
      fileHistories.put(fileHistory.getFileHistoryId(), fileHistory);
    }

    return fileHistories;
  }
View Full Code Here

      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);
 
          fileHistories.add(fileHistory);
        }
      }
View Full Code Here

          maxPurgeFileVersion.setType(FileType.FILE);
          maxPurgeFileVersion.setStatus(FileStatus.DELETED);
          maxPurgeFileVersion.setSize(0L);
          maxPurgeFileVersion.setLastModified(new Date());
 
          PartialFileHistory fileHistory = new PartialFileHistory(purgeFileHistoryId);
          fileHistory.addFileVersion(maxPurgeFileVersion);
 
          fileHistories.add(fileHistory);
        }
      }
     
View Full Code Here

   
    clientA.deleteFile("new folder/some subfolder"); // Delete this!
   
    // - Create new version (delete folder)
    TestSqlDatabase sqlDatabaseA = new TestSqlDatabase(testConfigA);
    PartialFileHistory folderFileHistoryWithLastVersion = sqlDatabaseA.getFileHistoryWithLastVersion("new folder/some subfolder");

    FileVersion deletedFolderVersion = folderFileHistoryWithLastVersion.getLastVersion().clone();
    deletedFolderVersion.setStatus(FileStatus.DELETED);
    deletedFolderVersion.setVersion(deletedFolderVersion.getVersion()+1);
   
    PartialFileHistory deletedFolderVersionHistory = new PartialFileHistory(folderFileHistoryWithLastVersion.getFileHistoryId());
    deletedFolderVersionHistory.addFileVersion(deletedFolderVersion);
   
    DatabaseVersion winnersDatabaseVersion = TestDatabaseUtil.createDatabaseVersion(sqlDatabaseA.getLastDatabaseVersionHeader());   
    winnersDatabaseVersion.addFileHistory(deletedFolderVersionHistory);
   
    // - Create memory database with this version
View Full Code Here

import org.syncany.database.PartialFileHistory.FileHistoryId;

public class PartialFileHistoryTest {
  @Test
  public void testFileHistoryInitEmpty() {
    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
   
    assertEquals(FileHistoryId.parseFileId("1234"), fileHistory.getFileHistoryId());
    assertNotSame(FileHistoryId.parseFileId("9999"), fileHistory.getFileHistoryId());
    assertNull(fileHistory.getLastVersion());
    assertNotNull(fileHistory.toString());
    assertTrue(fileHistory.toString().contains("1234"));
    assertNotNull(fileHistory.getFileVersions());
    assertEquals(0, fileHistory.getFileVersions().size());
  }
View Full Code Here

    assertEquals(0, fileHistory.getFileVersions().size());
  }
 
  @Test(expected = IllegalArgumentException.class)
  public void testFileHistoryInitInvalid() {
    new PartialFileHistory(null);
  }
View Full Code Here

    new PartialFileHistory(null);
  }
 
  @Test(expected = IllegalArgumentException.class)
  public void testFileHistoryAddFileVersionInvalidNull() {
    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
    fileHistory.addFileVersion(null);
  }
View Full Code Here

TOP

Related Classes of org.syncany.database.PartialFileHistory

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.