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

126515 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      122947 jvonka: (Quick) Shared Links API - updates
      - test for get rendition content via share link (no auth)
      - add optional filter (sharedByUser) to find links
      RA-830, RA-777


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126859 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 11:56:20 +00:00
parent d2fa56e4b1
commit e48ed0687b
6 changed files with 147 additions and 83 deletions

View File

@@ -26,9 +26,8 @@
package org.alfresco.rest.api.tests;
import static org.alfresco.rest.api.tests.util.RestApiUtil.parsePaging;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
import static org.junit.Assert.*;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.tenant.TenantUtil;
@@ -45,6 +44,7 @@ import org.alfresco.rest.api.tests.client.RequestContext;
import org.alfresco.rest.api.tests.client.data.Document;
import org.alfresco.rest.api.tests.client.data.Folder;
import org.alfresco.rest.api.tests.client.data.Node;
import org.alfresco.rest.api.tests.client.data.Rendition;
import org.alfresco.rest.api.tests.util.MultiPartBuilder;
import org.alfresco.rest.api.tests.util.RestApiUtil;
import org.alfresco.service.cmr.site.SiteVisibility;
@@ -344,4 +344,59 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
}
return ResourceUtils.getFile(url);
}
protected static final long PAUSE_TIME = 5000; //millisecond
protected static final int MAX_RETRY = 10;
protected Rendition createAndGetRendition(String userId, String sourceNodeId, String renditionId) throws Exception
{
Rendition renditionRequest = new Rendition();
renditionRequest.setId(renditionId);
int retryCount = 0;
while (retryCount < MAX_RETRY)
{
try
{
HttpResponse res = post(getRenditionsUrl(sourceNodeId), userId, toJsonAsString(renditionRequest), 202);
assertNull(res.getJsonResponse());
break;
}
catch (AssertionError ex)
{
// If no transformer is currently available,
// wait for 'PAUSE_TIME' and try again.
retryCount++;
Thread.sleep(PAUSE_TIME);
}
}
retryCount = 0;
while (retryCount < MAX_RETRY)
{
try
{
HttpResponse response = getSingle(getRenditionsUrl(sourceNodeId), userId, renditionId, 200);
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
assertNotNull(rendition);
assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
return rendition;
}
catch (AssertionError ex)
{
// If the asynchronous create rendition action is not finished yet,
// wait for 'PAUSE_TIME' and try again.
retryCount++;
Thread.sleep(PAUSE_TIME);
}
}
return null;
}
private String getRenditionsUrl(String nodeId)
{
return "nodes/" + nodeId + "/renditions";
}
}