mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
A tweak to createSnapshot that forces snapshots for stores which
have layered nodes in them. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5587 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -83,6 +83,29 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
public void testLayerSnapshots()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
assertEquals(1, fService.createSnapshot("main", null, null));
|
||||
fService.createStore("layer");
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
fService.createSnapshot("layer", null, null);
|
||||
fService.createFile("main:/a", "Xander");
|
||||
fService.createSnapshot("layer", null, null);
|
||||
assertEquals(2, fService.lookup(2, "layer:/a").getIndirectionVersion());
|
||||
assertEquals(fService.lookup(2, "main:/a/Xander").getId(),
|
||||
fService.lookup(2, "layer:/a/Xander").getId());
|
||||
assertNull(fService.lookup(1, "layer:/a/Xander"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
public void testBranchLayerSnapshot()
|
||||
{
|
||||
try
|
||||
|
@@ -179,25 +179,23 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
@SuppressWarnings("unchecked")
|
||||
public int createSnapshot(String tag, String description, Map<String, Integer> snapShotMap)
|
||||
{
|
||||
// If the root isn't new, we can't take a snapshot since nothing has changed.
|
||||
if (!fRoot.getIsNew())
|
||||
{
|
||||
// So, we set the tag and description fields of the latest version.
|
||||
VersionRoot versionRoot = AVMDAOs.Instance().fVersionRootDAO.getMaxVersion(this);
|
||||
if (tag != null || description != null)
|
||||
{
|
||||
versionRoot.setTag(tag);
|
||||
versionRoot.setDescription(description);
|
||||
}
|
||||
snapShotMap.put(fName, versionRoot.getVersionID());
|
||||
return versionRoot.getVersionID();
|
||||
}
|
||||
snapShotMap.put(fName, fNextVersionID);
|
||||
// Get all the layered nodes that were snapshotted last time
|
||||
// and force copies on them.
|
||||
VersionRoot lastVersion = AVMDAOs.Instance().fVersionRootDAO.getMaxVersion(this);
|
||||
List<VersionLayeredNodeEntry> layeredEntries =
|
||||
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.get(lastVersion);
|
||||
// Is there no need for a snapshot?
|
||||
if (!fRoot.getIsNew() && layeredEntries.size() == 0)
|
||||
{
|
||||
// So, we set the tag and description fields of the latest version.
|
||||
if (tag != null || description != null)
|
||||
{
|
||||
lastVersion.setTag(tag);
|
||||
lastVersion.setDescription(description);
|
||||
}
|
||||
snapShotMap.put(fName, lastVersion.getVersionID());
|
||||
return lastVersion.getVersionID();
|
||||
}
|
||||
snapShotMap.put(fName, fNextVersionID);
|
||||
// Force copies on all the layered nodes from last snapshot.
|
||||
for (VersionLayeredNodeEntry entry : layeredEntries)
|
||||
{
|
||||
String path = entry.getPath();
|
||||
|
Reference in New Issue
Block a user