mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
101312: Merge RA-SPRINT2 to HEAD-BUG-FIX (5.1) 99983: RA-62: fix SiteServiceTest so that it uses FileFolderService for copy/move instead of /slingshot API. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@101454 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -34,6 +34,8 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -75,6 +77,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
||||
private NodeService nodeService;
|
||||
private PermissionService permissionService;
|
||||
private AuthorityService authorityService;
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
private static final String USER_ONE = "SiteTestOne";
|
||||
private static final String USER_TWO = "SiteTestTwo";
|
||||
@@ -101,6 +104,8 @@ public class SiteServiceTest extends BaseWebScriptTest
|
||||
this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService");
|
||||
this.permissionService = (PermissionService)getServer().getApplicationContext().getBean("PermissionService");
|
||||
this.authorityService = (AuthorityService)getServer().getApplicationContext().getBean("AuthorityService");
|
||||
this.fileFolderService = (FileFolderService)getServer().getApplicationContext().getBean("FileFolderService");
|
||||
|
||||
// sets the testMode property to true via spring injection. This will prevent emails
|
||||
// from being sent from within this test case.
|
||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||
@@ -778,35 +783,14 @@ public class SiteServiceTest extends BaseWebScriptTest
|
||||
|
||||
private NodeRef copyToSite(NodeRef fileRef, NodeRef destRef) throws Exception
|
||||
{
|
||||
String copyUrl = "/slingshot/doclib/action/copy-to/node/workspace/SpacesStore/" + destRef.getId();
|
||||
return copyMoveRequest(fileRef, destRef, copyUrl);
|
||||
FileInfo copiedFileInfo = fileFolderService.copy(fileRef, destRef, null);
|
||||
return copiedFileInfo.getNodeRef();
|
||||
}
|
||||
|
||||
private NodeRef moveToSite(NodeRef fileRef, NodeRef destRef) throws Exception
|
||||
{
|
||||
String moveUrl = "/slingshot/doclib/action/move-to/node/workspace/SpacesStore/" + destRef.getId();
|
||||
return copyMoveRequest(fileRef, destRef, moveUrl);
|
||||
}
|
||||
|
||||
private NodeRef copyMoveRequest(NodeRef fileRef, NodeRef destRef, String actionUrl) throws Exception
|
||||
{
|
||||
JSONObject copyRequest = new JSONObject();
|
||||
JSONArray nodesToCopy = new JSONArray();
|
||||
nodesToCopy.put(fileRef.toString());
|
||||
copyRequest.put("nodeRefs", nodesToCopy);
|
||||
copyRequest.put("parentId", nodeService.getPrimaryParent(fileRef).getChildRef());
|
||||
|
||||
Response response = sendRequest(new PostRequest(actionUrl, copyRequest.toString(), "application/json"), Status.STATUS_OK);
|
||||
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
String failures = result.getString("failureCount");
|
||||
if (Integer.parseInt(failures) != 0)
|
||||
{
|
||||
fail("Failure at copy action");
|
||||
}
|
||||
JSONArray resList = result.getJSONArray("results");
|
||||
String resNodeRefStr = resList.getJSONObject(0).getString("nodeRef");
|
||||
return new NodeRef(resNodeRefStr);
|
||||
FileInfo movedFileInfo = fileFolderService.move(fileRef, destRef, null);
|
||||
return movedFileInfo.getNodeRef();
|
||||
}
|
||||
|
||||
private void checkPermissions(NodeRef nodeRef, String necessatyAuth, String expectedPermission, String actionInfo)
|
||||
|
Reference in New Issue
Block a user