Site Service: expose methods to get group names and available site roles

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10479 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-08-21 16:32:30 +00:00
parent be93fb9ca5
commit f8e72d6b47
6 changed files with 100 additions and 1 deletions

View File

@@ -140,4 +140,15 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
}
return site;
}
/**
* Returns an array of all the roles that can be assigned to a memeber of a site.
*
* @return String[] roles available to assign to a member of a site
*/
public String[] listSiteRoles()
{
List<String> roles = this.siteService.getSiteRoles();
return (String[])roles.toArray(new String[roles.size()]);
}
}

View File

@@ -25,6 +25,7 @@
package org.alfresco.repo.site.script;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -56,6 +57,10 @@ public class Site implements Serializable
/** Site information */
private SiteInfo siteInfo;
/** Site group information */
private String siteGroup;
private ScriptableHashMap<String, String> siteRoleGroups;
/** Services Registry */
private ServiceRegistry serviceRegistry;
@@ -180,6 +185,41 @@ public class Site implements Serializable
return node;
}
/**
* Get the site group name
*
* @return String site group name
*/
public String getSiteGroup()
{
if (this.siteGroup == null)
{
this.siteGroup = this.siteService.getSiteGroup(this.siteInfo.getShortName());
}
return this.siteGroup;
}
/**
* Gets a map of role name mapping to associated group name.
*
* @return ScriptableMap<String, String> map of role to group name
*/
public ScriptableHashMap<String, String> getSitePermissionGroups()
{
if (this.siteRoleGroups == null)
{
List<String> roles = this.siteService.getSiteRoles();
this.siteRoleGroups = new ScriptableHashMap<String, String>();
for (String role : roles)
{
this.siteRoleGroups.put(
role,
this.siteService.getSiteRoleGroup(this.siteInfo.getShortName(), role));
}
}
return this.siteRoleGroups;
}
/**
* Saves any outstanding updates to the site details.
* <p>

View File

@@ -196,9 +196,29 @@ function testPermissions()
site.resetAllPermissions(container);
}
function testRolesAndGroups()
{
var roles = siteService.listSiteRoles();
test.assertNotNull(roles);
test.assertFalse(roles.length == 0);
var site = siteService.createSite("sitePreset", "sn", "siteTitle", "siteDescription", false);
var siteGroup = site.siteGroup;
test.assertNotNull(siteGroup);
test.assertEquals("GROUP_site_sn", siteGroup);
var groups = site.sitePermissionGroups;
test.assertNotNull(groups);
test.assertEquals("GROUP_site_sn_SiteManager", groups.SiteManager);
test.assertEquals("GROUP_site_sn_SiteConsumer", groups.SiteConsumer);
test.assertEquals("GROUP_site_sn_SiteCollaborator", groups.SiteCollaborator);
}
// Execute test's
testCRUD();
testListSites();
testMembership();
testContainer();
testPermissions();
testPermissions();
testRolesAndGroups();