mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1636: fixed bug when updating person with aspects/props.
See https://issues.alfresco.com/jira/browse/REPO-1636?focusedCommentId=495557&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-495557 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133721 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -594,6 +594,11 @@ public class PeopleImpl implements People
|
|||||||
savePersonDescription(person.getDescription(), personNodeRef);
|
savePersonDescription(person.getDescription(), personNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update custom aspects - do this *before* adding custom properties. The
|
||||||
|
// addition of custom properties may result in the auto-addition of aspects
|
||||||
|
// and we don't want to remove them during the update of explicitly specified aspects.
|
||||||
|
nodes.updateCustomAspects(personNodeRef, person.getAspectNames(), EXCLUDED_ASPECTS);
|
||||||
|
|
||||||
// Add custom properties
|
// Add custom properties
|
||||||
if (person.getProperties() != null)
|
if (person.getProperties() != null)
|
||||||
{
|
{
|
||||||
@@ -612,9 +617,6 @@ public class PeopleImpl implements People
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update custom aspects
|
|
||||||
nodes.updateCustomAspects(personNodeRef, person.getAspectNames(), EXCLUDED_ASPECTS);
|
|
||||||
|
|
||||||
return getPerson(personId);
|
return getPerson(personId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -751,6 +751,50 @@ public class TestPeople extends EnterpriseTestApi
|
|||||||
assertNull(person.getProperties());
|
assertNull(person.getProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Aspects and properties together
|
||||||
|
{
|
||||||
|
Person person = new Person();
|
||||||
|
String personId = UUID.randomUUID().toString()+"@"+account1.getId();
|
||||||
|
person.setUserName(personId);
|
||||||
|
person.setFirstName("Joe");
|
||||||
|
person.setEmail(personId);
|
||||||
|
person.setEnabled(true);
|
||||||
|
person.setPassword("password123");
|
||||||
|
// Start with no custom props/aspects
|
||||||
|
person.setProperties(null);
|
||||||
|
person.setAspectNames(null);
|
||||||
|
|
||||||
|
person = people.create(person);
|
||||||
|
|
||||||
|
assertNull(person.getAspectNames());
|
||||||
|
assertNull(person.getProperties());
|
||||||
|
|
||||||
|
// Auto-add the papi:comms aspect, by setting its papi:jabber property,
|
||||||
|
// but explicitly add the papi:lunchable aspect.
|
||||||
|
String json = qjson(
|
||||||
|
"{" +
|
||||||
|
" `aspectNames`: [ " +
|
||||||
|
" `papi:lunchable` " +
|
||||||
|
" ], " +
|
||||||
|
" `properties`: { " +
|
||||||
|
" `papi:jabber`: `another@jabber.example.com`, " +
|
||||||
|
" `papi:lunch`: `sandwich` " +
|
||||||
|
" }" +
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
|
person = people.update(person.getId(), json, 200);
|
||||||
|
|
||||||
|
// Were both aspects set?
|
||||||
|
List<String> aspectNames = person.getAspectNames();
|
||||||
|
assertEquals(2, aspectNames.size());
|
||||||
|
assertTrue(aspectNames.contains("papi:lunchable"));
|
||||||
|
assertTrue(aspectNames.contains("papi:comms"));
|
||||||
|
assertEquals(2, person.getProperties().size());
|
||||||
|
assertEquals("another@jabber.example.com", person.getProperties().get("papi:jabber"));
|
||||||
|
assertEquals("sandwich", person.getProperties().get("papi:lunch"));
|
||||||
|
}
|
||||||
|
|
||||||
// Remove a property by setting it to null
|
// Remove a property by setting it to null
|
||||||
{
|
{
|
||||||
Person person = createTestUpdatePerson();
|
Person person = createTestUpdatePerson();
|
||||||
|
Reference in New Issue
Block a user