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);
|
||||
|
Reference in New Issue
Block a user