Search in sources :

Example 96 with SiteInfo

use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddOneFolderTypeToRmSite.

/**
 * Given that we try to add one cm:folder to rm site,
 * Then operation is successful.
 */
@Test
public void testAddOneFolderTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 97 with SiteInfo

use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddNonAcceptedTypeToRmSite.

/**
 * Given that we try to add non allowed type to rm site,
 * Then IntegrityException is thrown.
 */
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    QName type = AlfMock.generateQName();
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
    ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
    when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
    when(mockedChildAssoc.getParentRef()).thenReturn(rmSiteNodeRef);
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 98 with SiteInfo

use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddDODFilePlanTypeToStandardRmSite.

/**
 * Given that we try to add one dod:filePlan to standard rm site,
 * Then IntegrityException is thrown.
 */
@Test(expected = IntegrityException.class)
public void testAddDODFilePlanTypeToStandardRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 99 with SiteInfo

use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddMoreThanTwhoFolderTypeToRmSite.

/**
 * Given that we try to add more than two cm:folder to rm site,
 * Then IntegrityException is thrown.
 */
@Test
public void testAddMoreThanTwhoFolderTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(new ArrayList<ChildAssociationRef>());
    // create first folder
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    // create second cm:folder
    nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
    // create third cm:folder
    nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 100 with SiteInfo

use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.

the class DataLoadSystemTest method loadInPlace.

private void loadInPlace() {
    AuthenticationUtil.runAs(new RunAsWork<Void>() {

        public Void doWork() throws Exception {
            final SiteInfo site = siteService.getSite("test");
            if (site == null) {
                throw new AlfrescoRuntimeException("The collab site test is not present.");
            }
            final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
            if (filePlan == null) {
                Assert.fail("The default RM site is not present.");
            }
            // create users and add to site
            repeatInTransactionBatches(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    // create user
                    String userName = GUID.generate();
                    System.out.println("Creating user " + userName);
                    createPerson(userName, true);
                    // add to collab site
                    siteService.setMembership("test", userName, SiteRole.SiteCollaborator.toString());
                    return null;
                }
            }, USER_COUNT);
            // create content and declare as record
            repeatInTransactionBatches(new RunAsWork<Void>() {

                public Void doWork() throws Exception {
                    // create document
                    NodeRef docLib = siteService.getContainer(site.getShortName(), SiteService.DOCUMENT_LIBRARY);
                    NodeRef document = fileFolderService.create(docLib, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
                    recordService.createRecord(filePlan, document);
                    return null;
                }
            }, INPLACE_RECORD_COUNT);
            return null;
        }
    }, AuthenticationUtil.getAdminUserName());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RunAsWork(org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Aggregations

SiteInfo (org.alfresco.service.cmr.site.SiteInfo)190 NodeRef (org.alfresco.service.cmr.repository.NodeRef)83 Test (org.junit.Test)48 FilterPropString (org.alfresco.repo.node.getchildren.FilterPropString)45 ArrayList (java.util.ArrayList)32 QName (org.alfresco.service.namespace.QName)29 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)27 BaseAlfrescoSpringTest (org.alfresco.util.BaseAlfrescoSpringTest)26 HashMap (java.util.HashMap)22 Serializable (java.io.Serializable)20 RelationshipResourceNotFoundException (org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException)18 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)17 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)17 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)15 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)15 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)14 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)14 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)12 Date (java.util.Date)9 PagingRequest (org.alfresco.query.PagingRequest)9