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