Merged v3.0 to HEAD

12725: *RECORD ONLY* remove errant comma
   12740: Merged V2.2 to V3.0
      12577: Fix ETWOTWO-973 - Enable Logging of Leaked Transactions By Default.
      12582: *RECORD-ONLY* Fix ETWOTWO-872 - openoffice bootstrap config in WAR bundle.
      12628: *RECORD-ONLY* Fix for ETWOTWO-937: Regression Multi-Valued properties - nullpointerexception if only one value is set initially
   12741: Merged V2.2 to V3.0
      12643: Fixed ETWOTWO-354: null properties created on copy-pasted nodes
      12694: Added NodeService.addProperties() method
      12695: Follow-up fix for  ETWOTWO-354: null properties created on copy-pasted nodes
      12715: Fix ETWOTWO-988: Gather Oracle schema stats before, during and after upgrade
      12730: IndexInfo.main processes multiple directory arguments
      12737: Fixed ETWOTWO-246, ETHREEOH-996 (by merge) and ALFCOM-2299: Cancel discussion orphans nodes
   12745: Merged V2.2 to V3.0
      12744: Fixed ETWOTWO-1011 and (by merge) ALFCOM-2372: Upgrade from 2.1C fails

   svn diff -N .
      Merged /alfresco/BRANCHES/V3.0:r12725,12740-12741,12745
      Merged /alfresco/BRANCHES/V2.2:r12577,12582,12628,12643,12694-12695,12715,12730,12737,12744


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12748 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-01-14 17:32:34 +00:00
parent b7ef06d97c
commit fd15f44b54
12 changed files with 259 additions and 26 deletions

View File

@@ -627,6 +627,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// Remove child associations
// We have to iterate over the associations and remove all those between the parent and child
final List<Pair<Long, ChildAssociationRef>> assocsToDelete = new ArrayList<Pair<Long, ChildAssociationRef>>(5);
final List<Pair<Long, NodeRef>> nodesToDelete = new ArrayList<Pair<Long, NodeRef>>(5);
NodeDaoService.ChildAssocRefQueryCallback callback = new NodeDaoService.ChildAssocRefQueryCallback()
{
public boolean handle(
@@ -635,8 +636,16 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Pair<Long, NodeRef> childNodePair
)
{
// Add it
assocsToDelete.add(childAssocPair);
// Double check that it's not a primary association. If so, we can't delete it and
// have to delete the child node directly and with full archival.
if (childAssocPair.getSecond().isPrimary())
{
nodesToDelete.add(childNodePair);
}
else
{
assocsToDelete.add(childAssocPair);
}
// No recurse
return false;
}
@@ -656,6 +665,13 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
invokeOnDeleteChildAssociation(assocRef);
}
// Cascade-delete any nodes that were attached to primary associations
for (Pair<Long, NodeRef> childNodePair : nodesToDelete)
{
NodeRef childNodeRef = childNodePair.getSecond();
this.deleteNode(childNodeRef);
}
// Remove regular associations
Map<QName, AssociationDefinition> nodeAssocDefs = aspectDef.getAssociations();
Collection<Pair<Long, AssociationRef>> nodeAssocPairs = nodeDaoService.getNodeAssocsToAndFrom(nodeId);
@@ -910,26 +926,44 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Long childNodeId = getNodePairNotNull(childAssocRef.getChildRef()).getFirst();
QName assocTypeQName = childAssocRef.getTypeQName();
QName assocQName = childAssocRef.getQName();
// Delete the association
invokeBeforeDeleteChildAssociation(childAssocRef);
boolean deleted = nodeDaoService.deleteChildAssoc(parentNodeId, childNodeId, assocTypeQName, assocQName);
if (deleted)
Pair<Long, ChildAssociationRef> assocPair = nodeDaoService.getChildAssoc(
parentNodeId, childNodeId, assocTypeQName, assocQName);
if (assocPair == null)
{
invokeOnDeleteChildAssociation(childAssocRef);
// No association exists
return false;
}
Long assocId = assocPair.getFirst();
ChildAssociationRef assocRef = assocPair.getSecond();
if (assocRef.isPrimary())
{
NodeRef childNodeRef = assocRef.getChildRef();
// Delete the child node
this.deleteNode(childNodeRef);
// Done
return true;
}
else
{
// Delete the association
invokeBeforeDeleteChildAssociation(childAssocRef);
nodeDaoService.deleteChildAssoc(assocId);
invokeOnDeleteChildAssociation(childAssocRef);
// Index
nodeIndexer.indexDeleteChildAssociation(childAssocRef);
// Done
return true;
}
// Index
nodeIndexer.indexDeleteChildAssociation(childAssocRef);
// Done
return deleted;
}
public boolean removeSeconaryChildAssociation(ChildAssociationRef childAssocRef)
{
Long parentNodeId = getNodePairNotNull(childAssocRef.getParentRef()).getFirst();
Long childNodeId = getNodePairNotNull(childAssocRef.getChildRef()).getFirst();
QName typeQName = childAssocRef.getTypeQName();
QName qname = childAssocRef.getQName();
Pair<Long, ChildAssociationRef> assocPair = nodeDaoService.getChildAssoc(parentNodeId, childNodeId, typeQName, qname);
QName assocTypeQName = childAssocRef.getTypeQName();
QName assocQName = childAssocRef.getQName();
Pair<Long, ChildAssociationRef> assocPair = nodeDaoService.getChildAssoc(
parentNodeId, childNodeId, assocTypeQName, assocQName);
if (assocPair == null)
{
// No association exists
@@ -1150,6 +1184,34 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
nodeIndexer.indexUpdateNode(nodeRef);
}
public void addProperties(NodeRef nodeRef, Map<QName, Serializable> properties) throws InvalidNodeRefException
{
Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
Long nodeId = nodePair.getFirst();
extractIntrinsicProperties(properties);
// Invoke policy behaviours
Map<QName, Serializable> propertiesBefore = getPropertiesImpl(nodePair);
invokeBeforeUpdateNode(nodeRef);
// Change each property
for (Map.Entry<QName, Serializable> entry : properties.entrySet())
{
QName propertyQName = entry.getKey();
Serializable propertyValue = entry.getValue();
setPropertyImpl(nodeId, propertyQName, propertyValue);
}
// Invoke policy behaviours
Map<QName, Serializable> propertiesAfter = getPropertiesImpl(nodePair);
invokeOnUpdateNode(nodeRef);
invokeOnUpdateProperties(nodeRef, propertiesBefore, propertiesAfter);
// Index
nodeIndexer.indexUpdateNode(nodeRef);
}
private void setPropertiesImpl(Long nodeId, Map<QName, Serializable> properties)
{
// Get the cm:name and uuid for special handling