use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class DiscussionServiceImplTest method createTestSites.
private static void createTestSites() throws Exception {
final DiscussionServiceImpl privateDiscussionService = (DiscussionServiceImpl) testContext.getBean("discussionService");
DISCUSSION_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>() {
@Override
public SiteInfo execute() throws Throwable {
SiteInfo site = SITE_SERVICE.createSite(TEST_SITE_PREFIX, DiscussionServiceImplTest.class.getSimpleName() + "_testSite" + System.currentTimeMillis(), "test site title", "test site description", SiteVisibility.PUBLIC);
privateDiscussionService.getSiteDiscussionsContainer(site.getShortName(), true);
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
return site;
}
});
// Add a forum within it, used for the alternate testing
FORUM_NODE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() {
@Override
public NodeRef execute() throws Throwable {
NodeRef node = NODE_SERVICE.createNode(DISCUSSION_SITE.getNodeRef(), ForumModel.ASSOC_DISCUSSION, QName.createQName("Forum"), ForumModel.TYPE_FORUM).getChildRef();
NODE_SERVICE.setProperty(node, ContentModel.PROP_NAME, "Forum");
NODE_SERVICE.setProperty(node, ContentModel.PROP_TITLE, "Forum");
CLASS_TEST_NODES_TO_TIDY.add(node);
return node;
}
});
// Create the alternate site as admin
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
TenantContextHolder.setTenantDomain(TENANT_DOMAIN);
ALTERNATE_DISCUSSION_SITE = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<SiteInfo>() {
@Override
public SiteInfo execute() throws Throwable {
SiteInfo site = SITE_SERVICE.createSite(TEST_SITE_PREFIX, DiscussionServiceImplTest.class.getSimpleName() + "_testAltSite" + System.currentTimeMillis(), "alternate site title", "alternate site description", SiteVisibility.PRIVATE);
privateDiscussionService.getSiteDiscussionsContainer(site.getShortName(), true);
CLASS_TEST_NODES_TO_TIDY.add(site.getNodeRef());
return site;
}
});
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
TenantContextHolder.setTenantDomain(TENANT_DOMAIN);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RMSitesImpl method getRMSite.
@Override
public RMSite getRMSite(String siteId) {
Site site = getSite(siteId);
SiteInfo siteInfo = siteService.getSite(siteId);
RMSiteCompliance compliance = getCompliance(siteInfo);
return new RMSite(site, compliance);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RMSitesImpl method updateRMSite.
/**
* Updates the RM site
*/
public RMSite updateRMSite(String siteId, SiteUpdate update, Parameters parameters) {
Site updatedSite = updateSite(siteId, update, parameters);
SiteInfo siteInfo = siteService.getSite(siteId);
RMSiteCompliance compliance = getCompliance(siteInfo);
return new RMSite(updatedSite, compliance);
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class JSONConversionComponent method checkRmSiteExistence.
/**
* Checks for the existance of the RM site
*
* @param rootJSONObject the root JSON object
*/
@SuppressWarnings("unchecked")
private void checkRmSiteExistence(JSONObject rootJSONObject) {
if (!getJsonConversionComponentCache().contains(RM_SITE_EXISTS)) {
SiteInfo site = siteService.getSite(FilePlanService.DEFAULT_RM_SITE_ID);
if (site != null) {
getJsonConversionComponentCache().put(RM_SITE_EXISTS, true);
rootJSONObject.put(IS_RM_SITE_CREATED, true);
} else {
getJsonConversionComponentCache().put(RM_SITE_EXISTS, false);
rootJSONObject.put(IS_RM_SITE_CREATED, false);
}
} else {
rootJSONObject.put(IS_RM_SITE_CREATED, getJsonConversionComponentCache().get(RM_SITE_EXISTS));
}
}
use of org.alfresco.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddMoreThanOneFilePlanTypeToRmSite.
/**
* Given that we try to add more than one rma:filePlan to rm site,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneFilePlanTypeToRmSite() {
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);
// first file plan creation
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
// second filePlan creation
nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
assocs.add(mockedChildAssoc);
when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Aggregations