Merged 5.2.N (5.2.1) to HEAD (5.2)

132551 rneamtu: 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/HEAD/root@132676 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-10 17:00:11 +00:00
parent 7ffe84308a
commit d17fef60dc

View File

@@ -636,6 +636,77 @@ public class NodeWebScripTest extends BaseWebScriptTest
assertEquals(false, nodeService.hasAspect(testFile4, ApplicationModel.ASPECT_LINKED));
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
//you should not be able to create links for locked nodes but you can delete links
final NodeRef testFile5 = createNode(testFolder1, "testingLinkCreationFileWithLock", ContentModel.TYPE_CONTENT,
AuthenticationUtil.getAdminUserName());
req = new Request("POST", CREATE_LINK_API + testFile5.getStoreRef().getProtocol() + "/"
+ testFile5.getStoreRef().getIdentifier() + "/" + testFile5.getId());
jsonReq = new JSONObject();
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
jsonArray = new JSONArray();
jsonArray.add(testFile5.toString());
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
req.setBody(jsonReq.toString().getBytes());
req.setType(MimetypeMap.MIMETYPE_JSON);
json = asJSON(sendRequest(req, Status.STATUS_OK));
jsonLinkNodes = (JSONArray) json.get("linkNodes");
assertNotNull(jsonLinkNodes);
assertEquals(1, jsonLinkNodes.size());
assertEquals("true", json.get("overallSuccess"));
assertEquals("1", json.get("successCount"));
assertEquals("0", json.get("failureCount"));
jsonLinkNode = (JSONObject) jsonLinkNodes.get(0);
nodeRef = (String) jsonLinkNode.get("nodeRef");
NodeRef file5Link = new NodeRef(nodeRef);
assertEquals(true, nodeService.hasAspect(testFile5, ApplicationModel.ASPECT_LINKED));
assertEquals(true, nodeService.exists(file5Link));
//checkout the node testFile5
final NodeRef workingCopy = retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Exception
{
return checkOutCheckInService.checkout(testFile5);
}
});
assertNotNull(workingCopy);
//try to create link for working copy
req = new Request("POST", CREATE_LINK_API + workingCopy.getStoreRef().getProtocol() + "/"
+ workingCopy.getStoreRef().getIdentifier() + "/" + workingCopy.getId());
jsonReq = new JSONObject();
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
jsonArray = new JSONArray();
jsonArray.add(workingCopy.toString());
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
req.setBody(jsonReq.toString().getBytes());
req.setType(MimetypeMap.MIMETYPE_JSON);
//should fail since source node is working copy
json = asJSON(sendRequest(req, Status.STATUS_BAD_REQUEST));
//delete the link when source node is locked
nodeService.deleteNode(file5Link);
assertEquals(false, nodeService.hasAspect(testFile5, ApplicationModel.ASPECT_LINKED));
//release the lock
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
checkOutCheckInService.checkin(workingCopy, new HashMap<String, Serializable>());
return null;
}
});
assertEquals(false, nodeService.hasAspect(testFile5, ContentModel.ASPECT_LOCKABLE));
}
private NodeRef createNode(NodeRef parentNode, String nodeCmName, QName nodeType, String ownerUserName)