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:
Tatyana Valkevych
2015-04-08 16:10:03 +00:00
parent 74149ea9dd
commit d047d67fb3

View File

@@ -34,6 +34,8 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.web.scripts.BaseWebScriptTest; 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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -75,6 +77,7 @@ public class SiteServiceTest extends BaseWebScriptTest
private NodeService nodeService; private NodeService nodeService;
private PermissionService permissionService; private PermissionService permissionService;
private AuthorityService authorityService; private AuthorityService authorityService;
private FileFolderService fileFolderService;
private static final String USER_ONE = "SiteTestOne"; private static final String USER_ONE = "SiteTestOne";
private static final String USER_TWO = "SiteTestTwo"; private static final String USER_TWO = "SiteTestTwo";
@@ -101,6 +104,8 @@ public class SiteServiceTest extends BaseWebScriptTest
this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService"); this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService");
this.permissionService = (PermissionService)getServer().getApplicationContext().getBean("PermissionService"); this.permissionService = (PermissionService)getServer().getApplicationContext().getBean("PermissionService");
this.authorityService = (AuthorityService)getServer().getApplicationContext().getBean("AuthorityService"); 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 // sets the testMode property to true via spring injection. This will prevent emails
// from being sent from within this test case. // from being sent from within this test case.
this.authenticationComponent.setSystemUserAsCurrentUser(); this.authenticationComponent.setSystemUserAsCurrentUser();
@@ -778,35 +783,14 @@ public class SiteServiceTest extends BaseWebScriptTest
private NodeRef copyToSite(NodeRef fileRef, NodeRef destRef) throws Exception private NodeRef copyToSite(NodeRef fileRef, NodeRef destRef) throws Exception
{ {
String copyUrl = "/slingshot/doclib/action/copy-to/node/workspace/SpacesStore/" + destRef.getId(); FileInfo copiedFileInfo = fileFolderService.copy(fileRef, destRef, null);
return copyMoveRequest(fileRef, destRef, copyUrl); return copiedFileInfo.getNodeRef();
} }
private NodeRef moveToSite(NodeRef fileRef, NodeRef destRef) throws Exception private NodeRef moveToSite(NodeRef fileRef, NodeRef destRef) throws Exception
{ {
String moveUrl = "/slingshot/doclib/action/move-to/node/workspace/SpacesStore/" + destRef.getId(); FileInfo movedFileInfo = fileFolderService.move(fileRef, destRef, null);
return copyMoveRequest(fileRef, destRef, moveUrl); return movedFileInfo.getNodeRef();
}
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);
} }
private void checkPermissions(NodeRef nodeRef, String necessatyAuth, String expectedPermission, String actionInfo) private void checkPermissions(NodeRef nodeRef, String necessatyAuth, String expectedPermission, String actionInfo)