mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Switched on negative test cases in association persistence and impl in product code
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13782 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -897,6 +897,7 @@ abstract class AbstractAssocCommand
|
|||||||
*/
|
*/
|
||||||
class AddAssocCommand extends AbstractAssocCommand
|
class AddAssocCommand extends AbstractAssocCommand
|
||||||
{
|
{
|
||||||
|
private static final Log logger = LogFactory.getLog(AddAssocCommand.class);
|
||||||
public AddAssocCommand(NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
public AddAssocCommand(NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
||||||
{
|
{
|
||||||
super(sourceNodeRef, targetNodeRef);
|
super(sourceNodeRef, targetNodeRef);
|
||||||
@@ -905,6 +906,18 @@ class AddAssocCommand extends AbstractAssocCommand
|
|||||||
@Override
|
@Override
|
||||||
protected void updateAssociations(NodeService nodeService)
|
protected void updateAssociations(NodeService nodeService)
|
||||||
{
|
{
|
||||||
|
List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, ContentModel.ASSOC_REFERENCES);
|
||||||
|
for (AssociationRef assoc : existingAssocs)
|
||||||
|
{
|
||||||
|
if (assoc.getTargetRef().equals(targetNodeRef))
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("Attempt to add existing association prevented. " + assoc);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ContentModel.ASSOC_REFERENCES);
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, ContentModel.ASSOC_REFERENCES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -916,6 +929,7 @@ class AddAssocCommand extends AbstractAssocCommand
|
|||||||
*/
|
*/
|
||||||
class RemoveAssocCommand extends AbstractAssocCommand
|
class RemoveAssocCommand extends AbstractAssocCommand
|
||||||
{
|
{
|
||||||
|
private static final Log logger = LogFactory.getLog(RemoveAssocCommand.class);
|
||||||
public RemoveAssocCommand(NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
public RemoveAssocCommand(NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
||||||
{
|
{
|
||||||
super(sourceNodeRef, targetNodeRef);
|
super(sourceNodeRef, targetNodeRef);
|
||||||
@@ -924,6 +938,31 @@ class RemoveAssocCommand extends AbstractAssocCommand
|
|||||||
@Override
|
@Override
|
||||||
protected void updateAssociations(NodeService nodeService)
|
protected void updateAssociations(NodeService nodeService)
|
||||||
{
|
{
|
||||||
|
List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, ContentModel.ASSOC_REFERENCES);
|
||||||
|
boolean assocDoesNotExist = true;
|
||||||
|
for (AssociationRef assoc : existingAssocs)
|
||||||
|
{
|
||||||
|
if (assoc.getTargetRef().equals(targetNodeRef))
|
||||||
|
{
|
||||||
|
assocDoesNotExist = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (assocDoesNotExist)
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
msg.append("Attempt to remove non-existent association prevented. ")
|
||||||
|
.append(sourceNodeRef)
|
||||||
|
.append("|")
|
||||||
|
.append(targetNodeRef)
|
||||||
|
.append(ContentModel.ASSOC_REFERENCES);
|
||||||
|
logger.warn(msg.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nodeService.removeAssociation(sourceNodeRef, targetNodeRef, ContentModel.ASSOC_REFERENCES);
|
nodeService.removeAssociation(sourceNodeRef, targetNodeRef, ContentModel.ASSOC_REFERENCES);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user