RM: Inplace filing prototype

* extension of seciruty service to allow management of extended readers
  * extended reader maintained within file plan hierarchy 
  * support ready for removal (ie move) and overlapping of readers in hirearchy (maintained in reference counting map)
  * general rename to "Unfiled Records" rather than "New Records"
  * File plan unfiled records filter
  * Unit tests
  * Correct permissions on created unfiled container (file for admin as per file plan root)
  * record readers dynamic authority applied to file plan components on bootstrap and creation



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/INPLACE@42063 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2012-09-27 07:12:52 +00:00
parent 58bb845f42
commit 6b54f8f9f8
27 changed files with 567 additions and 193 deletions

View File

@@ -0,0 +1,151 @@
package org.alfresco.module.org_alfresco_module_rm.test.service;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Records management security service test.
*
* @author Roy Wetherall
*/
public class NewRecordsManagementSecurityServiceImplTest extends BaseRMTestCase
{
private NodeRef record;
private NodeRef recordToo;
@Override
protected boolean isUserTest()
{
return true;
}
@Override
protected void setupTestDataImpl()
{
super.setupTestDataImpl();
record = utils.createRecord(rmFolder, "record.txt");
recordToo = utils.createRecord(rmFolder, "recordToo.txt");
}
// TODO testGetProtectedAspects
// TODO getProtectedProperties
// TODO bootstrapDefaultRoles
// TODO getRoles
// TODO getRolesByUser
// TODO getRole
// TODO existsRole
// TODO hasRMAdminRole
// TODO createRole
// TODO updateRole
// TODO deleteRole
// TODO assignRoleToAuthority
// TODO setPermission
// TODO deletePermission
public void testExtendedReaders()
{
doTestInTransaction(new Test<Void>()
{
public Void run()
{
assertFalse(hasExtendedReadersAspect(filePlan));
assertFalse(hasExtendedReadersAspect(rmContainer));
assertFalse(hasExtendedReadersAspect(rmFolder));
assertFalse(hasExtendedReadersAspect(record));
assertNull(securityService.getExtendedReaders(record));
Set<String> extendedReaders = new HashSet<String>(2);
extendedReaders.add("monkey");
extendedReaders.add("elephant");
securityService.setExtendedReaders(record, extendedReaders);
Map<String, Integer> testMap = new HashMap<String, Integer>(2);
testMap.put("monkey", Integer.valueOf(1));
testMap.put("elephant", Integer.valueOf(1));
test(filePlan, testMap);
test(rmContainer, testMap);
test(rmFolder, testMap);
test(record, testMap);
Set<String> extendedReadersToo = new HashSet<String>(2);
extendedReadersToo.add("monkey");
extendedReadersToo.add("snake");
securityService.setExtendedReaders(recordToo, extendedReadersToo);
Map<String, Integer> testMapToo = new HashMap<String, Integer>(2);
testMapToo.put("monkey", Integer.valueOf(1));
testMapToo.put("snake", Integer.valueOf(1));
Map<String, Integer> testMapThree = new HashMap<String, Integer>(3);
testMapThree.put("monkey", Integer.valueOf(2));
testMapThree.put("elephant", Integer.valueOf(1));
testMapThree.put("snake", Integer.valueOf(1));
test(filePlan, testMapThree);
test(rmContainer, testMapThree);
test(rmFolder, testMapThree);
test(recordToo, testMapToo);
return null;
}
private boolean hasExtendedReadersAspect(NodeRef nodeRef)
{
return nodeService.hasAspect(nodeRef, ASPECT_EXTENDED_READERS);
}
private void test(NodeRef nodeRef, Map<String, Integer> testMap)
{
assertTrue(hasExtendedReadersAspect(nodeRef));
Map<String, Integer> readersMap = (Map<String,Integer>)nodeService.getProperty(nodeRef, PROP_READERS);
assertNotNull(readersMap);
assertEquals(testMap.size(), readersMap.size());
for (Map.Entry<String, Integer> entry: testMap.entrySet())
{
assertTrue(readersMap.containsKey(entry.getKey()));
assertEquals(entry.getValue(), readersMap.get(entry.getKey()));
}
Set<String> readers = securityService.getExtendedReaders(nodeRef);
assertNotNull(readers);
assertEquals(testMap.size(), readers.size());
}
});
}
// TODO getExtendedReaders
// TODO setExtendedReaders
// TODO removeExtendedReaders
// TODO removeAllExtendedReaders
}

View File

@@ -20,8 +20,9 @@ package org.alfresco.module.org_alfresco_module_rm.test.service;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.permission.RecordReadersDynamicAuthority;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.site.SiteModel;
@@ -132,8 +133,6 @@ public class RecordServiceTestImpl extends BaseRMTestCase
{
public Void run()
{
//assertFalse(rmService.isRecord(dmDocument));
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
assertEquals(AccessStatus.DENIED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
@@ -149,6 +148,14 @@ public class RecordServiceTestImpl extends BaseRMTestCase
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
assertTrue(rmService.isRecord(dmDocument));
//
Capability createCapability = capabilityService.getCapability("Create");
assertNotNull(createCapability);
createCapability.evaluate(dmDocument);
};
},
dmUserName);

View File

@@ -56,7 +56,7 @@ import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
/**
* Event service implementation unit test
* Security service implementation unit test
*
* @author Roy Wetherall
*/

View File

@@ -49,6 +49,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
@@ -104,6 +105,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected PersonService personService;
protected TransactionService transactionService;
protected FileFolderService fileFolderService;
protected PermissionService permissionService;
/** RM Services */
protected RecordsManagementService rmService;
@@ -260,6 +262,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
personService = (PersonService)this.applicationContext.getBean("PersonService");
transactionService = (TransactionService)applicationContext.getBean("TransactionService");
fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
permissionService = (PermissionService)applicationContext.getBean("PermissionService");
// Get RM services
rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
@@ -329,15 +332,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
setupTestDataImpl();
return null;
}
// check that the new records container has been created for the file plan
public void test(Void arg0) throws Exception
{
// NodeRef newRecordsContainer = recordService.getNewRecordContainer(filePlan);
// assertNotNull(newRecordsContainer);
// assertEquals(TYPE_NEW_RECORDS_CONTAINER, nodeService.getType(newRecordsContainer));
};
},
AuthenticationUtil.getSystemUserName());
}