mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM: In-place filing prototype WIP
* dynamic authority set ReadRecord permission on new record and ViewRecord capability on containing file plan * dynamic 'Record Readers' authority working correctly (checking whether current user is contained in the users/groups snap shoted as readers when the document was made a record) * unit test showing document in collab site being made a record and the existing collab user having record read permissions without being added to the RM site or given an RM role. * this check-in is sufficient to demonstrate that collaboration users can create records and view them without having to introduce any form of noticable mapping between the RM and Collab sites. (relates to RM-485) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/INPLACE@41708 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
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.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.permission.RecordReadersDynamicAuthority;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Record service implementation unit test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordServiceTestImpl extends BaseRMTestCase
|
||||
{
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
protected ActionService dmActionService;
|
||||
protected TaggingService taggingService;
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
protected String dmUserName;
|
||||
protected NodeRef dmUserPerson;
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService)applicationContext.getBean("ActionService");
|
||||
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
|
||||
dmPermissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTestData()
|
||||
{
|
||||
super.setupTestData();
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
setupCollaborationSiteTestDataImpl();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestDataImpl()
|
||||
{
|
||||
// create collaboration site
|
||||
collaborationSite = siteService.createSite("preset", COLLABORATION_SITE_ID, "title", "description", SiteVisibility.PRIVATE);
|
||||
documentLibrary = SiteServiceImpl.getSiteContainer(
|
||||
COLLABORATION_SITE_ID,
|
||||
SiteService.DOCUMENT_LIBRARY,
|
||||
true,
|
||||
siteService,
|
||||
transactionService,
|
||||
taggingService);
|
||||
|
||||
assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary);
|
||||
|
||||
// create a folder and documents
|
||||
dmFolder = fileFolderService.create(documentLibrary, "collabFolder", ContentModel.TYPE_FOLDER).getNodeRef();
|
||||
dmDocument = fileFolderService.create(dmFolder, "collabDocument.txt", ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTestUsersImpl(NodeRef filePlan)
|
||||
{
|
||||
super.setupTestUsersImpl(filePlan);
|
||||
|
||||
dmUserName = GUID.generate();
|
||||
dmUserPerson = createPerson(dmUserName);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmUserName, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDownImpl()
|
||||
{
|
||||
super.tearDownImpl();
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
}
|
||||
|
||||
public void testCreateRecordAction()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
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));
|
||||
|
||||
Action action = dmActionService.createAction(CreateRecordAction.NAME);
|
||||
dmActionService.executeAction(action, dmDocument);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test(Void result) throws Exception
|
||||
{
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(dmDocument, RMPermissionModel.READ_RECORDS));
|
||||
assertEquals(AccessStatus.ALLOWED, dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
|
||||
|
||||
assertTrue(rmService.isRecord(dmDocument));
|
||||
};
|
||||
},
|
||||
dmUserName);
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.test.service;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
@@ -612,46 +611,6 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
|
||||
|
||||
// TODO void testGetRecordFolders(NodeRef record);
|
||||
|
||||
// TODO void testIsRecordDeclared(NodeRef nodeRef);
|
||||
|
||||
public void testGetNewRecordsContainer()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
NodeRef result1 = recordService.getNewRecordContainer(filePlan);
|
||||
assertNotNull(result1);
|
||||
assertEquals(TYPE_NEW_RECORDS_CONTAINER, nodeService.getType(result1));
|
||||
|
||||
assertNull(recordService.getNewRecordContainer(rmContainer));
|
||||
assertNull(recordService.getNewRecordContainer(rmFolder));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Failure: File plan with no new record container
|
||||
doTestInTransaction(new FailureTest
|
||||
(
|
||||
"The newly created file plan shouldn't yet have a new record container.",
|
||||
AlfrescoRuntimeException.class
|
||||
)
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
NodeRef newFilePlan = rmService.createFilePlan(folder, GUID.generate());
|
||||
recordService.getNewRecordContainer(newFilePlan);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testCreateRecord()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/********** RM2 - Multi-hierarchy record taxonomy's **********/
|
||||
|
||||
|
@@ -333,9 +333,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
// 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));
|
||||
// NodeRef newRecordsContainer = recordService.getNewRecordContainer(filePlan);
|
||||
// assertNotNull(newRecordsContainer);
|
||||
// assertEquals(TYPE_NEW_RECORDS_CONTAINER, nodeService.getType(newRecordsContainer));
|
||||
|
||||
};
|
||||
},
|
||||
|
Reference in New Issue
Block a user