Update can now handle source paths with incomplete corresponding destination paths.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3887 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-22 14:42:26 +00:00
parent eb4a1429b9
commit 37edacd63c
2 changed files with 50 additions and 1 deletions

View File

@@ -31,7 +31,6 @@ import java.util.Set;
import java.util.TreeMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ActionImpl;
import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction;
import org.alfresco.repo.avm.util.BulkLoader;
import org.alfresco.repo.domain.PropertyValue;
@@ -61,6 +60,34 @@ import org.alfresco.service.transaction.TransactionService;
*/
public class AVMServiceTest extends AVMServiceTestBase
{
/**
* Test a noodle update.
*/
public void testNoodleUpdate()
{
try
{
setupBasicTree();
fService.createAVMStore("staging");
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "staging:/");
assertEquals(2, diffs.size());
List<AVMDifference> noodle = new ArrayList<AVMDifference>();
noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo",
AVMDifference.NEWER));
noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d",
AVMDifference.NEWER));
fSyncService.update(noodle, false, false, false, false);
diffs = fSyncService.compare(-1, "main:/", -1, "staging:/");
assertEquals(1, diffs.size());
assertEquals("main:/a/b/c/bar", diffs.get(0).getSourcePath());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test the SimpleAVMSubmitAction.
*/

View File

@@ -401,6 +401,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
*/
private void linkIn(String parentPath, String name, AVMNodeDescriptor toLink, boolean removeFirst)
{
mkdirs(parentPath);
if (removeFirst)
{
fAVMService.removeNode(parentPath, name);
@@ -674,4 +675,25 @@ public class AVMSyncServiceImpl implements AVMSyncService
fAVMService.removeNode(parts[0], parts[1]);
fAVMService.createLayeredDirectory(desc.getIndirection(), parts[0], parts[1]);
}
/**
* Make sure this entire directory path exists.
* @param path
*/
private void mkdirs(String path)
{
if (fAVMService.lookup(-1, path) != null)
{
return;
}
String [] pathParts = AVMNodeConverter.SplitBase(path);
if (pathParts[0] == null)
{
// This is a root path and as such has to exist.
// Something else is going on.
throw new AVMSyncException("No corresponding destination path: " + path);
}
mkdirs(pathParts[0]);
fAVMService.createDirectory(pathParts[0], pathParts[1]);
}
}