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());
}
}
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());
}
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());
}
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());
}
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));
}
Aggregations