From 2ac3615fd673214e7d0fc593eeba9b8dda58c8f5 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 1 Sep 2017 13:05:53 +0100 Subject: [PATCH 1/2] RM-5611 Create data setup method for edit with guides tests. Also add a new helper method in BaseTest to create a document in a site and return the noderef. --- .../org/alfresco/rest/core/v0/BaseAPI.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index 1e88d4be45..74ea1bc661 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -83,12 +83,12 @@ public abstract class BaseAPI @Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory; - @Autowired + @Autowired private ContentService contentService; private static final String NODE_REF_WORKSPACE_SPACES_STORE = "workspace://SpacesStore/"; private static final String FILE_PLAN_PATH = "Sites/rm/documentLibrary"; - + /** * Helper method to extract list of properties values from result. * @@ -404,11 +404,19 @@ public abstract class BaseAPI try { - responseBody = new JSONObject(EntityUtils.toString(response.getEntity())); + String bodyString = EntityUtils.toString(response.getEntity()); + try + { + responseBody = new JSONObject(bodyString); + } + catch (JSONException error) + { + LOGGER.error("Converting message body to JSON failed. Body: {}", responseBody, error); + } } - catch (ParseException | IOException | JSONException error) + catch (ParseException | IOException error) { - LOGGER.error("Parsing message body failed", error); + LOGGER.error("Parsing message body failed.", error); } switch (response.getStatusLine().getStatusCode()) @@ -616,7 +624,7 @@ public abstract class BaseAPI return getObjectByPath(username, password, itemPath) == null; } - /** + /** * Retrieve the node ref spaces store value * * @return node ref spaces store From 8adcb6323273cddc2acd0d345ab3b9388aab85e3 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 8 Sep 2017 14:10:47 +0100 Subject: [PATCH 2/2] RM-5611 Code review fixes. Remove nested try catch. Add additional check that we don't have duplicate topics selected. --- .../java/org/alfresco/rest/core/v0/BaseAPI.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index 74ea1bc661..0373fbcc73 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -404,15 +404,11 @@ public abstract class BaseAPI try { - String bodyString = EntityUtils.toString(response.getEntity()); - try - { - responseBody = new JSONObject(bodyString); - } - catch (JSONException error) - { - LOGGER.error("Converting message body to JSON failed. Body: {}", responseBody, error); - } + responseBody = new JSONObject(EntityUtils.toString(response.getEntity())); + } + catch (JSONException error) + { + LOGGER.error("Converting message body to JSON failed. Body: {}", responseBody, error); } catch (ParseException | IOException error) {