Merged 5.2.N (5.2.1) to HEAD (5.2)

132117 cturlica: REPO-1506: Update Person - implement
      - added implementation for update personService
      - added tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132338 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 14:04:53 +00:00
parent d6e678d2c2
commit a77b7e3173
5 changed files with 392 additions and 52 deletions

View File

@@ -50,7 +50,7 @@ import java.util.List;
* @author Gethin James
*/
@EntityResource(name="people", title = "People")
public class PeopleEntityResource implements EntityResourceAction.ReadById<Person>, EntityResourceAction.Create<Person>, InitializingBean
public class PeopleEntityResource implements EntityResourceAction.ReadById<Person>, EntityResourceAction.Create<Person>, EntityResourceAction.Update<Person>, InitializingBean
{
private static Log logger = LogFactory.getLog(PeopleEntityResource.class);
@@ -133,4 +133,48 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
result.add(people.create(person));
return result;
}
@Override
@WebApiDescription(title="Update person", description="Update the given person's details")
public Person update(String personId, Person person, Parameters parameters)
{
validateNonUpdatableFieldsExistence(person);
return people.update(personId, person);
}
/**
* Explicitly test for the presence of fields that are present on Person but
* shouldn't be updatable (until REPO-110 is solved).
*
* @param person
*/
private void validateNonUpdatableFieldsExistence(Person person)
{
if (person.getUserName() != null)
{
throw new InvalidArgumentException("Unsupported field: userName");
}
if (person.getStatusUpdatedAt() != null)
{
throw new InvalidArgumentException("Unsupported field: statusUpdatedAt");
}
if (person.getAvatarId() != null)
{
throw new InvalidArgumentException("Unsupported field: avatarId");
}
if (person.getQuota() != null)
{
throw new InvalidArgumentException("Unsupported field: quota");
}
if (person.getQuotaUsed() != null)
{
throw new InvalidArgumentException("Unsupported field: quotaUsed");
}
}
}