mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix up goofed up implicit snapshotting in update(). A test.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3813 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -59,6 +59,42 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test that non head version sources are update correctly.
|
||||
*/
|
||||
public void testVersionUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
fService.createAVMStore("source");
|
||||
fService.createAVMStore("dest");
|
||||
loader.recursiveLoad("config/alfresco/bootstrap", "source:/");
|
||||
int version1 = fService.createSnapshot("source");
|
||||
loader.recursiveLoad("config/alfresco/extension", "source:/");
|
||||
int version2 = fService.createSnapshot("source");
|
||||
List<AVMDifference> diffs =
|
||||
fSyncService.compare(version1, "source:/", -1, "dest:/");
|
||||
fService.createSnapshot("dest");
|
||||
assertEquals(1, diffs.size());
|
||||
fSyncService.update(diffs, false, false, false, false);
|
||||
diffs = fSyncService.compare(version1, "source:/", -1, "dest:/");
|
||||
assertEquals(0, diffs.size());
|
||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/");
|
||||
assertEquals(1, diffs.size());
|
||||
fSyncService.update(diffs, false, false, false, false);
|
||||
fService.createSnapshot("dest");
|
||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/");
|
||||
assertEquals(0, diffs.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an update forces a snapshot on the source.
|
||||
*/
|
||||
|
@@ -18,8 +18,11 @@
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
@@ -281,19 +284,33 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
public void update(List<AVMDifference> diffList, boolean ignoreConflicts, boolean ignoreOlder,
|
||||
boolean overrideConflicts, boolean overrideOlder)
|
||||
{
|
||||
Map<String, Integer> storeVersions = new HashMap<String, Integer>();
|
||||
for (AVMDifference diff : diffList)
|
||||
{
|
||||
if (!diff.isValid())
|
||||
{
|
||||
throw new AVMSyncException("Malformed AVMDifference.");
|
||||
}
|
||||
int colonOff = diff.getSourcePath().indexOf(':');
|
||||
if (colonOff == -1)
|
||||
// Snapshot the source if needed.
|
||||
int version = diff.getSourceVersion();
|
||||
if (version < 0)
|
||||
{
|
||||
throw new AVMBadArgumentException("Invalid path.");
|
||||
int colonOff = diff.getSourcePath().indexOf(':');
|
||||
if (colonOff == -1)
|
||||
{
|
||||
throw new AVMBadArgumentException("Invalid path.");
|
||||
}
|
||||
String storeName = diff.getSourcePath().substring(0, colonOff);
|
||||
if (storeVersions.containsKey(storeName))
|
||||
{
|
||||
// We've already snapshotted this store.
|
||||
version = storeVersions.get(storeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
version = fAVMService.createSnapshot(storeName);
|
||||
}
|
||||
}
|
||||
String storeName = diff.getSourcePath().substring(0, colonOff);
|
||||
int version = fAVMService.createSnapshot(storeName);
|
||||
AVMNodeDescriptor srcDesc = fAVMService.lookup(version,
|
||||
diff.getSourcePath(), true);
|
||||
if (srcDesc == null)
|
||||
|
Reference in New Issue
Block a user