mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
The containing groups for a user can now be optionally returned via the Person REST API.
Some cleanup to Person REST API templates scripts and tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13829 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,11 +2,6 @@
|
|||||||
var filter = args["filter"];
|
var filter = args["filter"];
|
||||||
var maxResults = args["maxResults"];
|
var maxResults = args["maxResults"];
|
||||||
|
|
||||||
if (filter)
|
|
||||||
{
|
|
||||||
filter = filter.replace('"', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the collection of people
|
// Get the collection of people
|
||||||
var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);
|
var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);
|
||||||
|
|
||||||
|
@@ -7,31 +7,11 @@ function main()
|
|||||||
var person = people.getPerson(userName);
|
var person = people.getPerson(userName);
|
||||||
|
|
||||||
// if person is found matching the given user name
|
// if person is found matching the given user name
|
||||||
// then get that person's details to pass through
|
// then delete that person
|
||||||
// to the template and then delete that person
|
|
||||||
if (person != null)
|
if (person != null)
|
||||||
{
|
{
|
||||||
// Get the person's details
|
|
||||||
|
|
||||||
var personDetails =
|
|
||||||
{
|
|
||||||
properties: []
|
|
||||||
}
|
|
||||||
|
|
||||||
personDetails.properties["userName"] = userName;
|
|
||||||
personDetails.properties["title"] = person.properties["title"];
|
|
||||||
personDetails.properties["firstName"] = person.properties["firstName"];
|
|
||||||
personDetails.properties["lastName"] = person.properties["lastName"];
|
|
||||||
personDetails.properties["organization"] = person.properties["organization"];
|
|
||||||
personDetails.properties["jobtitle"] = person.properties["jobtitle"];
|
|
||||||
personDetails.properties["email"] = person.properties["email"];
|
|
||||||
personDetails.assocs = {}; // fake the assocs object
|
|
||||||
|
|
||||||
// delete the person
|
// delete the person
|
||||||
people.deletePerson(userName);
|
people.deletePerson(userName);
|
||||||
|
|
||||||
// Put the person's details on the model to pass to the template
|
|
||||||
model.personDetails = personDetails;
|
|
||||||
}
|
}
|
||||||
// else if no person was found matching the given user name,
|
// else if no person was found matching the given user name,
|
||||||
// then return HTTP error status "not found"
|
// then return HTTP error status "not found"
|
||||||
|
@@ -1,2 +1 @@
|
|||||||
<#import "person.lib.ftl" as personLib/>
|
{}
|
||||||
<@personLib.personJSON person=personDetails/>
|
|
@@ -3,11 +3,15 @@ function main()
|
|||||||
// Get the user name of the person to get
|
// Get the user name of the person to get
|
||||||
var userName = url.extension;
|
var userName = url.extension;
|
||||||
|
|
||||||
|
// Do we want to return containing groups?
|
||||||
|
var groups = (args["groups"] == "true");
|
||||||
|
|
||||||
// Get the person who has that user name
|
// Get the person who has that user name
|
||||||
var person = people.getPerson(userName);
|
var person = people.getPerson(userName);
|
||||||
if (person != null)
|
if (person != null)
|
||||||
{
|
{
|
||||||
model.person = person;
|
model.person = person;
|
||||||
|
model.groups = groups ? people.getContainerGroups(person) : null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -1,2 +1,6 @@
|
|||||||
<#import "person.lib.ftl" as personLib/>
|
<#import "person.lib.ftl" as personLib/>
|
||||||
|
<#if groups??>
|
||||||
|
<@personLib.personGroupsJSON person=person groups=groups/>
|
||||||
|
<#else>
|
||||||
<@personLib.personJSON person=person/>
|
<@personLib.personJSON person=person/>
|
||||||
|
</#if>
|
@@ -1,6 +1,5 @@
|
|||||||
<#macro personJSON person>
|
<#macro personJSONinner person>
|
||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
|
||||||
"url" : "${url.serviceContext + "/api/person/" + person.properties.userName}",
|
"url" : "${url.serviceContext + "/api/person/" + person.properties.userName}",
|
||||||
"userName" : "${person.properties.userName}",
|
"userName" : "${person.properties.userName}",
|
||||||
<#if person.assocs["cm:avatar"]??>
|
<#if person.assocs["cm:avatar"]??>
|
||||||
@@ -26,10 +25,23 @@
|
|||||||
"quota" : <#if person.properties.sizeQuota??>${person.properties.sizeQuota?c}<#else>0</#if>,
|
"quota" : <#if person.properties.sizeQuota??>${person.properties.sizeQuota?c}<#else>0</#if>,
|
||||||
"sizeCurrent" : <#if person.properties.sizeCurrent??>${person.properties.sizeCurrent?c}<#else>0</#if>,
|
"sizeCurrent" : <#if person.properties.sizeCurrent??>${person.properties.sizeCurrent?c}<#else>0</#if>,
|
||||||
"persondescription" : <#if person.properties.persondescription??>"${person.properties.persondescription.content}"<#else>null</#if>
|
"persondescription" : <#if person.properties.persondescription??>"${person.properties.persondescription.content}"<#else>null</#if>
|
||||||
}
|
|
||||||
</#escape>
|
</#escape>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
<#macro personJSON person>
|
||||||
|
{
|
||||||
|
<@personJSONinner person=person/>
|
||||||
|
}
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro personGroupsJSON person groups>
|
||||||
|
{
|
||||||
|
<@personJSONinner person=person/>
|
||||||
|
,
|
||||||
|
"groups" : [<#list groups as g>"${jsonUtils.encodeJSONString(g.properties["usr:authorityName"])}"<#if g_has_next>, </#if></#list>]
|
||||||
|
}
|
||||||
|
</#macro>
|
||||||
|
|
||||||
<#macro personSummaryJSON person>
|
<#macro personSummaryJSON person>
|
||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
|
@@ -253,14 +253,7 @@ public class PersonServiceTest extends BaseWebScriptTest
|
|||||||
Status.STATUS_OK);
|
Status.STATUS_OK);
|
||||||
|
|
||||||
// Delete the person
|
// Delete the person
|
||||||
JSONObject result = deletePerson(userName, Status.STATUS_OK);
|
deletePerson(userName, Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(userName, result.get("userName"));
|
|
||||||
assertEquals("myFirstName", result.get("firstName"));
|
|
||||||
assertEquals("myLastName", result.get("lastName"));
|
|
||||||
assertEquals("myOrganisation", result.get("organisation"));
|
|
||||||
assertEquals("myJobTitle", result.get("jobtitle"));
|
|
||||||
assertEquals("firstName.lastName@email.com", result.get("email"));
|
|
||||||
|
|
||||||
// Make sure that the person has been deleted and no longer exists
|
// Make sure that the person has been deleted and no longer exists
|
||||||
deletePerson(userName, Status.STATUS_NOT_FOUND);
|
deletePerson(userName, Status.STATUS_NOT_FOUND);
|
||||||
|
Reference in New Issue
Block a user