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/BRANCHES/DEV/5.2.N/root@129790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2016-08-23 11:14:03 +00:00
parent 6ffc55f5dd
commit 650554b62c
4 changed files with 70 additions and 40 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);
}