mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature/RM-6865_EnableEncodedDeclareAndFileRecPath' into 'master'
Resolve RM-6865 "Feature/ enableencodeddeclareandfilerecpath" Closes RM-6865 See merge request records-management/records-management!1188
This commit is contained in:
@@ -87,13 +87,15 @@ 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 UserModel userFillingPermission, userReadOnlyPermission;
|
||||
private SiteModel publicSite;
|
||||
private FolderModel testFolder;
|
||||
private FileModel testFile;
|
||||
private RecordCategory recordCategory;
|
||||
private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedRecordFolder;
|
||||
private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedRecordFolder, recordFolderWithSpacesInName;
|
||||
private UnfiledContainerChild unfiledContainerFolder;
|
||||
|
||||
@Autowired
|
||||
@@ -165,6 +167,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);
|
||||
|
||||
STEP("Create rm users with different permissions on the record category");
|
||||
userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING);
|
||||
@@ -222,6 +225,27 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
|
||||
assertTrue(hasRecordAspect(testFile), "File should have record aspect");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I am calling the "declare as record" action
|
||||
* And I provide a valid encoded 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
|
||||
{
|
||||
STEP("Declare document as record with an encoded location parameter value");
|
||||
getRestAPIFactory().getActionsAPI(userFillingPermission).declareAndFile(testFile,
|
||||
Utility.buildPath(recordCategory.getName(), RECORD_FOLDER_NAME_ENCODED));
|
||||
|
||||
STEP("Verify the declared record is placed in the record folder");
|
||||
assertTrue(isMatchingRecordInRecordFolder(testFile, recordFolderWithSpacesInName), "Record should be filed to record folder");
|
||||
|
||||
STEP("Verify the document in collaboration site is now a record");
|
||||
assertTrue(hasRecordAspect(testFile), "File should have record aspect");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I am calling the "declare as record" action
|
||||
* And I provide an invalid record folder in the location parameter
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
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;
|
||||
|
||||
@@ -171,6 +173,8 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
||||
*/
|
||||
private NodeRef resolvePath(NodeRef filePlan, final String pathParameter)
|
||||
{
|
||||
String decodedPathParameter = decode(pathParameter);
|
||||
|
||||
NodeRef destinationFolder;
|
||||
|
||||
if (filePlan == null)
|
||||
@@ -178,7 +182,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
||||
filePlan = getDefaultFilePlan();
|
||||
}
|
||||
|
||||
final String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true);
|
||||
final String[] pathElementsArray = StringUtils.tokenizeToStringArray(decodedPathParameter, "/", false, true);
|
||||
if ((pathElementsArray != null) && (pathElementsArray.length > 0))
|
||||
{
|
||||
destinationFolder = resolvePath(filePlan, Arrays.asList(pathElementsArray));
|
||||
@@ -259,4 +263,24 @@ 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user