mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-572 - Refactor: Filling action logic moved to Record Service
* file and setup folder action removed in favour of services * disposition action methods consolidated in disposition service * vital record action methods consolidated in vital record service * unit test updates * other code fallout git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@44783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.test;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.BootstraptestDataRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.DataSetRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.DispositionRestApiTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.EventRestApiTest;
|
||||
@@ -46,7 +45,6 @@ public class WebScriptTestSuite extends TestSuite
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTestSuite(BootstraptestDataRestApiTest.class);
|
||||
suite.addTestSuite(DispositionRestApiTest.class);
|
||||
suite.addTestSuite(EventRestApiTest.class);
|
||||
suite.addTestSuite(RMCaveatConfigScriptTest.class);
|
||||
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.action;
|
||||
|
||||
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.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
|
||||
/**
|
||||
* Record service implementation unit test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CreateRecordActionTest extends BaseRMTestCase
|
||||
{
|
||||
/** Services */
|
||||
protected ActionService dmActionService;
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService)applicationContext.getBean("ActionService");
|
||||
dmPermissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void testCreateRecordAction()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
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(recordService.isRecord(dmDocument));
|
||||
};
|
||||
},
|
||||
dmCollaborator);
|
||||
}
|
||||
}
|
@@ -95,9 +95,9 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
Group auditGroup = capabilityService.getGroup("audit");
|
||||
assertNotNull(auditGroup);
|
||||
assertTrue(auditGroup.getIndex() == 1);
|
||||
assertTrue(auditGroup.getTitle().equalsIgnoreCase("Audit"));
|
||||
assertTrue(auditGroup.getId().equalsIgnoreCase("audit"));
|
||||
assertEquals(10, auditGroup.getIndex());
|
||||
assertEquals("Audit", auditGroup.getTitle());
|
||||
assertEquals("audit", auditGroup.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
GroupImpl testGroup = new GroupImpl();
|
||||
testGroup.setId("testGroup");
|
||||
testGroup.setIndex(14);
|
||||
testGroup.setIndex(140);
|
||||
testGroup.setTitle("Test group");
|
||||
capabilityService.addGroup(testGroup);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
assertNotNull(group);
|
||||
assertTrue(group.getId().equalsIgnoreCase("testGroup"));
|
||||
assertTrue(group.getTitle().equalsIgnoreCase("Test group"));
|
||||
assertTrue(group.getIndex() == 14);
|
||||
assertTrue(group.getIndex() == 140);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -152,21 +152,15 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
int size = groups.size();
|
||||
assertTrue(size == 13);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
assertNotNull(groups.get(i));
|
||||
assertTrue(groups.get(i).getIndex() == (i + 1));
|
||||
}
|
||||
|
||||
Group auditGroup = groups.get(0);
|
||||
assertNotNull(auditGroup);
|
||||
assertTrue(auditGroup.getIndex() == 1);
|
||||
assertTrue(auditGroup.getIndex() == 10);
|
||||
assertTrue(auditGroup.getId().equalsIgnoreCase("audit"));
|
||||
assertTrue(auditGroup.getTitle().equalsIgnoreCase("Audit"));
|
||||
|
||||
Group vitalRecords = groups.get(size - 1);
|
||||
assertNotNull(vitalRecords);
|
||||
assertTrue(vitalRecords.getIndex() == 13);
|
||||
assertTrue(vitalRecords.getIndex() == 130);
|
||||
assertTrue(vitalRecords.getId().equalsIgnoreCase("vitalRecords"));
|
||||
assertTrue(vitalRecords.getTitle().equalsIgnoreCase("Vital Records"));
|
||||
|
||||
@@ -194,11 +188,11 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
int vitalRecordCapabilitiesSize = auditCapabilities.size();
|
||||
assertTrue(vitalRecordCapabilitiesSize == 6);
|
||||
|
||||
for (int i = 0; i < vitalRecordCapabilitiesSize; i++)
|
||||
for (int i = 1; i == vitalRecordCapabilitiesSize; i++)
|
||||
{
|
||||
Capability capability = auditCapabilities.get(i);
|
||||
assertNotNull(capability);
|
||||
assertTrue(capability.getIndex() == (i + 1));
|
||||
assertEquals(i * 10, capability.getIndex());
|
||||
}
|
||||
|
||||
Group vitalRecordsGroup = groups.get(groups.size() - 1);
|
||||
@@ -208,14 +202,7 @@ public class CapabilityServiceImplTest extends BaseRMTestCase
|
||||
assertNotNull(vitalRecordCapabilities);
|
||||
|
||||
vitalRecordCapabilitiesSize = vitalRecordCapabilities.size();
|
||||
assertTrue(vitalRecordCapabilitiesSize == 3);
|
||||
|
||||
for (int i = 0; i < vitalRecordCapabilitiesSize; i++)
|
||||
{
|
||||
Capability capability = vitalRecordCapabilities.get(i);
|
||||
assertNotNull(capability);
|
||||
assertTrue(capability.getIndex() == (i + 1));
|
||||
}
|
||||
assertEquals(3, vitalRecordCapabilitiesSize);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.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 CreateRecordActionTest 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()
|
||||
{
|
||||
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(recordService.isRecord(dmDocument));
|
||||
};
|
||||
},
|
||||
dmUserName);
|
||||
}
|
||||
}
|
@@ -22,26 +22,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
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.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Records Service Implementation Test
|
||||
@@ -52,35 +45,20 @@ import org.alfresco.util.GUID;
|
||||
*/
|
||||
public class RecordServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
/** Services */
|
||||
protected ActionService dmActionService;
|
||||
|
||||
protected TaggingService taggingService;
|
||||
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
protected PermissionService dmPermissionService;
|
||||
protected ExtendedSecurityService extendedSecurityService;
|
||||
|
||||
// collaboration site artifacts
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
// dm users
|
||||
protected String dmConsumer;
|
||||
protected NodeRef dmConsumerNodeRef;
|
||||
protected String dmCollaborator;
|
||||
protected NodeRef dmCollaboratorNodeRef;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
|
||||
*/
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
dmActionService = (ActionService) applicationContext.getBean("ActionService");
|
||||
taggingService = (TaggingService) applicationContext.getBean("TaggingService");
|
||||
dmPermissionService = (PermissionService) applicationContext.getBean("PermissionService");
|
||||
extendedSecurityService = (ExtendedSecurityService) applicationContext.getBean("ExtendedSecurityService");
|
||||
}
|
||||
@@ -106,64 +84,14 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup the collaboration site test data
|
||||
* This is a collaboration site test
|
||||
*/
|
||||
@Override
|
||||
protected void setupTestData()
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
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);
|
||||
|
||||
dmConsumer = GUID.generate();
|
||||
dmConsumerNodeRef = createPerson(dmConsumer);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmConsumer, SiteModel.SITE_CONSUMER);
|
||||
|
||||
dmCollaborator = GUID.generate();
|
||||
dmCollaboratorNodeRef = createPerson(dmCollaborator);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmCollaborator, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDownImpl()
|
||||
{
|
||||
super.tearDownImpl();
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,9 +257,89 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
return null;
|
||||
}
|
||||
}, dmCollaborator);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void testFileNewContent() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
NodeRef record = fileFolderService.create(rmFolder, "test101.txt" , TYPE_CONTENT).getNodeRef();
|
||||
|
||||
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("hello world this is some test content");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFileUnfiledrecord() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
recordService.createRecord(filePlan, dmDocument);
|
||||
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
assertFalse(recordService.isFiled(dmDocument));
|
||||
|
||||
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
|
||||
|
||||
fileFolderService.move(dmDocument, rmFolder, "record.txt");
|
||||
|
||||
return dmDocument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFileDirectlyFromCollab() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
|
||||
|
||||
fileFolderService.move(dmDocument, rmFolder, "record.txt");
|
||||
|
||||
return dmDocument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertTrue(recordService.isRecord(record));
|
||||
assertTrue(recordService.isFiled(record));
|
||||
|
||||
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkPermissions(String permission, AccessStatus filePlanExpected,
|
||||
|
@@ -23,8 +23,10 @@ import java.util.Date;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Period;
|
||||
import org.alfresco.util.GUID;
|
||||
@@ -48,6 +50,15 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
|
||||
private NodeRef mhRecord54;
|
||||
private NodeRef mhRecord55;
|
||||
|
||||
/**
|
||||
* Indicate this test uses the collaboration site test data
|
||||
*/
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Indicate this is a multi hierarchy test */
|
||||
@Override
|
||||
protected boolean isMultiHierarchyTest()
|
||||
@@ -212,6 +223,75 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
|
||||
});
|
||||
}
|
||||
|
||||
/** Filling tests */
|
||||
|
||||
public void testFileNewContent() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef();
|
||||
|
||||
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("hello world this is some test content");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// public void testFileUnfiledrecord() throws Exception
|
||||
// {
|
||||
// doTestInTransaction(new Test<NodeRef>()
|
||||
// {
|
||||
// @Override
|
||||
// public NodeRef run() throws Exception
|
||||
// {
|
||||
// recordService.createRecord(filePlan, dmDocument);
|
||||
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
|
||||
//
|
||||
// return dmDocument;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void test(NodeRef record) throws Exception
|
||||
// {
|
||||
// assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public void testFileDirectlyFromCollab() throws Exception
|
||||
// {
|
||||
// doTestInTransaction(new Test<NodeRef>()
|
||||
// {
|
||||
// @Override
|
||||
// public NodeRef run() throws Exception
|
||||
// {
|
||||
// fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt");
|
||||
// return dmDocument;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void test(NodeRef record) throws Exception
|
||||
// {
|
||||
// assertVitalRecord(record, true, PERIOD_WEEK);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/** Helper Methods */
|
||||
|
||||
/**
|
||||
* Test to ensure that changes made to vital record definitions are reflected down the hierarchy.
|
||||
*/
|
||||
|
@@ -29,18 +29,20 @@ import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposableitem.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RmSiteType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.site.SiteServiceImpl;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -57,6 +59,7 @@ import org.alfresco.service.cmr.security.PersonService;
|
||||
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.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
@@ -81,15 +84,16 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
};
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
/** Test model contants */
|
||||
/** test model constants */
|
||||
protected String URI = "http://www.alfresco.org/model/rmtest/1.0";
|
||||
protected String PREFIX = "rmt";
|
||||
protected QName TYPE_CUSTOM_TYPE = QName.createQName(URI, "customType");
|
||||
protected QName ASPECT_CUSTOM_ASPECT = QName.createQName(URI, "customAspect");
|
||||
protected QName ASPECT_RECORD_META_DATA = QName.createQName(URI, "recordMetaData");
|
||||
|
||||
/** Site id */
|
||||
/** site id's */
|
||||
protected static final String SITE_ID = "mySite";
|
||||
protected static final String COLLABORATION_SITE_ID = "collab-site-id";
|
||||
|
||||
/** Common test utils */
|
||||
protected CommonRMTestUtils utils;
|
||||
@@ -109,6 +113,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected TransactionService transactionService;
|
||||
protected FileFolderService fileFolderService;
|
||||
protected PermissionService permissionService;
|
||||
protected TaggingService taggingService;
|
||||
|
||||
/** RM Services */
|
||||
protected RecordsManagementService rmService;
|
||||
@@ -214,6 +219,18 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
protected NodeRef recordDeclaredOne;
|
||||
protected NodeRef recordDeclaredTwo;
|
||||
|
||||
/** collaboration site artifacts */
|
||||
protected SiteInfo collaborationSite;
|
||||
protected NodeRef documentLibrary;
|
||||
protected NodeRef dmFolder;
|
||||
protected NodeRef dmDocument;
|
||||
|
||||
/** collaboration site users */
|
||||
protected String dmConsumer;
|
||||
protected NodeRef dmConsumerNodeRef;
|
||||
protected String dmCollaborator;
|
||||
protected NodeRef dmCollaboratorNodeRef;
|
||||
|
||||
/**
|
||||
* Indicates whether this is a multi-hierarchy test or not. If it is then the multi-hierarchy record
|
||||
* taxonomy test data is loaded.
|
||||
@@ -248,6 +265,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the test collaboration site should be created
|
||||
* or not.
|
||||
*/
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@@ -263,17 +289,26 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
|
||||
// Setup test data
|
||||
setupTestData();
|
||||
|
||||
// Create multi hierarchy data
|
||||
if (isMultiHierarchyTest() == true)
|
||||
{
|
||||
setupMultiHierarchyTestData();
|
||||
}
|
||||
}
|
||||
|
||||
// Create collaboration data
|
||||
if (isCollaborationSiteTest() == true)
|
||||
{
|
||||
setupCollaborationSiteTestData();
|
||||
}
|
||||
|
||||
// Create the users here
|
||||
if (isUserTest() == true)
|
||||
{
|
||||
setupTestUsers(filePlan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the service beans.
|
||||
*/
|
||||
@@ -294,6 +329,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
transactionService = (TransactionService)applicationContext.getBean("TransactionService");
|
||||
fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
|
||||
permissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
taggingService = (TaggingService)applicationContext.getBean("TaggingService");
|
||||
|
||||
// Get RM services
|
||||
rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
|
||||
@@ -342,6 +378,12 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
|
||||
// Delete the site
|
||||
siteService.deleteSite(SITE_ID);
|
||||
|
||||
// delete the collaboration site (if required)
|
||||
if (isCollaborationSiteTest() == true)
|
||||
{
|
||||
siteService.deleteSite(COLLABORATION_SITE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,6 +615,45 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
mhRecordFolder45 = rmService.createRecordFolder(mhContainer35, "mhFolder45");
|
||||
}
|
||||
|
||||
protected void setupCollaborationSiteTestData()
|
||||
{
|
||||
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();
|
||||
|
||||
dmConsumer = GUID.generate();
|
||||
dmConsumerNodeRef = createPerson(dmConsumer);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmConsumer, SiteModel.SITE_CONSUMER);
|
||||
|
||||
dmCollaborator = GUID.generate();
|
||||
dmCollaboratorNodeRef = createPerson(dmCollaborator);
|
||||
siteService.setMembership(COLLABORATION_SITE_ID, dmCollaborator, SiteModel.SITE_COLLABORATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to try and simplify {@link Void} tests.
|
||||
*
|
||||
|
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.BootstrapTestDataGet;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
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.PermissionService;
|
||||
import org.alfresco.service.cmr.view.ImporterBinding;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* This class is an initial placeholder for miscellaneous helper methods used in
|
||||
* the testing or test initialisation of the DOD5015 module.
|
||||
*
|
||||
* @author neilm
|
||||
*/
|
||||
public class TestUtilities implements RecordsManagementModel
|
||||
{
|
||||
public static NodeRef loadFilePlanData(ApplicationContext applicationContext)
|
||||
{
|
||||
return TestUtilities.loadFilePlanData(applicationContext, true, false);
|
||||
}
|
||||
|
||||
public static final String TEST_FILE_PLAN_NAME = "testUtilities.filePlan";
|
||||
|
||||
private static NodeRef getFilePlan(NodeService nodeService, NodeRef rootNode)
|
||||
{
|
||||
NodeRef filePlan = null;
|
||||
|
||||
// Try and find a file plan hanging from the root node
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(rootNode, ContentModel.ASSOC_CHILDREN, TYPE_FILE_PLAN);
|
||||
if (assocs.size() != 0)
|
||||
{
|
||||
filePlan = assocs.get(0).getChildRef();
|
||||
}
|
||||
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
public static NodeRef loadFilePlanData(ApplicationContext applicationContext, boolean patchData, boolean alwaysLoad)
|
||||
{
|
||||
NodeService nodeService = (NodeService)applicationContext.getBean("NodeService");
|
||||
AuthorityService authorityService = (AuthorityService)applicationContext.getBean("AuthorityService");
|
||||
PermissionService permissionService = (PermissionService)applicationContext.getBean("PermissionService");
|
||||
SearchService searchService = (SearchService)applicationContext.getBean("SearchService");
|
||||
ImporterService importerService = (ImporterService)applicationContext.getBean("importerComponent");
|
||||
RecordsManagementService recordsManagementService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService");
|
||||
RecordsManagementActionService recordsManagementActionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService");
|
||||
RecordsManagementSecurityService recordsManagementSecurityService = (RecordsManagementSecurityService)applicationContext.getBean("RecordsManagementSecurityService");
|
||||
RecordsManagementSearchBehaviour recordsManagementSearchBehaviour = (RecordsManagementSearchBehaviour)applicationContext.getBean("recordsManagementSearchBehaviour");
|
||||
DispositionService dispositionService = (DispositionService)applicationContext.getBean("DispositionService");
|
||||
|
||||
NodeRef filePlan = null;
|
||||
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
|
||||
if (alwaysLoad == false && getFilePlan(nodeService, rootNode) != null)
|
||||
{
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
// For now creating the filePlan beneath the
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||
props.put(ContentModel.PROP_NAME, TEST_FILE_PLAN_NAME);
|
||||
filePlan = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN,
|
||||
TYPE_FILE_PLAN,
|
||||
TYPE_FILE_PLAN,
|
||||
props).getChildRef();
|
||||
|
||||
// Do the data load into the the provided filePlan node reference
|
||||
// TODO ...
|
||||
InputStream is = TestUtilities.class.getClassLoader().getResourceAsStream(
|
||||
"alfresco/module/org_alfresco_module_rm/dod5015/DODExampleFilePlan.xml");
|
||||
//"alfresco/module/org_alfresco_module_rm/bootstrap/temp.xml");
|
||||
Assert.assertNotNull("The DODExampleFilePlan.xml import file could not be found", is);
|
||||
Reader viewReader = new InputStreamReader(is);
|
||||
Location location = new Location(filePlan);
|
||||
importerService.importView(viewReader, location, REPLACE_BINDING, null);
|
||||
|
||||
if (patchData == true)
|
||||
{
|
||||
// Tempory call out to patch data after AMP
|
||||
BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService,
|
||||
recordsManagementActionService, permissionService,
|
||||
authorityService, recordsManagementSecurityService,
|
||||
recordsManagementSearchBehaviour,
|
||||
dispositionService);
|
||||
}
|
||||
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordSeries(RecordsManagementService rmService, NodeService nodeService, String seriesName)
|
||||
{
|
||||
NodeRef result = null;
|
||||
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
NodeRef filePlan = getFilePlan(nodeService, rootNode);
|
||||
|
||||
if (filePlan != null)
|
||||
{
|
||||
result = nodeService.getChildByName(filePlan, ContentModel.ASSOC_CONTAINS, seriesName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordCategory(RecordsManagementService rmService, NodeService nodeService, String seriesName, String categoryName)
|
||||
{
|
||||
NodeRef seriesNodeRef = getRecordSeries(rmService, nodeService, seriesName);
|
||||
|
||||
NodeRef result = null;
|
||||
if (seriesNodeRef != null)
|
||||
{
|
||||
result = nodeService.getChildByName(seriesNodeRef, ContentModel.ASSOC_CONTAINS, categoryName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static NodeRef getRecordFolder(RecordsManagementService rmService, NodeService nodeService, String seriesName, String categoryName, String folderName)
|
||||
{
|
||||
NodeRef categoryNodeRef = getRecordCategory(rmService, nodeService, seriesName, categoryName);
|
||||
|
||||
NodeRef result = null;
|
||||
if (categoryNodeRef != null)
|
||||
{
|
||||
result = nodeService.getChildByName(categoryNodeRef, ContentModel.ASSOC_CONTAINS, folderName);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO .. do we need to redeclare this here ??
|
||||
private static ImporterBinding REPLACE_BINDING = new ImporterBinding()
|
||||
{
|
||||
|
||||
public UUID_BINDING getUUIDBinding()
|
||||
{
|
||||
return UUID_BINDING.REPLACE_EXISTING;
|
||||
}
|
||||
|
||||
public String getValue(String key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean allowReferenceWithinTransaction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public QName[] getExcludedClasses()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static void declareRecord(NodeRef recordToDeclare, NodeService nodeService,
|
||||
RecordsManagementActionService rmActionService)
|
||||
{
|
||||
// Declare record
|
||||
Map<QName, Serializable> propValues = nodeService.getProperties(recordToDeclare);
|
||||
propValues.put(RecordsManagementModel.PROP_PUBLICATION_DATE, new Date());
|
||||
List<String> smList = new ArrayList<String>(2);
|
||||
// smList.add(DOD5015Test.FOUO);
|
||||
// smList.add(DOD5015Test.NOFORN);
|
||||
propValues.put(RecordsManagementModel.PROP_SUPPLEMENTAL_MARKING_LIST, (Serializable)smList);
|
||||
propValues.put(RecordsManagementModel.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||
propValues.put(RecordsManagementModel.PROP_FORMAT, "formatValue");
|
||||
propValues.put(RecordsManagementModel.PROP_DATE_RECEIVED, new Date());
|
||||
propValues.put(RecordsManagementModel.PROP_ORIGINATOR, "origValue");
|
||||
propValues.put(RecordsManagementModel.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
||||
propValues.put(ContentModel.PROP_TITLE, "titleValue");
|
||||
nodeService.setProperties(recordToDeclare, propValues);
|
||||
rmActionService.executeRecordsManagementAction(recordToDeclare, "declareRecord");
|
||||
}
|
||||
}
|
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.webscript;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.TestUtilities;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||
|
||||
/**
|
||||
* This class tests the Rest API for disposition related operations
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class BootstraptestDataRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel
|
||||
{
|
||||
protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||
protected static final String URL = "/api/rma/bootstraptestdata";
|
||||
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
||||
protected static final String APPLICATION_JSON = "application/json";
|
||||
|
||||
protected NodeService nodeService;
|
||||
protected RetryingTransactionHelper transactionHelper;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService");
|
||||
transactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper");
|
||||
}
|
||||
|
||||
public void testBoostrapTestData() throws Exception
|
||||
{
|
||||
final NodeRef filePlan = transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||
return TestUtilities.loadFilePlanData(getServer().getApplicationContext(), false, true);
|
||||
}
|
||||
});
|
||||
|
||||
sendRequest(new GetRequest(URL), 200);
|
||||
|
||||
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||
nodeService.deleteNode(filePlan);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user