From e2e44eb9c73b40d0d6c438daf6a943693ce1e393 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 16 Dec 2019 15:14:31 +0200 Subject: [PATCH] Reduce Sonar issues from automation-community-rest-api --- .../alfresco/rest/rm/community/model/record/Record.java | 2 +- .../rm/community/model/recordcategory/RecordCategory.java | 2 +- .../model/recordcategory/RecordCategoryChild.java | 2 +- .../rest/rm/community/requests/gscore/api/FilesAPI.java | 1 - .../org/alfresco/rest/rm/community/util/PojoUtility.java | 8 ++++++-- .../java/org/alfresco/rest/v0/CustomDefinitionsAPI.java | 2 +- .../src/main/java/org/alfresco/rest/v0/RMAuditAPI.java | 2 +- .../src/main/java/org/alfresco/rest/v0/SearchAPI.java | 2 +- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java index 55acb537a9..9b959c193a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java @@ -109,7 +109,7 @@ public class Record extends TestModel implements IRestModel @Override public ModelAssertion assertThat() { - return new ModelAssertion(this); + return new ModelAssertion<>(this); } @Override diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategory.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategory.java index 297ac5ccf7..fbaa9a0ea9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategory.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategory.java @@ -53,7 +53,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class RecordCategory extends TestModel { - public final static String DEFAULT_FILE_PLAN_ALIAS = "-filePlan-"; + public static final String DEFAULT_FILE_PLAN_ALIAS = "-filePlan-"; /*************************/ /** Mandatory parameters */ diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryChild.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryChild.java index 746e8f2fe3..008c10bcbf 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryChild.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryChild.java @@ -53,7 +53,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class RecordCategoryChild extends TestModel { - public final static String RECORD_FOLDER_NODE_TYPE = "rma:recordFolder"; + public static final String RECORD_FOLDER_NODE_TYPE = "rma:recordFolder"; /*************************/ /** Mandatory parameters */ diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java index 949d4cbfc3..0b86644d5d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java @@ -28,7 +28,6 @@ package org.alfresco.rest.rm.community.requests.gscore.api; import static org.alfresco.rest.core.RestRequest.simpleRequest; import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString; -import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.springframework.http.HttpMethod.POST; import org.alfresco.rest.core.RMRestWrapper; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java index 7d0d08f98a..55592dfbbd 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java @@ -54,6 +54,10 @@ public class PojoUtility */ private static final Logger LOGGER = LoggerFactory.getLogger(PojoUtility.class); + /** Private constructor to prevent instantiation. */ + private PojoUtility() + {} + /** * see {@link #toJson(Object, Class, Class)} */ @@ -122,7 +126,7 @@ public class PojoUtility } catch (IOException e) { - LOGGER.error("Unable to convert the json into a java object.", e.toString()); + LOGGER.error("Unable to convert the json into a java object.", e); } return obj; @@ -152,7 +156,7 @@ public class PojoUtility } catch (IOException e) { - LOGGER.error("Unable to convert the json array into a java collection.", e.toString()); + LOGGER.error("Unable to convert the json array into a java collection.", e); } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/CustomDefinitionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/CustomDefinitionsAPI.java index 6b480fd10d..bae0a15631 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/CustomDefinitionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/CustomDefinitionsAPI.java @@ -105,7 +105,7 @@ public class CustomDefinitionsAPI extends BaseAPI } catch (JSONException error) { - LOGGER.error("Unable to get the refId for the custom reference definition " + customDefinition); + LOGGER.error("Unable to get the refId for the custom reference definition {}", customDefinition); } } return null; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java index 10c7125ec8..6558d67bb0 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java @@ -76,7 +76,7 @@ public class RMAuditAPI extends BaseAPI } catch (UnsupportedEncodingException e) { - LOGGER.error("Unable to encode the event name" + e.getMessage()); + LOGGER.error("Unable to encode the event name {}", e.getMessage()); } JSONArray auditEntries = doGetRequest(user, password, MessageFormat.format(RM_AUDIT_LOG_API,"{0}", parameters)).getJSONObject("data").getJSONArray("entries"); diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java index c1a42bae6a..80d7a9a23d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/SearchAPI.java @@ -102,7 +102,7 @@ public class SearchAPI extends BaseAPI String filters, String sortby) { - List searchParameters = new ArrayList(); + List searchParameters = new ArrayList<>(); searchParameters.add(new BasicNameValuePair("query", query)); searchParameters.add(new BasicNameValuePair("filters", filters)); if (sortby != null)