|
|
@@ -3,11 +3,11 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
|
|
-import uk.ac.ic.wlgitbridge.writelatex.filestore.FileIndexStore;
|
|
|
+import uk.ac.ic.wlgitbridge.writelatex.filestore.store.FileIndexStore;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
|
|
-import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -16,40 +16,35 @@ import java.util.Map;
|
|
|
*/
|
|
|
public class WLDirectoryNode {
|
|
|
|
|
|
- private Map<String, FileNode> files;
|
|
|
- private FileIndexStore fileIndexes;
|
|
|
- private final String rootGitDirectoryPath;
|
|
|
+ private Map<String, FileNode> fileNodeTable;
|
|
|
+ private FileIndexStore fileIndexStore;
|
|
|
|
|
|
- public WLDirectoryNode(String rootGitDirectoryPath, String projectName) {
|
|
|
- this.rootGitDirectoryPath = rootGitDirectoryPath;
|
|
|
- files = new HashMap<String, FileNode>();
|
|
|
- fileIndexes = new FileIndexStore();
|
|
|
+ public WLDirectoryNode() {
|
|
|
+ fileNodeTable = new HashMap<String, FileNode>();
|
|
|
+ fileIndexStore = new FileIndexStore();
|
|
|
}
|
|
|
|
|
|
- public void updateFromSnapshot(Snapshot snapshot) throws FailedConnectionException {
|
|
|
- Map<String, FileNode> updatedFiles = new HashMap<String, FileNode>();
|
|
|
+ public List<FileNode> updateFromSnapshot(Snapshot snapshot) throws FailedConnectionException {
|
|
|
+ Map<String, FileNode> updatedFileNodeTable = new HashMap<String, FileNode>();
|
|
|
List<SnapshotFile> srcs = snapshot.getSrcs();
|
|
|
List<SnapshotAttachment> atts = snapshot.getAtts();
|
|
|
for (SnapshotFile src : srcs) {
|
|
|
- BlobNode blobNode = new BlobNode(src, files);
|
|
|
- updatedFiles.put(blobNode.getFilePath(), blobNode);
|
|
|
+ BlobNode blobNode = new BlobNode(src, fileNodeTable);
|
|
|
+ updatedFileNodeTable.put(blobNode.getFilePath(), blobNode);
|
|
|
}
|
|
|
for (SnapshotAttachment att : atts) {
|
|
|
- AttachmentNode attachmentNode = new AttachmentNode(att, files, fileIndexes);
|
|
|
- updatedFiles.put(attachmentNode.getFilePath(), attachmentNode);
|
|
|
+ AttachmentNode attachmentNode = new AttachmentNode(att, fileNodeTable, fileIndexStore);
|
|
|
+ updatedFileNodeTable.put(attachmentNode.getFilePath(), attachmentNode);
|
|
|
}
|
|
|
- files = updatedFiles;
|
|
|
- try {
|
|
|
- throw new Throwable();
|
|
|
- } catch (Throwable t) {
|
|
|
- t.printStackTrace();
|
|
|
- }
|
|
|
- System.out.println(this);
|
|
|
+ fileNodeTable = updatedFileNodeTable;
|
|
|
+ LinkedList<FileNode> fileNodes = new LinkedList<FileNode>(updatedFileNodeTable.values());
|
|
|
+ fileIndexStore = new FileIndexStore(fileNodes);
|
|
|
+ return fileNodes;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return files.toString();
|
|
|
+ return fileNodeTable.toString();
|
|
|
}
|
|
|
|
|
|
}
|