File tmpFile = new File(tmpName);
tmpFile.mkdirs();
// synchronization memento
SynchronizationResponse res = getResponseObj(true, tmpName);
SynchronizationMemento m = new SynchronizationMemento(res);
// populate the dir
RandomDirTree tree = new RandomDirTree(tmpName);
tree.populate(true);
InventoryMgr iMgr = new InventoryMgr(tmpFile);
List inventory = iMgr.getInventory();
System.out.println("Number of files in directory [" +tmpName+ "]: "
+ inventory.size());
// saves a snapshot in memento
m.saveState();
// populates the new dir
RandomFileMover mover =
new RandomFileMover(getBackupFile(tmpFile),tmpFile,copyEnabled);
mover.move();
List moved = mover.getMoveList();
List copied = mover.getCopyList();
System.out.println("Number of files moved to directory ["
+ getBackupFile(tmpFile) + "]: " + moved.size());
System.out.println("Number of files copied to directory ["
+ getBackupFile(tmpFile) + "]: " + copied.size());
// merges the two trees
m.commit();
List newInventory = iMgr.getInventory();
System.out.println("Number of files in directory ["
+ tmpFile + "]: " + newInventory.size());