Search in sources :

Example 91 with SiteInfo

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);
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)

Example 92 with SiteInfo

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);
}
Also used : Site(org.alfresco.rest.api.model.Site) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) RMSite(org.alfresco.rm.rest.api.model.RMSite) RMSiteCompliance(org.alfresco.rm.rest.api.model.RMSiteCompliance)

Example 93 with SiteInfo

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);
}
Also used : Site(org.alfresco.rest.api.model.Site) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) RMSite(org.alfresco.rm.rest.api.model.RMSite) RMSiteCompliance(org.alfresco.rm.rest.api.model.RMSiteCompliance)

Example 94 with SiteInfo

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));
    }
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo)

Example 95 with SiteInfo

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

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