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
|
||||
* if used unwisely.
|
||||
* @param lDir The layered directory node.
|
||||
* @param path The path to the layered directory.
|
||||
* @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))
|
||||
{
|
||||
throw new AVMWrongTypeException("Not a Layered Directory.");
|
||||
}
|
||||
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
||||
if (!dir.getIsNew())
|
||||
{
|
||||
throw new AVMException("Directory has not already been copied.");
|
||||
}
|
||||
dir.flatten(name);
|
||||
AVMContext.fgInstance.fAVMNodeDAO.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -63,6 +63,37 @@ import org.alfresco.util.GUID;
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@@ -461,12 +461,10 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
// Otherwise make a directory in the target parent, and recursiveCopy all the source
|
||||
// children into it.
|
||||
AVMNodeDescriptor newParentDesc = fAVMRepository.createDirectory(parent, name);
|
||||
fgLogger.error(newParentDesc);
|
||||
Map<String, AVMNodeDescriptor> children =
|
||||
fAVMService.getDirectoryListing(toCopy, true);
|
||||
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
||||
{
|
||||
fgLogger.error(entry.getKey());
|
||||
recursiveCopy(newParentDesc, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -629,13 +627,13 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
throw new AVMWrongTypeException("Underlying is not a directory: " + underlying);
|
||||
}
|
||||
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 (layerListing.size() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
layer = fAVMService.forceCopy(layer.getPath());
|
||||
// layer = fAVMService.forceCopy(layer.getPath());
|
||||
// Grab the listing
|
||||
Map<String, AVMNodeDescriptor> underListing =
|
||||
fAVMService.getDirectoryListing(underlying, true);
|
||||
@@ -644,7 +642,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
{
|
||||
AVMNodeDescriptor topNode = layerListing.get(name);
|
||||
AVMNodeDescriptor bottomNode = underListing.get(name);
|
||||
fgLogger.error("Trying to flatten out: " + name);
|
||||
// fgLogger.error("Trying to flatten out: " + name);
|
||||
if (bottomNode == null)
|
||||
{
|
||||
flattened = false;
|
||||
@@ -653,16 +651,16 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
// We've found an identity so flatten it.
|
||||
if (topNode.getId() == bottomNode.getId())
|
||||
{
|
||||
fAVMRepository.flatten(layer, name);
|
||||
fgLogger.error("Identity flattened: " + name);
|
||||
fAVMRepository.flatten(layer.getPath(), name);
|
||||
// fgLogger.error("Identity flattened: " + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise recursively flatten the children.
|
||||
if (flatten(topNode, bottomNode))
|
||||
{
|
||||
fAVMRepository.flatten(layer, name);
|
||||
fgLogger.error("Recursively flattened: " + name);
|
||||
fAVMRepository.flatten(layer.getPath(), name);
|
||||
// fgLogger.error("Recursively flattened: " + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -710,6 +708,5 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
}
|
||||
mkdirs(pathParts[0]);
|
||||
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.
|
||||
List<AVMDifference> diffs =
|
||||
fAVMSyncService.compare(version, path, -1, avmDest);
|
||||
for (AVMDifference diff : diffs)
|
||||
{
|
||||
fgLogger.error(diff);
|
||||
}
|
||||
// Do the update.
|
||||
fAVMSyncService.update(diffs, true, true, false, false);
|
||||
// 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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -137,7 +137,7 @@
|
||||
</many-to-one>
|
||||
</class>
|
||||
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries" optimistic-lock="version">
|
||||
<cache usage="read-write"/>
|
||||
<cache usage="read-write"/>
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
|
@@ -29,8 +29,6 @@ class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
||||
"from AVMNodePropertyImpl anp where anp.node = :node and anp.name = :name");
|
||||
query.setEntity("node", node);
|
||||
query.setParameter("name", name);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("Property.Lookup");
|
||||
return (AVMNodeProperty)query.uniqueResult();
|
||||
}
|
||||
|
||||
@@ -46,8 +44,6 @@ class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
||||
getSession().createQuery(
|
||||
"from AVMNodePropertyImpl anp where anp.node = :node");
|
||||
query.setEntity("node", node);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("Properties.Lookup");
|
||||
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");
|
||||
query.setString("name", name);
|
||||
query.setEntity("parent", parent);
|
||||
query.setCacheable(true);
|
||||
return (ChildEntry)query.uniqueResult();
|
||||
}
|
||||
|
||||
@@ -76,8 +75,6 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
{
|
||||
Query query = getSession().getNamedQuery("ChildEntry.ByParent");
|
||||
query.setEntity("parent", parent);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("ChildEntry.ByParent");
|
||||
return (List<ChildEntry>)query.list();
|
||||
}
|
||||
|
||||
@@ -92,8 +89,6 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
Query query = getSession().getNamedQuery("ChildEntry.ByParentChild");
|
||||
query.setEntity("parent", parent);
|
||||
query.setEntity("child", child);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("ChildEntry.ByParentChild");
|
||||
return (ChildEntry)query.uniqueResult();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user