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:
@@ -131,6 +131,11 @@
|
|||||||
<type>d:childassocref</type>
|
<type>d:childassocref</type>
|
||||||
<mandatory>true</mandatory>
|
<mandatory>true</mandatory>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sys:archivedOriginalPath">
|
||||||
|
<type>d:any</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<index enabled="false" />
|
||||||
|
</property>
|
||||||
<property name="sys:archivedBy">
|
<property name="sys:archivedBy">
|
||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
<mandatory>true</mandatory>
|
<mandatory>true</mandatory>
|
||||||
|
@@ -42,6 +42,7 @@ public interface ContentModel
|
|||||||
// archived nodes aspect constants
|
// archived nodes aspect constants
|
||||||
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
static final QName ASPECT_ARCHIVED = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived");
|
||||||
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
static final QName PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalParentAssoc");
|
||||||
|
static final QName PROP_ARCHIVED_ORIGINAL_PATH = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedOriginalPath");
|
||||||
static final QName PROP_ARCHIVED_BY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedBy");
|
static final QName PROP_ARCHIVED_BY = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedBy");
|
||||||
static final QName PROP_ARCHIVED_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedDate");
|
static final QName PROP_ARCHIVED_DATE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archivedDate");
|
||||||
static final QName ASPECT_ARCHIVED_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived-assocs");
|
static final QName ASPECT_ARCHIVED_ASSOCS = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "archived-assocs");
|
||||||
|
@@ -77,15 +77,26 @@ public class ChildAssocImpl implements ChildAssoc
|
|||||||
|
|
||||||
public ChildAssociationRef getChildAssocRef()
|
public ChildAssociationRef getChildAssocRef()
|
||||||
{
|
{
|
||||||
|
boolean trashReference = false;
|
||||||
// first check if it is available
|
// first check if it is available
|
||||||
refReadLock.lock();
|
refReadLock.lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (childAssocRef != null)
|
if (childAssocRef != null)
|
||||||
{
|
{
|
||||||
|
// 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;
|
return childAssocRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
refReadLock.unlock();
|
refReadLock.unlock();
|
||||||
@@ -95,13 +106,13 @@ public class ChildAssocImpl implements ChildAssoc
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// double check
|
// double check
|
||||||
if (childAssocRef == null )
|
if (childAssocRef == null || trashReference)
|
||||||
{
|
{
|
||||||
childAssocRef = new ChildAssociationRef(
|
childAssocRef = new ChildAssociationRef(
|
||||||
this.typeQName,
|
this.typeQName,
|
||||||
getParent().getNodeRef(),
|
parent.getNodeRef(),
|
||||||
this.qName,
|
this.qName,
|
||||||
getChild().getNodeRef(),
|
child.getNodeRef(),
|
||||||
this.isPrimary,
|
this.isPrimary,
|
||||||
-1);
|
-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.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
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.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
@@ -128,6 +129,13 @@ public class ArchiveAndRestoreTest extends TestCase
|
|||||||
PermissionService.ALL_PERMISSIONS,
|
PermissionService.ALL_PERMISSIONS,
|
||||||
true);
|
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_A, USER_A, workStoreRootNodeRef, nodeService, authenticationService);
|
||||||
TestWithUserUtils.createUser(USER_B, USER_B, 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(b_, false);
|
||||||
verifyNodeExistence(bb_, true);
|
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
|
// restore the node
|
||||||
nodeService.restoreNode(bb_, null, null, null);
|
nodeService.restoreNode(bb_, null, null, null);
|
||||||
// check
|
// check
|
||||||
|
@@ -1279,6 +1279,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
{
|
{
|
||||||
Node node = getNodeNotNull(nodeRef);
|
Node node = getNodeNotNull(nodeRef);
|
||||||
ChildAssoc primaryParentAssoc = nodeDaoService.getPrimaryParentAssoc(node);
|
ChildAssoc primaryParentAssoc = nodeDaoService.getPrimaryParentAssoc(node);
|
||||||
|
Path primaryPath = getPath(nodeRef);
|
||||||
|
|
||||||
// add the aspect
|
// add the aspect
|
||||||
node.getAspects().add(ContentModel.ASPECT_ARCHIVED);
|
node.getAspects().add(ContentModel.ASPECT_ARCHIVED);
|
||||||
@@ -1295,6 +1296,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
dictionaryService.getProperty(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC),
|
dictionaryService.getProperty(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC),
|
||||||
primaryParentAssoc.getChildAssocRef());
|
primaryParentAssoc.getChildAssocRef());
|
||||||
properties.put(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC, archivedPrimaryParentNodeRefProperty);
|
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
|
// move the node
|
||||||
NodeRef archiveStoreRootNodeRef = getRootNode(archiveStoreRef);
|
NodeRef archiveStoreRootNodeRef = getRootNode(archiveStoreRef);
|
||||||
|
Reference in New Issue
Block a user