Exemple #1
0
  private void updateFullDatabaseVersionCache(DatabaseVersion newDatabaseVersion) {
    // Chunks
    for (ChunkEntry sourceChunk : newDatabaseVersion.getChunks()) {
      if (fullDatabaseVersionCache.getChunk(sourceChunk.getChecksum()) == null) {
        fullDatabaseVersionCache.addChunk(sourceChunk);
      }
    }

    // Multichunks
    for (MultiChunkEntry sourceMultiChunk : newDatabaseVersion.getMultiChunks()) {
      if (fullDatabaseVersionCache.getMultiChunk(sourceMultiChunk.getId()) == null) {
        fullDatabaseVersionCache.addMultiChunk(sourceMultiChunk);
      }
    }

    // Contents
    for (FileContent sourceFileContent : newDatabaseVersion.getFileContents()) {
      if (fullDatabaseVersionCache.getFileContent(sourceFileContent.getChecksum()) == null) {
        fullDatabaseVersionCache.addFileContent(sourceFileContent);
      }
    }

    // Histories
    for (PartialFileHistory sourceFileHistory : newDatabaseVersion.getFileHistories()) {
      PartialFileHistory targetFileHistory =
          fullDatabaseVersionCache.getFileHistory(sourceFileHistory.getFileId());

      if (targetFileHistory == null) {
        fullDatabaseVersionCache.addFileHistory((PartialFileHistory) sourceFileHistory.clone());
      } else {
        for (FileVersion sourceFileVersion : sourceFileHistory.getFileVersions().values()) {
          if (targetFileHistory.getFileVersion(sourceFileVersion.getVersion()) == null) {
            targetFileHistory.addFileVersion(sourceFileVersion);
          }
        }
      }
    }
  }
Exemple #2
0
 public FileContent getContent(FileChecksum checksum) {
   return (checksum != null) ? fullDatabaseVersionCache.getFileContent(checksum) : null;
 }