Search in sources :

Example 11 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class FilePlanComponentsApiUtils method postActivity.

/**
 * Posts activities for given fileInfo
 *
 * @param fileInfo
 * @param parentNodeRef
 * @param activityType
 */
public void postActivity(FileInfo fileInfo, NodeRef parentNodeRef, String activityType) {
    ActivityInfo activityInfo = null;
    RMSite rmSite = sites.getRMSite(RM_SITE_ID);
    if (rmSite != null && !rmSite.getId().equals("")) {
        if (fileInfo != null) {
            boolean isContent = dictionaryService.isSubClass(fileInfo.getType(), ContentModel.TYPE_CONTENT);
            if (isContent) {
                activityInfo = new ActivityInfo(null, parentNodeRef, RM_SITE_ID, fileInfo);
            }
        }
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Non-site activity, so ignored " + fileInfo.getNodeRef());
        }
    }
    if (activityInfo == null)
        // Nothing to do.
        return;
    if (activityType != null) {
        activityPoster.postFileFolderActivity(activityType, null, TenantUtil.getCurrentDomain(), activityInfo.getSiteId(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(), activityInfo.getFileName(), Activities.APP_TOOL, Activities.RESTAPI_CLIENT, activityInfo.getFileInfo());
    }
}
Also used : ActivityInfo(org.alfresco.service.cmr.activities.ActivityInfo) RMSite(org.alfresco.rm.rest.api.model.RMSite)

Example 12 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSitesImplUnitTest method createRMStandardSite.

@Test
public void createRMStandardSite() throws Exception {
    RMSite toCreate = new RMSite();
    toCreate.setTitle(RM_SITE_TITLE);
    toCreate.setDescription(RM_SITE_DESCRIPTION);
    // mocked SiteInfo
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(RM_SITE_ID);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedSiteService.createSite(any(String.class), any(String.class), any(String.class), any(String.class), any(SiteVisibility.class), any(QName.class))).thenReturn(mockedSiteInfo);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call createRMSite method
    RMSite createdRMSite = rmSitesImpl.createRMSite(toCreate, mockedParameters);
    // check siteService.createSite parameters
    ArgumentCaptor<String> sitePresetCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<SiteVisibility> visibilityCaptor = ArgumentCaptor.forClass(SiteVisibility.class);
    ArgumentCaptor<QName> siteTypeCaptor = ArgumentCaptor.forClass(QName.class);
    verify(mockedSiteService, times(1)).createSite(sitePresetCaptor.capture(), idCaptor.capture(), titleCaptor.capture(), descriptionCaptor.capture(), visibilityCaptor.capture(), siteTypeCaptor.capture());
    assertEquals(RM_SITE_PRESET, sitePresetCaptor.getValue());
    assertEquals(RM_SITE_ID, idCaptor.getValue());
    assertEquals(RM_SITE_TITLE, titleCaptor.getValue());
    assertEquals(RM_SITE_DESCRIPTION, descriptionCaptor.getValue());
    assertEquals(SiteVisibility.PUBLIC, visibilityCaptor.getValue());
    assertEquals(RecordsManagementModel.TYPE_RM_SITE, siteTypeCaptor.getValue());
    verify(mockedImporterService, times(1)).importView(any(SiteImportPackageHandler.class), any(Location.class), any(ImporterBinding.class), eq(null));
    verify(mockedSiteService, times(1)).createContainer(RM_SITE_ID, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    verify(mockedFavouritesService, times(1)).addFavourite(any(String.class), any(NodeRef.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.STANDARD, createdRMSite.getCompliance());
    assertEquals(null, createdRMSite.getRole());
    assertEquals(RM_SITE_ID, createdRMSite.getId());
    assertEquals(siteNodeRef.getId(), createdRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, createdRMSite.getDescription());
    assertEquals(RM_SITE_TITLE, createdRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, createdRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) QName(org.alfresco.service.namespace.QName) ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteImportPackageHandler(org.alfresco.rest.api.impl.SiteImportPackageHandler) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) Location(org.alfresco.service.cmr.view.Location) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 13 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSitesImplUnitTest method updateRMSite.

@Test
public void updateRMSite() throws Exception {
    String siteId = RM_SITE_ID;
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    // mock SiteInfo
    when(mockedSiteInfo.getShortName()).thenReturn(siteId);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION).thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE).thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedNodeService.getType(siteNodeRef)).thenReturn(RecordsManagementModel.TYPE_RM_SITE);
    when(mockedSiteService.getSite(siteId)).thenReturn(mockedSiteInfo);
    when(mockedSiteService.getMembersRole(eq(siteId), any(String.class))).thenReturn(RM_SITE_MANAGER_ROLE);
    // mock UpdateSite
    SiteUpdate mockedSiteUpdate = mock(SiteUpdate.class);
    when(mockedSiteUpdate.getDescription()).thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
    when(mockedSiteUpdate.getTitle()).thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
    when(mockedSiteUpdate.getVisibility()).thenReturn(null);
    when(mockedSiteUpdate.wasSet(Site.TITLE)).thenReturn(true);
    when(mockedSiteUpdate.wasSet(Site.DESCRIPTION)).thenReturn(true);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call updateRMSite method
    RMSite updatedRMSite = rmSitesImpl.updateRMSite(siteId, mockedSiteUpdate, mockedParameters);
    // check if the new title is set to siteInfo
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedSiteInfo, times(1)).setTitle(titleCaptor.capture());
    assertEquals(RM_SITE_TITLE_AFTER_UPDATE, titleCaptor.getValue());
    // check that new description is set to siteInfo
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedSiteInfo, times(1)).setDescription(descriptionCaptor.capture());
    assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, descriptionCaptor.getValue());
    // check that site visibility is not changed
    verify(mockedSiteInfo, never()).setVisibility(any(SiteVisibility.class));
    // check that updateSite is called
    verify(mockedSiteService, times(1)).updateSite(any(SiteInfo.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.STANDARD, updatedRMSite.getCompliance());
    assertEquals(RM_SITE_MANAGER_ROLE, updatedRMSite.getRole());
    assertEquals(siteId, updatedRMSite.getId());
    assertEquals(siteNodeRef.getId(), updatedRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, updatedRMSite.getDescription());
    assertEquals(RM_SITE_TITLE_AFTER_UPDATE, updatedRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, updatedRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteUpdate(org.alfresco.rest.api.model.SiteUpdate) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 14 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSitesImplUnitTest method createRMDOD5015Site.

@Test
public void createRMDOD5015Site() throws Exception {
    RMSite toCreate = new RMSite();
    toCreate.setTitle(RM_SITE_TITLE);
    toCreate.setDescription(RM_SITE_DESCRIPTION);
    toCreate.setCompliance(RMSiteCompliance.DOD5015);
    // mocked SiteInfo
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(RM_SITE_ID);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedSiteService.createSite(any(String.class), any(String.class), any(String.class), any(String.class), any(SiteVisibility.class), any(QName.class))).thenReturn(mockedSiteInfo);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call createRMSite method
    RMSite createdRMSite = rmSitesImpl.createRMSite(toCreate, mockedParameters);
    // check siteService.createSite parameters
    ArgumentCaptor<String> sitePresetCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<SiteVisibility> visibilityCaptor = ArgumentCaptor.forClass(SiteVisibility.class);
    ArgumentCaptor<QName> siteTypeCaptor = ArgumentCaptor.forClass(QName.class);
    verify(mockedSiteService, times(1)).createSite(sitePresetCaptor.capture(), idCaptor.capture(), titleCaptor.capture(), descriptionCaptor.capture(), visibilityCaptor.capture(), siteTypeCaptor.capture());
    assertEquals(RM_SITE_PRESET, sitePresetCaptor.getValue());
    assertEquals(RM_SITE_ID, idCaptor.getValue());
    assertEquals(RM_SITE_TITLE, titleCaptor.getValue());
    assertEquals(RM_SITE_DESCRIPTION, descriptionCaptor.getValue());
    assertEquals(SiteVisibility.PUBLIC, visibilityCaptor.getValue());
    assertEquals(DOD5015Model.TYPE_DOD_5015_SITE, siteTypeCaptor.getValue());
    verify(mockedImporterService, times(1)).importView(any(SiteImportPackageHandler.class), any(Location.class), any(ImporterBinding.class), eq(null));
    verify(mockedSiteService, times(1)).createContainer(RM_SITE_ID, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    verify(mockedFavouritesService, times(1)).addFavourite(any(String.class), any(NodeRef.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.DOD5015, createdRMSite.getCompliance());
    assertEquals(null, createdRMSite.getRole());
    assertEquals(RM_SITE_ID, createdRMSite.getId());
    assertEquals(siteNodeRef.getId(), createdRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, createdRMSite.getDescription());
    assertEquals(RM_SITE_TITLE, createdRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, createdRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) QName(org.alfresco.service.namespace.QName) ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteImportPackageHandler(org.alfresco.rest.api.impl.SiteImportPackageHandler) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) Location(org.alfresco.service.cmr.view.Location) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 15 with RMSite

use of org.alfresco.rm.rest.api.model.RMSite in project records-management by Alfresco.

the class RMSiteEntityResourceUnitTest method updateRMSiteCompliance.

@Test
public void updateRMSiteCompliance() throws Exception {
    String siteId = RM_SITE_ID;
    Params parameters = mock(Params.class);
    RMSite site = new RMSite();
    site.setTitle("New Title");
    site.setDescription("New Description");
    site.setCompliance(RMSiteCompliance.STANDARD);
    try {
        rmSiteEntityResource.update(siteId, site, parameters);
        fail("Expected ecxeption as rm site compliance cannot be changed.");
    } catch (InvalidArgumentException ex) {
        assertEquals("Site update does not support field: compliance", ex.getMsgId());
    }
    verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
Also used : RMSite(org.alfresco.rm.rest.api.model.RMSite) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) SiteUpdate(org.alfresco.rest.api.model.SiteUpdate) Params(org.alfresco.rest.framework.resource.parameters.Params) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Aggregations

RMSite (org.alfresco.rm.rest.api.model.RMSite)17 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)13 Test (org.junit.Test)13 Parameters (org.alfresco.rest.framework.resource.parameters.Parameters)11 SiteUpdate (org.alfresco.rest.api.model.SiteUpdate)8 Params (org.alfresco.rest.framework.resource.parameters.Params)8 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)7 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)4 SiteImportPackageHandler (org.alfresco.rest.api.impl.SiteImportPackageHandler)3 Site (org.alfresco.rest.api.model.Site)3 RMSiteCompliance (org.alfresco.rm.rest.api.model.RMSiteCompliance)3 ImporterBinding (org.alfresco.service.cmr.view.ImporterBinding)3 Location (org.alfresco.service.cmr.view.Location)3 QName (org.alfresco.service.namespace.QName)3 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 ActivityInfo (org.alfresco.service.cmr.activities.ActivityInfo)1