Fixed AssociationRef.equals method that was causing association matching to fail

Fixed node tests that were hiding a NullPointerException when node associations weren't found
Fixed NodeAssoc AssociationRef caching for cases where the source or target nodes move stores
Removed storage of Path property for archived nodes


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-05-12 22:04:49 +00:00
parent 881f966ee8
commit d8878a46ed
8 changed files with 38 additions and 47 deletions

View File

@@ -1206,24 +1206,6 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
return assocRef;
}
public void testAssociationToIncorrectNodeType() throws Exception
{
AssociationRef assocRef = createAssociation();
NodeRef sourceRef = assocRef.getSourceRef();
NodeRef targetRef = assocRef.getTargetRef();
QName qname = assocRef.getTypeQName();
try
{
// attempt the association in reverse
nodeService.createAssociation(sourceRef, targetRef, qname);
fail("Incorrect node type not detected");
}
catch (RuntimeException e)
{
// expected
}
}
public void testDuplicateAssociationDetection() throws Exception
{
AssociationRef assocRef = createAssociation();

View File

@@ -36,7 +36,6 @@ 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;
@@ -55,8 +54,8 @@ import org.springframework.context.ApplicationContext;
*/
public class ArchiveAndRestoreTest extends TestCase
{
private static final String USER_A = "AAAAA";
private static final String USER_B = "BBBBB";
private static final String USER_A = "aaaaa";
private static final String USER_B = "bbbbb";
private static final QName ASPECT_ATTACHABLE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "attachable");
private static final QName ASSOC_ATTACHMENTS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "attachments");
private static final QName QNAME_A = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "a");
@@ -123,11 +122,19 @@ public class ArchiveAndRestoreTest extends TestCase
// Map the work store to the archive store. This will already be wired into the NodeService.
StoreArchiveMap archiveMap = (StoreArchiveMap) ctx.getBean("storeArchiveMap");
archiveMap.getArchiveMap().put(workStoreRef, archiveStoreRef);
TestWithUserUtils.createUser(USER_A, USER_A, workStoreRootNodeRef, nodeService, authenticationService);
TestWithUserUtils.createUser(USER_B, USER_B, workStoreRootNodeRef, nodeService, authenticationService);
// grant everyone rights to the work store
// grant A and B rights to the work store
permissionService.setPermission(
workStoreRootNodeRef,
PermissionService.ALL_AUTHORITIES,
USER_A,
PermissionService.ALL_PERMISSIONS,
true);
permissionService.setPermission(
workStoreRootNodeRef,
USER_B,
PermissionService.ALL_PERMISSIONS,
true);
@@ -137,9 +144,6 @@ public class ArchiveAndRestoreTest extends TestCase
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);
}
finally
{
@@ -335,8 +339,8 @@ public class ArchiveAndRestoreTest extends TestCase
// 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);
ChildAssociationRef bb_originalParent = (ChildAssociationRef) bb_Properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
assertNotNull("Original parent not stored", bb_originalParent);
// restore the node
nodeService.restoreNode(bb_, null, null, null);

View File

@@ -1071,14 +1071,20 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
throws InvalidNodeRefException
{
// Invoke policy behaviours
invokeBeforeUpdateNode(sourceRef);
Node sourceNode = getNodeNotNull(sourceRef);
Node targetNode = getNodeNotNull(targetRef);
// get the association
NodeAssoc assoc = nodeDaoService.getNodeAssoc(sourceNode, targetNode, assocTypeQName);
if (assoc == null)
{
// nothing to remove
return;
}
AssociationRef assocRef = assoc.getNodeAssocRef();
// Invoke policy behaviours
invokeBeforeUpdateNode(sourceRef);
// delete it
nodeDaoService.deleteNodeAssoc(assoc);
@@ -1302,7 +1308,6 @@ 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);
@@ -1319,10 +1324,6 @@ 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);
@@ -1559,7 +1560,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// remove the aspect archived aspect
aspects.remove(ContentModel.ASPECT_ARCHIVED);
properties.remove(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
properties.remove(ContentModel.PROP_ARCHIVED_ORIGINAL_PATH);
properties.remove(ContentModel.PROP_ARCHIVED_BY);
properties.remove(ContentModel.PROP_ARCHIVED_DATE);