mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126592 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124825 gjames: RA-849: Restore Deleted Node git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126937 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.rest;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsStringNonNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -43,6 +44,7 @@ import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -123,6 +125,46 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
checkDeletedNodes(now, createdFolder, createdFolderNonSite, document, nodes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndRestore() throws Exception
|
||||
{
|
||||
publicApiClient.setRequestContext(new RequestContext(u1.getId()));
|
||||
Date now = new Date();
|
||||
String folder1 = "folder" + now.getTime() + "_1";
|
||||
Folder createdFolder = createFolder(u1.getId(), docLibNodeRef.getId(), folder1, null);
|
||||
assertNotNull(createdFolder);
|
||||
|
||||
//Create a folder outside a site
|
||||
Folder createdFolderNonSite = createFolder(u1.getId(), Nodes.PATH_MY, folder1, null);
|
||||
assertNotNull(createdFolderNonSite);
|
||||
|
||||
Document document = createDocument(createdFolder, "restoreme.txt");
|
||||
delete(URL_NODES, u1.getId(), document.getId(), 204);
|
||||
//Create another document with the same name
|
||||
Document documentSameName = createDocument(createdFolder, "restoreme.txt");
|
||||
|
||||
//Can't restore a node of the same name
|
||||
HttpResponse response = post("deleted-nodes/"+document.getId()+"/restore", u1.getId(), null, null, Status.STATUS_CONFLICT);
|
||||
|
||||
delete(URL_NODES, u1.getId(), documentSameName.getId(), 204);
|
||||
|
||||
//Now we can restore it.
|
||||
response = post("deleted-nodes/"+document.getId()+"/restore", u1.getId(), null, null, 201);
|
||||
|
||||
delete(URL_NODES, u1.getId(), createdFolder.getId(), 204);
|
||||
|
||||
//We deleted the parent folder so lets see if we can restore a child doc, hopefully not.
|
||||
response = post("deleted-nodes/"+documentSameName.getId()+"/restore", u1.getId(), null, null, Status.STATUS_NOT_FOUND);
|
||||
|
||||
//Can't delete "nonsense" noderef
|
||||
response = post("deleted-nodes/nonsense/restore", u1.getId(), null, null, Status.STATUS_NOT_FOUND);
|
||||
|
||||
RepoService.TestPerson u2 = networkOne.createUser();
|
||||
//User 2 can't restore it but user 1 can.
|
||||
response = post("deleted-nodes/"+createdFolder.getId()+"/restore", u2.getId(), null, null, Status.STATUS_FORBIDDEN);
|
||||
response = post("deleted-nodes/"+createdFolder.getId()+"/restore", u1.getId(), null, null, 201);
|
||||
}
|
||||
|
||||
protected void checkDeletedNodes(Date now, Folder createdFolder, Folder createdFolderNonSite, Document document, List<Node> nodes)
|
||||
{
|
||||
Node aNode = (Node) nodes.get(0);
|
||||
|
Reference in New Issue
Block a user