Search in sources :

Example 66 with SiteInfo

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

the class SiteServiceImplTest method testALF_3200.

/**
 * ALF-3200
 * You shouldn't be able to rename a Site using the normal node service
 *  type operations, because the relationship between a site and its
 *  authorities is based on a pattern that uses the site name.
 * However, you are free to change a site's display name.
 */
@Test
public void testALF_3200() throws Exception {
    // Create the site
    String siteName = "testALF_3200";
    SiteInfo siteInfo = this.siteService.createSite(TEST_SITE_PRESET, siteName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.MODERATED);
    // Grab the details
    NodeRef siteNodeRef = siteInfo.getNodeRef();
    // Try to rename it
    try {
        fileFolderService.rename(siteNodeRef, "RenamedName");
        fail("Shouldn't be able to rename a site but did");
    } catch (SiteServiceException e) {
    // expected
    }
    // Now just try to change the display name (title) via the node service
    assertEquals(TEST_TITLE, nodeService.getProperty(siteNodeRef, ContentModel.PROP_TITLE));
    String newName = "ChangedTitleName";
    String newName2 = "Changed2Title2Name";
    nodeService.setProperty(siteNodeRef, ContentModel.PROP_TITLE, newName);
    assertEquals(newName, nodeService.getProperty(siteNodeRef, ContentModel.PROP_TITLE));
    // And also via the site info
    siteInfo = this.siteService.getSite(siteNodeRef);
    assertEquals(newName, siteInfo.getTitle());
    siteInfo.setTitle(newName2);
    siteService.updateSite(siteInfo);
    assertEquals(newName2, siteInfo.getTitle());
    assertEquals(newName2, nodeService.getProperty(siteNodeRef, ContentModel.PROP_TITLE));
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 67 with SiteInfo

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

the class SiteServiceImplTest method testALF_1017_nonSitesInSitesSpace.

/**
 * ALF-1017 - Non sites in the Sites Space container shouldn't
 *  break the listing methods
 */
@Test
public void testALF_1017_nonSitesInSitesSpace() throws Exception {
    // Initially listing is fine
    List<SiteInfo> sites = this.siteService.listSites(null, null);
    assertNotNull("sites list was null.", sites);
    final int preexistingSitesCount = sites.size();
    // Create some sites
    SiteInfo site1 = this.siteService.createSite(TEST_SITE_PRESET, "mySiteOne", TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
    SiteInfo site2 = this.siteService.createSite(TEST_SITE_PRESET, "mySiteTwo", TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PRIVATE);
    // Listing is still ok
    sites = this.siteService.listSites(null, null);
    assertNotNull("sites list was null.", sites);
    assertEquals(preexistingSitesCount + 2, sites.size());
    // Now add a random folder, and a random document to the sites root
    final NodeRef sitesSpace = this.nodeService.getPrimaryParent(site1.getNodeRef()).getParentRef();
    final NodeRef folder = AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>() {

        @Override
        public NodeRef doWork() throws Exception {
            return nodeService.createNode(sitesSpace, ContentModel.ASSOC_CONTAINS, QName.createQName("Folder"), ContentModel.TYPE_FOLDER).getChildRef();
        }
    });
    final NodeRef document = AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>() {

        @Override
        public NodeRef doWork() throws Exception {
            return nodeService.createNode(sitesSpace, ContentModel.ASSOC_CONTAINS, QName.createQName("Document"), ContentModel.TYPE_CONTENT).getChildRef();
        }
    });
    // Listing should still be fine, and count won't have increased
    sites = this.siteService.listSites(null, null);
    assertNotNull("sites list was null.", sites);
    assertEquals(preexistingSitesCount + 2, sites.size());
    // Delete one site, listing still ok
    this.siteService.deleteSite(site2.getShortName());
    sites = this.siteService.listSites(null, null);
    assertNotNull("sites list was null.", sites);
    assertEquals(preexistingSitesCount + 1, sites.size());
    // Tidy up the random nodes, listing still fine
    this.nodeService.deleteNode(folder);
    this.nodeService.deleteNode(document);
    sites = this.siteService.listSites(null, null);
    assertNotNull("sites list was null.", sites);
    assertEquals(preexistingSitesCount + 1, sites.size());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) UnknownAuthorityException(org.alfresco.repo.security.authority.UnknownAuthorityException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 68 with SiteInfo

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

the class SiteServiceImplTest method testModeratedSite.

/**
 * From CLOUD-957, insure that GROUP_EVERYONE does not have read access to moderated sites' containers.
 */
@Test
public void testModeratedSite() throws Exception {
    String siteName = GUID.generate();
    SiteInfo siteInfo = createSite(siteName, "doclib", SiteVisibility.MODERATED);
    NodeRef container = this.siteService.getContainer(siteInfo.getShortName(), "doclib");
    assertNull("GROUP_EVERYONE shouldn't have any permissions on a moderated site's containers", getAllowedPermissionsMap(container).get(PermissionService.ALL_AUTHORITIES));
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 69 with SiteInfo

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

the class SiteServiceImplTest method testALF_5556.

@Test
public void testALF_5556() throws Exception {
    String siteName = "testALF_5556";
    SiteInfo siteInfo = this.siteService.createSite(TEST_SITE_PRESET, siteName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.MODERATED);
    // create a container for the site
    NodeRef container = this.siteService.createContainer(siteInfo.getShortName(), "folder.component", null, null);
    // Try to rename the container
    try {
        fileFolderService.rename(container, "RenamedContainer");
        fail("Shouldn't be able to rename a container but was able to");
    } catch (SiteServiceException e) {
    // expected
    }
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

Example 70 with SiteInfo

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

the class SiteServiceImplTest method testDeleteSite_ViaNodeService.

@Test
public void testDeleteSite_ViaNodeService() {
    String siteShortName = "testUpdateSite";
    this.siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
    SiteInfo siteInfo = this.siteService.getSite(siteShortName);
    assertNotNull(siteInfo);
    // delete a site through the nodeService - not allowed
    try {
        nodeService.deleteNode(siteInfo.getNodeRef());
        fail("Shouldn't be able to delete a site via the nodeService");
    } catch (AlfrescoRuntimeException expected) {
    // Intentionally empty
    }
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) BaseAlfrescoSpringTest(org.alfresco.util.BaseAlfrescoSpringTest) Test(org.junit.Test)

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