Merged /DEV/BUGFIXING/HEAD-2014_12_09 to HEAD:

92077: RM-1770 Not possible to delete parent/child reference

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@92096 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-12-09 17:01:53 +00:00
parent 3d7c41cbc8
commit 42f5dc5e5f
2 changed files with 80 additions and 2 deletions

View File

@@ -487,8 +487,9 @@ public class RelationshipServiceImpl extends RecordsManagementAdminBase implemen
// Get the association definition name
final QName associationDefinitionName = associationDefinition.getName();
final NodeRef targetNode = target;
final NodeRef sourceNode = source;
invokeBeforeRemoveReference(source, targetNode, associationDefinitionName);
invokeBeforeRemoveReference(sourceNode, targetNode, associationDefinitionName);
if (associationDefinition.isChild())
{
@@ -497,7 +498,7 @@ public class RelationshipServiceImpl extends RecordsManagementAdminBase implemen
@Override
public Void doWork()
{
List<ChildAssociationRef> children = getNodeService().getChildAssocs(targetNode);
List<ChildAssociationRef> children = getNodeService().getChildAssocs(sourceNode);
for (ChildAssociationRef chRef : children)
{
if (associationDefinitionName.equals(chRef.getTypeQName()) && chRef.getChildRef().equals(targetNode))

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.relationship;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.GUID;
/**
* Delete relationship test.
*
* @author Ana Bozianu
* @since 2.3
*/
public class DeleteRelationshipTest extends BaseRMTestCase
{
public void testDeleteRelationship() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
/** test data */
NodeRef sourceNode;
NodeRef targetNode;
String associationName = "obsoletes";
public void given()
{
// create the source record
sourceNode = utils.createRecord(rmFolder, GUID.generate());
//create the target record
targetNode = utils.createRecord(rmFolder, GUID.generate());
//create relationship
relationshipService.addRelationship(associationName, sourceNode, targetNode);
}
public void when()
{
//delete relationship
relationshipService.removeRelationship(associationName, sourceNode, targetNode);
}
public void then()
{
//check if relationship is deleted
Set<Relationship> relationships = relationshipService.getRelationshipsFrom(sourceNode);
for(Relationship r : relationships){
assertFalse(r.getTarget().equals(targetNode) && r.getUniqueName().equals(associationName));
}
}
});
}
}