mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
A fix for some incorrect behaviors in AVMSyncService.flatten() brought
on by some incorrect cacheing and the lack of some necessary flushes. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3910 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1558,22 +1558,31 @@ public class AVMRepository
|
|||||||
/**
|
/**
|
||||||
* Remove name without leaving behind a deleted node. Dangerous
|
* Remove name without leaving behind a deleted node. Dangerous
|
||||||
* if used unwisely.
|
* if used unwisely.
|
||||||
* @param lDir The layered directory node.
|
* @param path The path to the layered directory.
|
||||||
* @param name The name of the child.
|
* @param name The name of the child.
|
||||||
*/
|
*/
|
||||||
public void flatten(AVMNodeDescriptor lDir, String name)
|
public void flatten(String path, String name)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(lDir.getId());
|
fLookupCount.set(1);
|
||||||
|
String [] pathParts = SplitPath(path);
|
||||||
|
AVMStore store = getAVMStoreByName(pathParts[0]);
|
||||||
|
if (store == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Store not found.");
|
||||||
|
}
|
||||||
|
Lookup lPath = store.lookup(-1, pathParts[1], true, false);
|
||||||
|
AVMNode node = lPath.getCurrentNode();
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
throw new AVMNotFoundException("Path not found.");
|
||||||
|
}
|
||||||
if (!(node instanceof LayeredDirectoryNode))
|
if (!(node instanceof LayeredDirectoryNode))
|
||||||
{
|
{
|
||||||
throw new AVMWrongTypeException("Not a Layered Directory.");
|
throw new AVMWrongTypeException("Not a Layered Directory.");
|
||||||
}
|
}
|
||||||
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
||||||
if (!dir.getIsNew())
|
|
||||||
{
|
|
||||||
throw new AVMException("Directory has not already been copied.");
|
|
||||||
}
|
|
||||||
dir.flatten(name);
|
dir.flatten(name);
|
||||||
|
AVMContext.fgInstance.fAVMNodeDAO.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -63,6 +63,37 @@ import org.alfresco.util.GUID;
|
|||||||
*/
|
*/
|
||||||
public class AVMServiceTest extends AVMServiceTestBase
|
public class AVMServiceTest extends AVMServiceTestBase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Test partial flatten.
|
||||||
|
*/
|
||||||
|
public void testPartialFlatten()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
setupBasicTree();
|
||||||
|
fService.createAVMStore("layer");
|
||||||
|
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||||
|
fService.getFileOutputStream("layer:/a/b/c/foo").close();
|
||||||
|
fService.createFile("layer:/a/b", "bing").close();
|
||||||
|
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||||
|
diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo",
|
||||||
|
-1, "main:/a/b/c/foo",
|
||||||
|
AVMDifference.NEWER));
|
||||||
|
fSyncService.update(diffs, false, false, false, false);
|
||||||
|
fSyncService.flatten("layer:/a", "main:/a");
|
||||||
|
AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b");
|
||||||
|
assertTrue(b.isLayeredDirectory());
|
||||||
|
AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c");
|
||||||
|
assertTrue(c.isPlainDirectory());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test getIndirection.
|
* Test getIndirection.
|
||||||
*/
|
*/
|
||||||
|
@@ -461,12 +461,10 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// Otherwise make a directory in the target parent, and recursiveCopy all the source
|
// Otherwise make a directory in the target parent, and recursiveCopy all the source
|
||||||
// children into it.
|
// children into it.
|
||||||
AVMNodeDescriptor newParentDesc = fAVMRepository.createDirectory(parent, name);
|
AVMNodeDescriptor newParentDesc = fAVMRepository.createDirectory(parent, name);
|
||||||
fgLogger.error(newParentDesc);
|
|
||||||
Map<String, AVMNodeDescriptor> children =
|
Map<String, AVMNodeDescriptor> children =
|
||||||
fAVMService.getDirectoryListing(toCopy, true);
|
fAVMService.getDirectoryListing(toCopy, true);
|
||||||
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
||||||
{
|
{
|
||||||
fgLogger.error(entry.getKey());
|
|
||||||
recursiveCopy(newParentDesc, entry.getKey(), entry.getValue());
|
recursiveCopy(newParentDesc, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -629,13 +627,13 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
throw new AVMWrongTypeException("Underlying is not a directory: " + underlying);
|
throw new AVMWrongTypeException("Underlying is not a directory: " + underlying);
|
||||||
}
|
}
|
||||||
Map<String, AVMNodeDescriptor> layerListing =
|
Map<String, AVMNodeDescriptor> layerListing =
|
||||||
fAVMService.getDirectoryListingDirect(layer, true);
|
fAVMService.getDirectoryListingDirect(-1, layer.getPath(), true);
|
||||||
// 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 true;
|
return true;
|
||||||
}
|
}
|
||||||
layer = fAVMService.forceCopy(layer.getPath());
|
// layer = fAVMService.forceCopy(layer.getPath());
|
||||||
// Grab the listing
|
// Grab the listing
|
||||||
Map<String, AVMNodeDescriptor> underListing =
|
Map<String, AVMNodeDescriptor> underListing =
|
||||||
fAVMService.getDirectoryListing(underlying, true);
|
fAVMService.getDirectoryListing(underlying, true);
|
||||||
@@ -644,7 +642,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
{
|
{
|
||||||
AVMNodeDescriptor topNode = layerListing.get(name);
|
AVMNodeDescriptor topNode = layerListing.get(name);
|
||||||
AVMNodeDescriptor bottomNode = underListing.get(name);
|
AVMNodeDescriptor bottomNode = underListing.get(name);
|
||||||
fgLogger.error("Trying to flatten out: " + name);
|
// fgLogger.error("Trying to flatten out: " + name);
|
||||||
if (bottomNode == null)
|
if (bottomNode == null)
|
||||||
{
|
{
|
||||||
flattened = false;
|
flattened = false;
|
||||||
@@ -653,16 +651,16 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// We've found an identity so flatten it.
|
// We've found an identity so flatten it.
|
||||||
if (topNode.getId() == bottomNode.getId())
|
if (topNode.getId() == bottomNode.getId())
|
||||||
{
|
{
|
||||||
fAVMRepository.flatten(layer, name);
|
fAVMRepository.flatten(layer.getPath(), name);
|
||||||
fgLogger.error("Identity flattened: " + name);
|
// fgLogger.error("Identity flattened: " + name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Otherwise recursively flatten the children.
|
// Otherwise recursively flatten the children.
|
||||||
if (flatten(topNode, bottomNode))
|
if (flatten(topNode, bottomNode))
|
||||||
{
|
{
|
||||||
fAVMRepository.flatten(layer, name);
|
fAVMRepository.flatten(layer.getPath(), name);
|
||||||
fgLogger.error("Recursively flattened: " + name);
|
// fgLogger.error("Recursively flattened: " + name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -710,6 +708,5 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
}
|
}
|
||||||
mkdirs(pathParts[0]);
|
mkdirs(pathParts[0]);
|
||||||
fAVMService.createDirectory(pathParts[0], pathParts[1]);
|
fAVMService.createDirectory(pathParts[0], pathParts[1]);
|
||||||
fgLogger.error("mkdir " + pathParts[0] + " " + pathParts[1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -115,14 +115,11 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
|
|||||||
// Get the difference between source and destination.
|
// Get the difference between source and destination.
|
||||||
List<AVMDifference> diffs =
|
List<AVMDifference> diffs =
|
||||||
fAVMSyncService.compare(version, path, -1, avmDest);
|
fAVMSyncService.compare(version, path, -1, avmDest);
|
||||||
for (AVMDifference diff : diffs)
|
|
||||||
{
|
|
||||||
fgLogger.error(diff);
|
|
||||||
}
|
|
||||||
// Do the update.
|
// Do the update.
|
||||||
fAVMSyncService.update(diffs, true, true, false, false);
|
fAVMSyncService.update(diffs, true, true, false, false);
|
||||||
// Cleanup by flattening the source relative to the destination.
|
// Cleanup by flattening the source relative to the destination.
|
||||||
//fAVMSyncService.flatten(storePath[0] + ":/appBase", websiteName + "-staging:/appBase");
|
AVMContext.fgInstance.fAVMNodeDAO.flush();
|
||||||
|
fAVMSyncService.flatten(storePath[0] + ":/appBase", websiteName + "-staging:/appBase");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -29,8 +29,6 @@ class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
|||||||
"from AVMNodePropertyImpl anp where anp.node = :node and anp.name = :name");
|
"from AVMNodePropertyImpl anp where anp.node = :node and anp.name = :name");
|
||||||
query.setEntity("node", node);
|
query.setEntity("node", node);
|
||||||
query.setParameter("name", name);
|
query.setParameter("name", name);
|
||||||
query.setCacheable(true);
|
|
||||||
query.setCacheRegion("Property.Lookup");
|
|
||||||
return (AVMNodeProperty)query.uniqueResult();
|
return (AVMNodeProperty)query.uniqueResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +44,6 @@ class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
|||||||
getSession().createQuery(
|
getSession().createQuery(
|
||||||
"from AVMNodePropertyImpl anp where anp.node = :node");
|
"from AVMNodePropertyImpl anp where anp.node = :node");
|
||||||
query.setEntity("node", node);
|
query.setEntity("node", node);
|
||||||
query.setCacheable(true);
|
|
||||||
query.setCacheRegion("Properties.Lookup");
|
|
||||||
return (List<AVMNodeProperty>)query.list();
|
return (List<AVMNodeProperty>)query.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,7 +62,6 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
"from ChildEntryImpl ce where ce.name = :name and ce.parent = :parent");
|
"from ChildEntryImpl ce where ce.name = :name and ce.parent = :parent");
|
||||||
query.setString("name", name);
|
query.setString("name", name);
|
||||||
query.setEntity("parent", parent);
|
query.setEntity("parent", parent);
|
||||||
query.setCacheable(true);
|
|
||||||
return (ChildEntry)query.uniqueResult();
|
return (ChildEntry)query.uniqueResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +75,6 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
{
|
{
|
||||||
Query query = getSession().getNamedQuery("ChildEntry.ByParent");
|
Query query = getSession().getNamedQuery("ChildEntry.ByParent");
|
||||||
query.setEntity("parent", parent);
|
query.setEntity("parent", parent);
|
||||||
query.setCacheable(true);
|
|
||||||
query.setCacheRegion("ChildEntry.ByParent");
|
|
||||||
return (List<ChildEntry>)query.list();
|
return (List<ChildEntry>)query.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +89,6 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
|||||||
Query query = getSession().getNamedQuery("ChildEntry.ByParentChild");
|
Query query = getSession().getNamedQuery("ChildEntry.ByParentChild");
|
||||||
query.setEntity("parent", parent);
|
query.setEntity("parent", parent);
|
||||||
query.setEntity("child", child);
|
query.setEntity("child", child);
|
||||||
query.setCacheable(true);
|
|
||||||
query.setCacheRegion("ChildEntry.ByParentChild");
|
|
||||||
return (ChildEntry)query.uniqueResult();
|
return (ChildEntry)query.uniqueResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user