mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
This in theory makes AVMSyncService feature complete, by added flatten, which
essentially resets a users layer to be as much like the target tree as possible to keep comparisons fast. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3797 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -58,6 +58,43 @@ import org.alfresco.service.transaction.TransactionService;
|
|||||||
*/
|
*/
|
||||||
public class AVMServiceTest extends AVMServiceTestBase
|
public class AVMServiceTest extends AVMServiceTestBase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Test the flatten operation, with a little bit of compare and update.
|
||||||
|
*/
|
||||||
|
public void testFlatten()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
setupBasicTree();
|
||||||
|
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||||
|
fService.createSnapshot("main");
|
||||||
|
System.out.println(recursiveList("main", -1, true));
|
||||||
|
// Change some stuff.
|
||||||
|
fService.createFile("main:/layer/b", "fig").close();
|
||||||
|
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||||
|
fService.createSnapshot("main");
|
||||||
|
System.out.println(recursiveList("main", -1, true));
|
||||||
|
// Do a compare.
|
||||||
|
List<AVMDifference> diffs =
|
||||||
|
fSyncService.compare(-1, "main:/layer", -1, "main:/a");
|
||||||
|
for (AVMDifference diff : diffs)
|
||||||
|
{
|
||||||
|
System.out.println(diff);
|
||||||
|
}
|
||||||
|
// Update.
|
||||||
|
fSyncService.update(diffs, false, false, false, false);
|
||||||
|
System.out.println(recursiveList("main", -1, true));
|
||||||
|
// Flatten.
|
||||||
|
fSyncService.flatten("main:/layer", "main:/a");
|
||||||
|
System.out.println(recursiveList("main", -1, true));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of Descriptor indirection field.
|
* Test of Descriptor indirection field.
|
||||||
*/
|
*/
|
||||||
|
@@ -508,16 +508,16 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
* @param layer The on top node.
|
* @param layer The on top node.
|
||||||
* @param underlying The underlying node.
|
* @param underlying The underlying node.
|
||||||
*/
|
*/
|
||||||
private void flatten(AVMNodeDescriptor layer, AVMNodeDescriptor underlying)
|
private boolean flatten(AVMNodeDescriptor layer, AVMNodeDescriptor underlying)
|
||||||
{
|
{
|
||||||
if (!layer.isLayeredDirectory())
|
if (!layer.isLayeredDirectory())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
// layer and underlying must match for flattening to be useful.
|
// layer and underlying must match for flattening to be useful.
|
||||||
if (!layer.getIndirection().equals(underlying.getPath()))
|
if (!layer.getIndirection().equals(underlying.getPath()))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
// The underlying thing must be a directory.
|
// The underlying thing must be a directory.
|
||||||
if (!underlying.isDirectory())
|
if (!underlying.isDirectory())
|
||||||
@@ -529,11 +529,12 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// If the layer is empty (directly, that is) we're done.
|
// If the layer is empty (directly, that is) we're done.
|
||||||
if (layerListing.size() == 0)
|
if (layerListing.size() == 0)
|
||||||
{
|
{
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
// Grab the listing
|
// Grab the listing
|
||||||
Map<String, AVMNodeDescriptor> underListing =
|
Map<String, AVMNodeDescriptor> underListing =
|
||||||
fAVMService.getDirectoryListing(-1, underlying.getPath(), true);
|
fAVMService.getDirectoryListing(-1, underlying.getPath(), true);
|
||||||
|
boolean flattened = true;
|
||||||
for (String name : layerListing.keySet())
|
for (String name : layerListing.keySet())
|
||||||
{
|
{
|
||||||
AVMNodeDescriptor topNode = layerListing.get(name);
|
AVMNodeDescriptor topNode = layerListing.get(name);
|
||||||
@@ -551,9 +552,18 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Otherwise recursively flatten the children.
|
// Otherwise recursively flatten the children.
|
||||||
flatten(topNode, bottomNode);
|
if (flatten(topNode, bottomNode))
|
||||||
|
{
|
||||||
|
fAVMService.removeNode(layer.getPath(), name);
|
||||||
|
fAVMService.uncover(layer.getPath(), name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flattened = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return flattened;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user