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

131862 mward: Merged 131680:131794 from DEV/mward/5.2.n-createperson to 5.2.N
     REPO-892: make sure not all fields need to be supplied during create.
     REPO-892: throws error if fields exclusively belonging to Person (that are not part of PersonUpdate) are sent in request.
     REPO-892: cleaned up PersonUpdateJSONSerializer a little, by removing unnecessary 'fullVisibility' switch.
     REPO-892: improved test for optional fields; added test for too few fields.
     REPO-892: added tests (and impl where needed) for -ve response codes as given in the open api spec for create person.
     REPO-892: fixed broken test due to reuse of username.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132308 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:59:46 +00:00
parent 373d976faa
commit d2322f56a2
4 changed files with 221 additions and 84 deletions

View File

@@ -31,6 +31,7 @@ import org.alfresco.rest.api.model.PersonUpdate;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.ResourceParameter;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.parameters.Parameters;
@@ -86,18 +87,29 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
kind= ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple=false)
public List<Person> create(List<Person> persons, Parameters parameters)
{
Person p = persons.get(0);
// Until REPO-110 is solved, we need to explicitly test for the presence of fields
// that are present on Person but not PersonUpdate
// see also, SiteEntityResource.update(String, Site, Parameters)
// TODO: these are the extras:
// avatarId
// statusUpdatedAt
// quota
// quotaUsed
if (p.getStatusUpdatedAt() != null)
{
throw new InvalidArgumentException("Unsupported field: statusUpdatedAt");
}
if (p.getAvatarId() != null)
{
throw new InvalidArgumentException("Unsupported field: avatarId");
}
if (p.getQuota() != null)
{
throw new InvalidArgumentException("Unsupported field: quota");
}
if (p.getQuotaUsed() != null)
{
throw new InvalidArgumentException("Unsupported field: quotaUsed");
}
List<Person> result = new ArrayList<>(1);
Person p = persons.get(0);
PersonUpdate person = new PersonUpdate.Builder()
.id(p.getUserName())
.firstName(p.getFirstName())