mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature/RM-6865_RemoveEncoding' into 'master'
Resolve RM-6865 "Feature/ removeencoding" Closes RM-6865 See merge request records-management/records-management!1196
This commit is contained in:
@@ -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 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 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 HOLD_NAME = "holdName";
|
||||||
private final static String RECORD_FOLDER_NAME_ENCODED = "Folder%20With%20Spaces%20In%20Name";
|
private final static String RECORD_FOLDER_NAME_WITH_SPACE = "Folder With Spaces In Name";
|
||||||
private final static String RECORD_FOLDER_NAME_DECODED = "Folder With Spaces In Name";
|
|
||||||
|
|
||||||
private UserModel userFillingPermission, userReadOnlyPermission;
|
private UserModel userFillingPermission, userReadOnlyPermission;
|
||||||
private SiteModel publicSite;
|
private SiteModel publicSite;
|
||||||
@@ -167,7 +166,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
|
|||||||
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
|
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE);
|
||||||
closedRecordFolder = createFolder(recordCategory.getId(), getRandomName("closedRecordFolder"));
|
closedRecordFolder = createFolder(recordCategory.getId(), getRandomName("closedRecordFolder"));
|
||||||
closeFolder(closedRecordFolder.getId());
|
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");
|
STEP("Create rm users with different permissions on the record category");
|
||||||
userFillingPermission = roleService.createCollaboratorWithRMRoleAndPermission(publicSite, recordCategory, ROLE_RM_POWER_USER, PERMISSION_FILING);
|
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
|
* 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
|
* When I execute the action
|
||||||
* Then the document is declared as a record
|
* Then the document is declared as a record
|
||||||
* And is filed to the record folder specified
|
* And is filed to the record folder specified
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void declareAndFileToValidEncodedLocationUsingActionsAPI() throws Exception
|
public void declareAndFileToValidLocationWithSpacesUsingActionsAPI() throws Exception
|
||||||
{
|
{
|
||||||
STEP("Declare document as record with an encoded location parameter value");
|
STEP("Declare document as record with an encoded location parameter value");
|
||||||
getRestAPIFactory().getActionsAPI(userFillingPermission).declareAndFile(testFile,
|
getRestAPIFactory().getActionsAPI(userFillingPermission).declareAndFile(testFile,
|
||||||
Utility.buildPath(recordCategory.getName(), RECORD_FOLDER_NAME_ENCODED));
|
Utility.buildPath(recordCategory.getName(), RECORD_FOLDER_NAME_WITH_SPACE));
|
||||||
|
|
||||||
STEP("Verify the declared record is placed in the record folder");
|
STEP("Verify the declared record is placed in the record folder");
|
||||||
assertTrue(isMatchingRecordInRecordFolder(testFile, recordFolderWithSpacesInName), "Record should be filed to record folder");
|
assertTrue(isMatchingRecordInRecordFolder(testFile, recordFolderWithSpacesInName), "Record should be filed to record folder");
|
||||||
|
@@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.action.dm;
|
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.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -127,10 +125,6 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
|||||||
// resolve destination record folder if path supplied
|
// resolve destination record folder if path supplied
|
||||||
NodeRef destinationRecordFolder = null;
|
NodeRef destinationRecordFolder = null;
|
||||||
String pathParameter = (String) action.getParameterValue(PARAM_PATH);
|
String pathParameter = (String) action.getParameterValue(PARAM_PATH);
|
||||||
if (pathParameter != null && !pathParameter.isEmpty())
|
|
||||||
{
|
|
||||||
destinationRecordFolder = resolvePath(filePlan, pathParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// indicate whether the record should be hidden or not (default not)
|
// indicate whether the record should be hidden or not (default not)
|
||||||
boolean hideRecord = false;
|
boolean hideRecord = false;
|
||||||
@@ -140,6 +134,11 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
|||||||
hideRecord = hideRecordValue.booleanValue();
|
hideRecord = hideRecordValue.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pathParameter != null && !pathParameter.isEmpty())
|
||||||
|
{
|
||||||
|
destinationRecordFolder = resolvePath(filePlan, pathParameter);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
// create record from existing document
|
// create record from existing document
|
||||||
@@ -167,14 +166,12 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
|||||||
/**
|
/**
|
||||||
* Helper method to get the target record folder node reference from the action path parameter
|
* Helper method to get the target record folder node reference from the action path parameter
|
||||||
*
|
*
|
||||||
* @param filePlan The filePlan containing the path
|
* @param filePlan The filePlan containing the path
|
||||||
* @param pathParameter The path
|
* @param pathParameter The path
|
||||||
* @return The NodeRef of the resolved path
|
* @return The NodeRef of the resolved path
|
||||||
*/
|
*/
|
||||||
private NodeRef resolvePath(NodeRef filePlan, final String pathParameter)
|
private NodeRef resolvePath(NodeRef filePlan, final String pathParameter)
|
||||||
{
|
{
|
||||||
String decodedPathParameter = decode(pathParameter);
|
|
||||||
|
|
||||||
NodeRef destinationFolder;
|
NodeRef destinationFolder;
|
||||||
|
|
||||||
if (filePlan == null)
|
if (filePlan == null)
|
||||||
@@ -182,7 +179,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
|||||||
filePlan = getDefaultFilePlan();
|
filePlan = getDefaultFilePlan();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] pathElementsArray = StringUtils.tokenizeToStringArray(decodedPathParameter, "/", false, true);
|
final String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true);
|
||||||
if ((pathElementsArray != null) && (pathElementsArray.length > 0))
|
if ((pathElementsArray != null) && (pathElementsArray.length > 0))
|
||||||
{
|
{
|
||||||
destinationFolder = resolvePath(filePlan, Arrays.asList(pathElementsArray));
|
destinationFolder = resolvePath(filePlan, Arrays.asList(pathElementsArray));
|
||||||
@@ -263,24 +260,4 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
|||||||
}
|
}
|
||||||
return filePlan;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -117,4 +117,34 @@ public class CreateRecordActionTest extends BaseRMTestCase
|
|||||||
},
|
},
|
||||||
ADMIN_USER);
|
ADMIN_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateRecordActionWithLocationWithSpaces()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
assertFalse(recordService.isRecord(dmDocument1));
|
||||||
|
|
||||||
|
Action action = actionService.createAction(CreateRecordAction.NAME);
|
||||||
|
action.setParameterValue(CreateRecordAction.PARAM_HIDE_RECORD, false);
|
||||||
|
action.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
|
||||||
|
action.setParameterValue(CreateRecordAction.PARAM_PATH, "rm Container/rm Folder");
|
||||||
|
actionService.executeAction(action, dmDocument1);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test(Void result) throws Exception
|
||||||
|
{
|
||||||
|
assertTrue(recordService.isRecord(dmDocument1));
|
||||||
|
assertTrue(recordService.isFiled(dmDocument1));
|
||||||
|
|
||||||
|
// is the record folder the primary parent of the filed record
|
||||||
|
NodeRef parent = nodeService.getPrimaryParent(dmDocument1).getParentRef();
|
||||||
|
assertEquals(rm_Folder, parent);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ADMIN_USER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,6 @@ import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServi
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||||
@@ -62,7 +61,6 @@ import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
|||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authority.AuthorityDAO;
|
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.site.SiteServiceImpl;
|
import org.alfresco.repo.site.SiteServiceImpl;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
@@ -186,8 +184,10 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
protected NodeRef folder;
|
protected NodeRef folder;
|
||||||
protected NodeRef filePlan;
|
protected NodeRef filePlan;
|
||||||
protected NodeRef rmContainer;
|
protected NodeRef rmContainer;
|
||||||
|
protected NodeRef rm_Container;
|
||||||
protected DispositionSchedule dispositionSchedule;
|
protected DispositionSchedule dispositionSchedule;
|
||||||
protected NodeRef rmFolder;
|
protected NodeRef rmFolder;
|
||||||
|
protected NodeRef rm_Folder;
|
||||||
protected NodeRef unfiledContainer;
|
protected NodeRef unfiledContainer;
|
||||||
protected String collabSiteId;
|
protected String collabSiteId;
|
||||||
protected NodeRef holdsContainer;
|
protected NodeRef holdsContainer;
|
||||||
@@ -586,12 +586,18 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
rmContainer = filePlanService.createRecordCategory(filePlan, "rmContainer");
|
rmContainer = filePlanService.createRecordCategory(filePlan, "rmContainer");
|
||||||
assertNotNull("Could not create rm container", rmContainer);
|
assertNotNull("Could not create rm container", rmContainer);
|
||||||
|
|
||||||
|
rm_Container = filePlanService.createRecordCategory(filePlan, "rm Container");
|
||||||
|
assertNotNull("Could not create rm container", rm_Container);
|
||||||
|
|
||||||
// Create disposition schedule
|
// Create disposition schedule
|
||||||
dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer);
|
dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer);
|
||||||
|
|
||||||
// Create RM folder
|
// Create RM folder
|
||||||
rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder");
|
rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder");
|
||||||
assertNotNull("Could not create rm folder", rmFolder);
|
assertNotNull("Could not create rm folder", rmFolder);
|
||||||
|
|
||||||
|
rm_Folder = recordFolderService.createRecordFolder(rm_Container, "rm Folder");
|
||||||
|
assertNotNull("Could not create rm folder", rm_Folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user