mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added primary path to the properties archived against a node.
Fixed bug in caching of ChildAssociationRef in the ChildAssoc object git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2797 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -77,13 +77,24 @@ public class ChildAssocImpl implements ChildAssoc
|
||||
|
||||
public ChildAssociationRef getChildAssocRef()
|
||||
{
|
||||
boolean trashReference = false;
|
||||
// first check if it is available
|
||||
refReadLock.lock();
|
||||
try
|
||||
{
|
||||
if (childAssocRef != null)
|
||||
{
|
||||
return childAssocRef;
|
||||
// double check that the parent and child node references match those of our reference
|
||||
if (childAssocRef.getParentRef() != parent.getNodeRef() ||
|
||||
childAssocRef.getChildRef() != child.getNodeRef())
|
||||
{
|
||||
trashReference = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are sure that the reference is correct
|
||||
return childAssocRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -95,13 +106,13 @@ public class ChildAssocImpl implements ChildAssoc
|
||||
try
|
||||
{
|
||||
// double check
|
||||
if (childAssocRef == null )
|
||||
if (childAssocRef == null || trashReference)
|
||||
{
|
||||
childAssocRef = new ChildAssociationRef(
|
||||
this.typeQName,
|
||||
getParent().getNodeRef(),
|
||||
parent.getNodeRef(),
|
||||
this.qName,
|
||||
getChild().getNodeRef(),
|
||||
child.getNodeRef(),
|
||||
this.isPrimary,
|
||||
-1);
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -128,6 +129,13 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
PermissionService.ALL_PERMISSIONS,
|
||||
true);
|
||||
|
||||
// grant everyone rights to the archive store
|
||||
permissionService.setPermission(
|
||||
archiveStoreRootNodeRef,
|
||||
PermissionService.ALL_AUTHORITIES,
|
||||
PermissionService.ALL_PERMISSIONS,
|
||||
true);
|
||||
|
||||
TestWithUserUtils.createUser(USER_A, USER_A, workStoreRootNodeRef, nodeService, authenticationService);
|
||||
TestWithUserUtils.createUser(USER_B, USER_B, workStoreRootNodeRef, nodeService, authenticationService);
|
||||
}
|
||||
@@ -318,6 +326,11 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
verifyNodeExistence(b_, false);
|
||||
verifyNodeExistence(bb_, true);
|
||||
|
||||
// check that the required properties are present and correct
|
||||
Map<QName, Serializable> bb_Properties = nodeService.getProperties(bb_);
|
||||
Path bb_originalPath = (Path) bb_Properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH);
|
||||
assertNotNull("Original path not stored", bb_originalPath);
|
||||
|
||||
// restore the node
|
||||
nodeService.restoreNode(bb_, null, null, null);
|
||||
// check
|
||||
|
@@ -1279,6 +1279,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
{
|
||||
Node node = getNodeNotNull(nodeRef);
|
||||
ChildAssoc primaryParentAssoc = nodeDaoService.getPrimaryParentAssoc(node);
|
||||
Path primaryPath = getPath(nodeRef);
|
||||
|
||||
// add the aspect
|
||||
node.getAspects().add(ContentModel.ASPECT_ARCHIVED);
|
||||
@@ -1295,6 +1296,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
dictionaryService.getProperty(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC),
|
||||
primaryParentAssoc.getChildAssocRef());
|
||||
properties.put(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC, archivedPrimaryParentNodeRefProperty);
|
||||
PropertyValue archivedPrimaryPathProperty = makePropertyValue(
|
||||
dictionaryService.getProperty(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH),
|
||||
primaryPath);
|
||||
properties.put(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH, archivedPrimaryPathProperty);
|
||||
|
||||
// move the node
|
||||
NodeRef archiveStoreRootNodeRef = getRootNode(archiveStoreRef);
|
||||
|
Reference in New Issue
Block a user