mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
SHA-1875 : Link cannot be deleted if the original node is locked
- Removed aspect Lockable when the links are deleted - In case of the user try to create links for locked or checked out nodes, throw an error - Disabled audit when add marker aspect Linked - Added tests for case git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@132551 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -150,11 +150,7 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
{
|
||||
throw new IllegalArgumentException("Destination node NodeRef '" + source + "' must be of type " + ContentModel.TYPE_FOLDER);
|
||||
}
|
||||
//if file is working copy - create link to the original
|
||||
if (checkOutCheckInService.isWorkingCopy(source))
|
||||
{
|
||||
source = checkOutCheckInService.getCheckedOut(source);
|
||||
}
|
||||
|
||||
/* Create link */
|
||||
String sourceName = (String) nodeService.getProperty(source, ContentModel.PROP_NAME);
|
||||
|
||||
@@ -175,7 +171,12 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
|
||||
ChildAssociationRef childRef = null;
|
||||
QName sourceType = nodeService.getType(source);
|
||||
|
||||
|
||||
if( checkOutCheckInService.isWorkingCopy(source) || nodeService.hasAspect(source, ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
throw new IllegalArgumentException( "Cannot perform operation since the node (id:" + source.getId() + ") is locked.");
|
||||
}
|
||||
|
||||
if (dictionaryService.isSubClass(sourceType, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
// create File Link node
|
||||
@@ -193,7 +194,15 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
}
|
||||
|
||||
//add linked aspect to the sourceNode
|
||||
nodeService.addAspect(source, ApplicationModel.ASPECT_LINKED, null);
|
||||
behaviourFilter.disableBehaviour(source, ContentModel.ASPECT_AUDITABLE);
|
||||
try
|
||||
{
|
||||
nodeService.addAspect(source, ApplicationModel.ASPECT_LINKED, null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(source, ContentModel.ASPECT_AUDITABLE);
|
||||
}
|
||||
|
||||
return childRef.getChildRef();
|
||||
}
|
||||
@@ -296,7 +305,17 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
}
|
||||
|
||||
// remove also the aspect app:linked
|
||||
nodeService.removeAspect(document, ApplicationModel.ASPECT_LINKED);
|
||||
behaviourFilter.disableBehaviour(document, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(document, ContentModel.ASPECT_LOCKABLE);
|
||||
try
|
||||
{
|
||||
nodeService.removeAspect(document, ApplicationModel.ASPECT_LINKED);
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(document, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(document, ContentModel.ASPECT_LOCKABLE);
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
@@ -326,6 +345,7 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
if (nodeRefLinks.size() == 1 && nodeRefLinks.contains(linkNodeRef))
|
||||
{
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_LOCKABLE);
|
||||
try
|
||||
{
|
||||
// remove linked aspect to the sourceNode
|
||||
@@ -334,6 +354,7 @@ public class DocumentLinkServiceImpl implements DocumentLinkService, NodeService
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_LOCKABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user