mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/V3.2 to HEAD:
18564: Fixed ETHREEOH-4031: ParentAssocsCache gets out of date when parent NodeRefs are modified 18569: Fix ETHREEOH-3632: UI - View versioned properties fails when node associations are present 18579: Fix failing unit test after CHK-11190 18580: Fixed parentAssocsCache invalidation for parent NodeRef modification 18597: Fixed ETHREEOH-3996 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19214 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1165,7 +1165,6 @@ public class HibernateNodeDaoServiceImpl
|
|||||||
// Update the node
|
// Update the node
|
||||||
updateNode(nodeId, storeRef, null, null);
|
updateNode(nodeId, storeRef, null, null);
|
||||||
NodeRef nodeRef = node.getNodeRef();
|
NodeRef nodeRef = node.getNodeRef();
|
||||||
this.parentAssocsCache.remove(nodeId);
|
|
||||||
|
|
||||||
return new Pair<Long, NodeRef>(node.getId(), nodeRef);
|
return new Pair<Long, NodeRef>(node.getId(), nodeRef);
|
||||||
}
|
}
|
||||||
@@ -1297,6 +1296,9 @@ public class HibernateNodeDaoServiceImpl
|
|||||||
DirtySessionMethodInterceptor.flushSession(getSession(), true);
|
DirtySessionMethodInterceptor.flushSession(getSession(), true);
|
||||||
// The cache entry will be overwritten so we don't need to do it here
|
// The cache entry will be overwritten so we don't need to do it here
|
||||||
}
|
}
|
||||||
|
// ETHREEOH-4031: ParentAssocsCache gets out of date when parent NodeRefs are modified
|
||||||
|
parentAssocsCache.remove(nodeId);
|
||||||
|
removeParentAssocCacheEntriesForParent(nodeId);
|
||||||
|
|
||||||
// Change the store
|
// Change the store
|
||||||
node.setStore(storeAfter);
|
node.setStore(storeAfter);
|
||||||
@@ -1785,6 +1787,48 @@ public class HibernateNodeDaoServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that parent association entries are removed for all children of a given node
|
||||||
|
*/
|
||||||
|
private void removeParentAssocCacheEntriesForParent(final Long parentNodeId)
|
||||||
|
{
|
||||||
|
HibernateCallback getChildNodeIdsCallback = new HibernateCallback()
|
||||||
|
{
|
||||||
|
public Object doInHibernate(Session session)
|
||||||
|
{
|
||||||
|
Query query = session
|
||||||
|
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_NODE_IDS)
|
||||||
|
.setLong("parentId", parentNodeId);
|
||||||
|
DirtySessionMethodInterceptor.setQueryFlushMode(session, query);
|
||||||
|
return query.scroll(ScrollMode.FORWARD_ONLY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ScrollableResults results = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
results = (ScrollableResults) getHibernateTemplate().execute(getChildNodeIdsCallback);
|
||||||
|
|
||||||
|
while (results.next())
|
||||||
|
{
|
||||||
|
Long childNodeId = results.getLong(0);
|
||||||
|
parentAssocsCache.remove(childNodeId);
|
||||||
|
if (isDebugParentAssocCacheEnabled)
|
||||||
|
{
|
||||||
|
loggerParentAssocsCache.debug(
|
||||||
|
"Parent associations cache - Removing entry: \n" +
|
||||||
|
" Node: " + childNodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if(results != null)
|
||||||
|
{
|
||||||
|
results.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final String QUERY_DELETE_PARENT_ASSOCS = "node.DeleteParentAssocs";
|
private static final String QUERY_DELETE_PARENT_ASSOCS = "node.DeleteParentAssocs";
|
||||||
private static final String QUERY_DELETE_CHILD_ASSOCS = "node.DeleteChildAssocs";
|
private static final String QUERY_DELETE_CHILD_ASSOCS = "node.DeleteChildAssocs";
|
||||||
private static final String QUERY_DELETE_NODE_ASSOCS = "node.DeleteNodeAssocs";
|
private static final String QUERY_DELETE_NODE_ASSOCS = "node.DeleteNodeAssocs";
|
||||||
@@ -1808,39 +1852,9 @@ public class HibernateNodeDaoServiceImpl
|
|||||||
{
|
{
|
||||||
logger.debug("Deleting child assocs of node " + nodeId);
|
logger.debug("Deleting child assocs of node " + nodeId);
|
||||||
}
|
}
|
||||||
HibernateCallback getChildNodeIdsCallback = new HibernateCallback()
|
// Make sure that the cache is updated
|
||||||
{
|
removeParentAssocCacheEntriesForParent(nodeId);
|
||||||
public Object doInHibernate(Session session)
|
|
||||||
{
|
|
||||||
Query query = session
|
|
||||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_NODE_IDS)
|
|
||||||
.setLong("parentId", nodeId);
|
|
||||||
DirtySessionMethodInterceptor.setQueryFlushMode(session, query);
|
|
||||||
return query.scroll(ScrollMode.FORWARD_ONLY);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ScrollableResults childNodeIds = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
childNodeIds = (ScrollableResults) getHibernateTemplate().execute(getChildNodeIdsCallback);
|
|
||||||
|
|
||||||
while (childNodeIds.next())
|
|
||||||
{
|
|
||||||
Long childNodeId = childNodeIds.getLong(0);
|
|
||||||
parentAssocsCache.remove(childNodeId);
|
|
||||||
if (isDebugParentAssocCacheEnabled)
|
|
||||||
{
|
|
||||||
loggerParentAssocsCache.debug("\n" + "Parent associations cache - Removing entry: \n" + " Node: " + childNodeId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if(childNodeIds != null)
|
|
||||||
{
|
|
||||||
childNodeIds.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HibernateCallback deleteParentAssocsCallback = new HibernateCallback()
|
HibernateCallback deleteParentAssocsCallback = new HibernateCallback()
|
||||||
{
|
{
|
||||||
public Object doInHibernate(Session session)
|
public Object doInHibernate(Session session)
|
||||||
|
@@ -188,7 +188,7 @@ public class Node2ServiceImpl extends NodeServiceImpl implements NodeService, Ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws UnsupportedOperationException always
|
* @return an empty list - ALWAYS.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
|
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
|
||||||
@@ -197,8 +197,7 @@ public class Node2ServiceImpl extends NodeServiceImpl implements NodeService, Ve
|
|||||||
{
|
{
|
||||||
return super.getTargetAssocs(sourceRef, qnamePattern);
|
return super.getTargetAssocs(sourceRef, qnamePattern);
|
||||||
}
|
}
|
||||||
|
// TODO: Persist these so they are retrievable
|
||||||
// This operation is not supported for a version2 store
|
return Collections.emptyList();
|
||||||
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -235,20 +235,11 @@ public class NodeServiceImplTest extends BaseVersionStoreTest
|
|||||||
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
|
if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID))
|
||||||
{
|
{
|
||||||
// V2 version store (eg. workspace://version2Store)
|
// V2 version store (eg. workspace://version2Store)
|
||||||
try
|
// See ETHREEOH-3632: method now doesn't blow up.
|
||||||
{
|
List<AssociationRef> assocs = this.lightWeightVersionStoreNodeService.getTargetAssocs(
|
||||||
this.lightWeightVersionStoreNodeService.getTargetAssocs(
|
dummyNodeRef,
|
||||||
dummyNodeRef,
|
RegexQNamePattern.MATCH_ALL);
|
||||||
RegexQNamePattern.MATCH_ALL);
|
assertEquals("Currently the assocs will be empty", 0, assocs.size());
|
||||||
fail("This operation is not supported.");
|
|
||||||
}
|
|
||||||
catch (UnsupportedOperationException exception)
|
|
||||||
{
|
|
||||||
if (exception.getMessage() != MSG_ERR)
|
|
||||||
{
|
|
||||||
fail("Unexpected exception raised during method excution: " + exception.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
|
else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user