mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'remotes/origin/feature/RM-5617_ClassifyCompleteRecords_API_Tests_no' into feature/RM-5787_ClassifyInPlaceRecord_API_Tests_no
This commit is contained in:
@@ -33,6 +33,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE;
|
||||
@@ -529,6 +530,35 @@ public class BaseRMRestTest extends RestTest
|
||||
Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
|
||||
return recordFolderAPI.createRecord(recordModel, parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a non-electronic record
|
||||
*
|
||||
* @param parentId the id of the parent
|
||||
* @param name the name of the record
|
||||
* @return the created record
|
||||
* @throws Exception
|
||||
*/
|
||||
public Record createNonElectronicRecord(String parentId, String name) throws Exception
|
||||
{
|
||||
return createNonElectronicRecord(parentId, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a non-electronic record
|
||||
*
|
||||
* @param parentId the id of the parent
|
||||
* @param name the name of the record
|
||||
* @return the created record
|
||||
* @throws Exception
|
||||
*/
|
||||
public Record createNonElectronicRecord(String parentId, String name, UserModel user) throws Exception
|
||||
{
|
||||
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user);
|
||||
Record recordModel = Record.builder().name(name).nodeType(NON_ELECTRONIC_RECORD_TYPE).build();
|
||||
return recordFolderAPI.createRecord(recordModel, parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record folder
|
||||
*
|
||||
|
@@ -155,7 +155,10 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
public Void doWork()
|
||||
{
|
||||
// setup vital record definition
|
||||
if(nodeService.exists(child))
|
||||
{
|
||||
vitalRecordService.setupVitalRecordDefinition(child);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -190,7 +193,10 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
public Void doWork()
|
||||
{
|
||||
// setup record category permissions
|
||||
if(nodeService.exists(childAssocRef.getChildRef()))
|
||||
{
|
||||
filePlanPermissionService.setupRecordCategoryPermissions(childAssocRef.getChildRef());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ 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.report.ReportService;
|
||||
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.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
@@ -173,6 +174,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected InplaceRecordService inplaceRecordService;
|
||||
protected RelationshipService relationshipService;
|
||||
|
||||
/** test utils */
|
||||
protected UserAndGroupsUtils userAndGroupsUtils;
|
||||
|
||||
/** test data */
|
||||
protected String siteId;
|
||||
protected StoreRef storeRef;
|
||||
@@ -340,6 +344,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
// Get the application context
|
||||
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||
utils = new CommonRMTestUtils(applicationContext);
|
||||
userAndGroupsUtils = new UserAndGroupsUtils(applicationContext);
|
||||
|
||||
// Initialise the service beans
|
||||
initServices();
|
||||
|
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.util;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Test utils class containing methods for managing user, groups and roles
|
||||
*
|
||||
* @author Ana Manolache
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UserAndGroupsUtils
|
||||
{
|
||||
protected FilePlanRoleService filePlanRoleService;
|
||||
protected AuthorityService authorityService;
|
||||
|
||||
/**
|
||||
* @param applicationContext the application context
|
||||
*/
|
||||
public UserAndGroupsUtils(ApplicationContext applicationContext)
|
||||
{
|
||||
filePlanRoleService = (FilePlanRoleService) applicationContext.getBean("FilePlanRoleService");
|
||||
authorityService = (AuthorityService) applicationContext.getBean("AuthorityService");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to an RM role
|
||||
*
|
||||
* @param userName the username of the user to add to the role
|
||||
* @param role the role to add the user to
|
||||
*/
|
||||
public void addUserToRole(NodeRef filePlan, String userName, RMRole role)
|
||||
{
|
||||
// Find the authority for the given role
|
||||
Role roleObj = filePlanRoleService.getRole(filePlan, role.getGroupName());
|
||||
assertNotNull("Notification role " + role.getGroupName() + " could not be retrieved", roleObj);
|
||||
String roleGroup = roleObj.getRoleGroupName();
|
||||
assertNotNull("Notification role group " + roleGroup + " can not be null.", roleGroup);
|
||||
|
||||
// Add user to notification role group
|
||||
authorityService.addAuthority(roleGroup, userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* An enum of RM Roles
|
||||
*/
|
||||
public enum RMRole
|
||||
{
|
||||
RM_ADMINISTRATOR("Administrator"),
|
||||
RM_MANAGER("RecordsManager"),
|
||||
RM_POWER_USER("PowerUser"),
|
||||
RM_SECURITY_OFFICER("SecurityOfficer"),
|
||||
RM_USER("User");
|
||||
|
||||
private String groupName;
|
||||
|
||||
private RMRole(String groupName)
|
||||
{
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public String getGroupName()
|
||||
{
|
||||
return this.groupName;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user