Fixed the completely broken code in memberships.get.js REST API and the equally challenged URL that's calling it in colleagues.get.js.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14570 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-06-05 18:47:25 +00:00
parent 6f60cfc4e0
commit 8c84d09566

View File

@@ -14,18 +14,17 @@ function main()
var authorityType = args["authorityType"];
var sizeString = args["size"];
if(authorityType != null )
if (authorityType != null)
{
authorityType.match("[USER|GROUP]" != null)
if (authorityType.match("USER|GROUP") == null)
{
status.setCode(status.STATUS_BAD_REQUEST, "The authorityType must be either USER or GROUP.");
status.setCode(status.STATUS_BAD_REQUEST, "The 'authorityType' argument must be either USER or GROUP.");
return;
}
}
// Get the filtered memberships
// Comes back as a Map<String, String> containing the full authority name
// and role
// Comes back as a Map<String, String> containing the full authority name and role
var memberships = site.listMembers(nameFilter, roleFilter, sizeString != null ? parseInt(sizeString) : 0);
// Get a list of all the users resolved to person nodes
@@ -35,22 +34,20 @@ function main()
for (userName in memberships)
{
var membershipRole = memberships[userName];
if(userName.match("^GROUP_"))
if (userName.match("^GROUP_"))
{
if(authorityType == null || authorityType == "GROUP")
if (authorityType == null || authorityType == "GROUP")
{
// make sure the keys are strings - as usernames may be all
// numbers!
// make sure the keys are strings - as usernames may be all numbers!
authorities['_' + userName] = groups.getGroupForFullAuthorityName(userName);
roles['_' + userName] = membershipRole;
}
}
else
{
if(authorityType == null || authorityType == "USER")
if (authorityType == null || authorityType == "USER")
{
// make sure the keys are strings - as usernames may be all
// numbers!
// make sure the keys are strings - as usernames may be all numbers!
authorities['_' + userName] = people.getPerson(userName);
roles['_' + userName] = membershipRole;
}