mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Morning merge.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2851 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -165,11 +165,11 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
* Create the following:
|
||||
* <pre>
|
||||
* root
|
||||
* / | \
|
||||
* / | \
|
||||
* / | \
|
||||
* / | \
|
||||
* A <-> B X
|
||||
* / |
|
||||
* / |
|
||||
* / |
|
||||
* / |
|
||||
* A <-> B
|
||||
* |\ /|
|
||||
* | \ / |
|
||||
* | \/ |
|
||||
@@ -500,6 +500,17 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
txn.begin();
|
||||
}
|
||||
|
||||
public void testRestoreToMissingParent() throws Exception
|
||||
{
|
||||
nodeService.deleteNode(a);
|
||||
nodeService.deleteNode(b);
|
||||
commitAndBeginNewTransaction();
|
||||
|
||||
// attempt to restore b_ to a
|
||||
RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(b_, a, null, null);
|
||||
assertEquals("Incorrect report status", RestoreStatus.FAILURE_INVALID_PARENT, report.getStatus());
|
||||
}
|
||||
|
||||
public void testMassRestore() throws Exception
|
||||
{
|
||||
nodeService.deleteNode(a);
|
||||
|
@@ -21,8 +21,10 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -133,13 +135,34 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
|
||||
{
|
||||
report.setStatus(RestoreStatus.FAILURE_INVALID_PARENT);
|
||||
}
|
||||
else if (destinationNodeRef == null)
|
||||
{
|
||||
// get the original parent of the archived node
|
||||
ChildAssociationRef originalParentAssocRef = (ChildAssociationRef) nodeService.getProperty(
|
||||
archivedNodeRef,
|
||||
ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
|
||||
NodeRef originalParentNodeRef = originalParentAssocRef.getParentRef();
|
||||
if (EqualsHelper.nullSafeEquals(originalParentNodeRef, invalidNodeRef))
|
||||
{
|
||||
report.setStatus(RestoreStatus.FAILURE_INVALID_PARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
// some other invalid node was detected
|
||||
report.setStatus(RestoreStatus.FAILURE_OTHER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// some other invalid node was detected
|
||||
report.setStatus(RestoreStatus.FAILURE_OTHER);
|
||||
}
|
||||
}
|
||||
// TODO: Catch permission exceptions
|
||||
catch (AccessDeniedException e)
|
||||
{
|
||||
report.setCause(e);
|
||||
report.setStatus(RestoreStatus.FAILURE_PERMISSION);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
report.setCause(e);
|
||||
|
@@ -409,19 +409,24 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
// get the old parent
|
||||
Node oldParentNode = oldAssoc.getParent();
|
||||
|
||||
// Invoke policy behaviour
|
||||
invokeBeforeDeleteChildAssociation(oldAssocRef);
|
||||
invokeBeforeCreateChildAssociation(newParentRef, nodeToMoveRef, assocTypeQName, assocQName);
|
||||
invokeBeforeUpdateNode(oldParentNode.getNodeRef()); // old parent will be updated
|
||||
invokeBeforeUpdateNode(newParentRef); // new parent ditto
|
||||
boolean movingStore = !nodeToMoveRef.getStoreRef().equals(newParentRef.getStoreRef());
|
||||
|
||||
// If the node is moving stores, then drag the node hierarchy with it
|
||||
if (!nodeToMoveRef.getStoreRef().equals(newParentRef.getStoreRef()))
|
||||
// data needed for policy invocation
|
||||
QName nodeToMoveTypeQName = nodeToMove.getTypeQName();
|
||||
Set<QName> nodeToMoveAspects = nodeToMove.getAspects();
|
||||
|
||||
// Invoke policy behaviour
|
||||
if (movingStore)
|
||||
{
|
||||
Store newStore = newParentNode.getStore();
|
||||
moveNodeToStore(nodeToMove, newStore);
|
||||
// the node reference will have changed too
|
||||
nodeToMoveRef = nodeToMove.getNodeRef();
|
||||
invokeBeforeDeleteNode(nodeToMoveRef);
|
||||
invokeBeforeCreateNode(newParentRef, assocTypeQName, assocQName, nodeToMoveTypeQName);
|
||||
}
|
||||
else
|
||||
{
|
||||
invokeBeforeDeleteChildAssociation(oldAssocRef);
|
||||
invokeBeforeCreateChildAssociation(newParentRef, nodeToMoveRef, assocTypeQName, assocQName);
|
||||
invokeBeforeUpdateNode(oldParentNode.getNodeRef()); // old parent will be updated
|
||||
invokeBeforeUpdateNode(newParentRef); // new parent ditto
|
||||
}
|
||||
|
||||
// remove the child assoc from the old parent
|
||||
@@ -430,14 +435,32 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
// create a new assoc
|
||||
ChildAssoc newAssoc = nodeDaoService.newChildAssoc(newParentNode, nodeToMove, true, assocTypeQName, assocQName);
|
||||
|
||||
// If the node is moving stores, then drag the node hierarchy with it
|
||||
if (movingStore)
|
||||
{
|
||||
// do the move
|
||||
Store newStore = newParentNode.getStore();
|
||||
moveNodeToStore(nodeToMove, newStore);
|
||||
// the node reference will have changed too
|
||||
nodeToMoveRef = nodeToMove.getNodeRef();
|
||||
}
|
||||
|
||||
// check that no cyclic relationships have been created
|
||||
getPaths(nodeToMoveRef, false);
|
||||
|
||||
|
||||
// invoke policy behaviour
|
||||
invokeOnCreateChildAssociation(newAssoc.getChildAssocRef());
|
||||
invokeOnDeleteChildAssociation(oldAssoc.getChildAssocRef());
|
||||
invokeOnUpdateNode(oldParentNode.getNodeRef());
|
||||
invokeOnUpdateNode(newParentRef);
|
||||
if (movingStore)
|
||||
{
|
||||
invokeOnDeleteNode(oldAssocRef, nodeToMoveTypeQName, nodeToMoveAspects);
|
||||
invokeOnCreateNode(newAssoc.getChildAssocRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
invokeOnCreateChildAssociation(newAssoc.getChildAssocRef());
|
||||
invokeOnDeleteChildAssociation(oldAssoc.getChildAssocRef());
|
||||
invokeOnUpdateNode(oldParentNode.getNodeRef());
|
||||
invokeOnUpdateNode(newParentRef);
|
||||
}
|
||||
|
||||
// update the node status
|
||||
nodeDaoService.recordChangeId(nodeToMoveRef);
|
||||
@@ -1342,11 +1365,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
nodeToMove.setStore(store);
|
||||
NodeRef newNodeRef = nodeToMove.getNodeRef();
|
||||
|
||||
// update change statuses
|
||||
String txnId = AlfrescoTransactionSupport.getTransactionId();
|
||||
// update old status
|
||||
NodeStatus oldNodeStatus = nodeDaoService.getNodeStatus(oldNodeRef, true);
|
||||
oldNodeStatus.setNode(null);
|
||||
oldNodeStatus.setChangeTxnId(txnId);
|
||||
// create the new status
|
||||
NodeStatus newNodeStatus = nodeDaoService.getNodeStatus(newNodeRef, true);
|
||||
newNodeStatus.setNode(nodeToMove);
|
||||
newNodeStatus.setChangeTxnId(txnId);
|
||||
|
Reference in New Issue
Block a user