From c82d58647918add9406dc610b14dbfbaa53ac6fd Mon Sep 17 00:00:00 2001 From: Ross Gale Date: Tue, 18 Jun 2019 17:45:46 +0100 Subject: [PATCH] RM-6865 removing encoding of path in action body --- .../gscore/api/ActionsExecutionAPI.java | 15 --------- .../DeclareAndFileDocumentAsRecordTests.java | 11 +++---- .../action/dm/CreateRecordAction.java | 32 +------------------ 3 files changed, 6 insertions(+), 52 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/ActionsExecutionAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/ActionsExecutionAPI.java index f15c336b9c..a977db9ad6 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/ActionsExecutionAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/ActionsExecutionAPI.java @@ -64,21 +64,6 @@ public class ActionsExecutionAPI extends RMModelRequest ImmutableMap.of("path", destinationPath)); } - /** - * Declares and files a document as record to a record folder using v1 actions api - * - * @param targetNode the node on which the action is executed - * @param destinationPath the path to the record folder - * @param encoded value to indicate if the path has been encoded - * @throws Exception - */ - public JSONObject declareAndFile(RepoTestModel targetNode, String destinationPath, boolean encoded) throws Exception - { - return getRmRestWrapper().withCoreAPI().usingActions() - .executeAction(ActionsOnRule.DECLARE_AS_RECORD.getActionValue(), targetNode, - ImmutableMap.of("path", destinationPath, "encoded", String.valueOf(encoded))); - } - /** * Declares a document as record using v1 actions api * diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java index f16ad991db..244132d031 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java @@ -87,8 +87,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest private final static String DESTINATION_PATH_NOT_RECORD_FOLDER_EXC = "Unable to execute create-record action, because the destination path is not a record folder."; private final static String CLOSED_RECORD_FOLDER_EXC = "You can't add new items to a closed record folder."; private final static String HOLD_NAME = "holdName"; - private final static String RECORD_FOLDER_NAME_ENCODED = "Folder%20With%20Spaces%20In%20Name"; - private final static String RECORD_FOLDER_NAME_DECODED = "Folder With Spaces In Name"; + private final static String RECORD_FOLDER_NAME_WITH_SPACE = "Folder With Spaces In Name"; private UserModel userFillingPermission, userReadOnlyPermission; private SiteModel publicSite; @@ -167,7 +166,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE); closedRecordFolder = createFolder(recordCategory.getId(), getRandomName("closedRecordFolder")); closeFolder(closedRecordFolder.getId()); - recordFolderWithSpacesInName = createFolder(recordCategory.getId(), RECORD_FOLDER_NAME_DECODED); + recordFolderWithSpacesInName = createFolder(recordCategory.getId(), RECORD_FOLDER_NAME_WITH_SPACE); STEP("Create rm users with different permissions on the record category"); userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING); @@ -227,17 +226,17 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest /** * Given I am calling the "declare as record" action - * And I provide a valid encoded record folder name in the location parameter + * And I provide a valid record folder name in the location parameter * When I execute the action * Then the document is declared as a record * And is filed to the record folder specified */ @Test - public void declareAndFileToValidEncodedLocationUsingActionsAPI() throws Exception + public void declareAndFileToValidLocationWithSpacesUsingActionsAPI() throws Exception { STEP("Declare document as record with an encoded location parameter value"); getRestAPIFactory().getActionsAPI(userFillingPermission).declareAndFile(testFile, - Utility.buildPath(recordCategory.getName(), RECORD_FOLDER_NAME_ENCODED), true); + Utility.buildPath(recordCategory.getName(), RECORD_FOLDER_NAME_WITH_SPACE)); STEP("Verify the declared record is placed in the record folder"); assertTrue(isMatchingRecordInRecordFolder(testFile, recordFolderWithSpacesInName), "Record should be filed to record folder"); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java index 4f6aee0895..0700df1524 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/dm/CreateRecordAction.java @@ -27,8 +27,6 @@ package org.alfresco.module.org_alfresco_module_rm.action.dm; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; import java.util.Arrays; import java.util.List; @@ -140,14 +138,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase if (pathParameter != null && !pathParameter.isEmpty()) { - if (action.getParameterValue(PARAM_ENCODED) != null && (Boolean) action.getParameterValue(PARAM_ENCODED)) - { - destinationRecordFolder = resolvePath(filePlan, decode(pathParameter)); - } - else - { - destinationRecordFolder = resolvePath(filePlan, pathParameter); - } + destinationRecordFolder = resolvePath(filePlan, pathParameter); } synchronized (this) @@ -172,7 +163,6 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); params.add(new ParameterDefinitionImpl(PARAM_PATH, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_PATH))); params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD))); - params.add(new ParameterDefinitionImpl(PARAM_ENCODED, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_ENCODED))); } /** @@ -272,24 +262,4 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase } return filePlan; } - - /** - * Helper method to decode path string - * - * @param pathParameter The path string to be decoded - * @return The decoded path string - */ - private String decode(String pathParameter) - { - String decodedPathParameter; - try - { - decodedPathParameter = URLDecoder.decode(pathParameter, "UTF-8"); - } - catch (UnsupportedEncodingException ex) - { - throw new AlfrescoRuntimeException("Unable to execute " + NAME + " action, because the destination path could not be decoded."); - } - return decodedPathParameter; - } }