RM-6865 allow spaces in declare and file path

This commit is contained in:
Sara Aspery
2019-06-05 15:26:31 +01:00
parent 57452c43eb
commit 1419540456

View File

@@ -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;
}
}