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

129790 jvonka: REPO-164 / REPO-1141: fix error mapping when unable to update content due to locked node (should be 409 not 500)
   - also minor cleanup of error handling/mapping (handle within common "writeContent")


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130230 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-09-06 14:43:25 +00:00
parent 2e47b0cce2
commit 65f1f05d1f
4 changed files with 68 additions and 38 deletions

View File

@@ -764,16 +764,29 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
// create empty file
HttpResponse response = post(getNodeChildrenUrl(parentFolderId), toJsonAsStringNonNull(d1), params, null, "alfresco", expectedStatus);
if (expectedStatus != 201)
{
return null;
}
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
}
protected Document updateTextFile(String contentId, String textContent, Map<String, String> params) throws IOException, Exception
protected Document updateTextFile(String contentId, String textContent, Map<String, String> params) throws Exception
{
return updateTextFile(contentId, textContent, params, 200);
}
protected Document updateTextFile(String contentId, String textContent, Map<String, String> params, int expectedStatus) throws Exception
{
ByteArrayInputStream inputStream = new ByteArrayInputStream(textContent.getBytes());
File txtFile = TempFileProvider.createTempFile(inputStream, getClass().getSimpleName(), ".txt");
BinaryPayload payload = new BinaryPayload(txtFile);
HttpResponse response = putBinary(getNodeContentUrl(contentId), payload, null, params, 200);
HttpResponse response = putBinary(getNodeContentUrl(contentId), payload, null, params, expectedStatus);
if (expectedStatus != 200)
{
return null;
}
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
}