diff --git a/source/java/org/alfresco/rest/api/People.java b/source/java/org/alfresco/rest/api/People.java index 9e950043fe..7643d2d946 100644 --- a/source/java/org/alfresco/rest/api/People.java +++ b/source/java/org/alfresco/rest/api/People.java @@ -26,7 +26,6 @@ package org.alfresco.rest.api; import org.alfresco.rest.api.model.Person; -import org.alfresco.rest.api.model.PersonUpdate; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.NoSuchPersonException; @@ -50,7 +49,7 @@ public interface People * @param person * @return */ - Person create(PersonUpdate person); + Person create(Person person); /** * Update the given person's details. diff --git a/source/java/org/alfresco/rest/api/impl/PeopleImpl.java b/source/java/org/alfresco/rest/api/impl/PeopleImpl.java index 8ceb6b83c7..671b885709 100644 --- a/source/java/org/alfresco/rest/api/impl/PeopleImpl.java +++ b/source/java/org/alfresco/rest/api/impl/PeopleImpl.java @@ -32,7 +32,6 @@ import org.alfresco.rest.api.Nodes; import org.alfresco.rest.api.People; import org.alfresco.rest.api.Sites; import org.alfresco.rest.api.model.Person; -import org.alfresco.rest.api.model.PersonUpdate; import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException; import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; @@ -283,7 +282,7 @@ public class PeopleImpl implements People } @Override - public Person create(PersonUpdate person) + public Person create(Person person) { validateCreatePersonData(person); @@ -334,7 +333,7 @@ public class PeopleImpl implements People }); } - private void validateCreatePersonData(PersonUpdate person) + private void validateCreatePersonData(Person person) { checkRequiredField("id", person.getUserName()); checkRequiredField("firstName", person.getFirstName()); diff --git a/source/java/org/alfresco/rest/api/model/Person.java b/source/java/org/alfresco/rest/api/model/Person.java index 1355ad182b..5f6fcb7f49 100644 --- a/source/java/org/alfresco/rest/api/model/Person.java +++ b/source/java/org/alfresco/rest/api/model/Person.java @@ -162,16 +162,31 @@ public class Person return company; } + public void setCompany(Company company) + { + this.company = company; + } + public String getInstantMessageId() { return instantMessageId; } + public void setInstantMessageId(String instantMessageId) + { + this.instantMessageId = instantMessageId; + } + public String getGoogleId() { return googleId; } + public void setGoogleId(String googleId) + { + this.googleId = googleId; + } + public Long getQuota() { return quota; @@ -187,17 +202,32 @@ public class Person return description; } + public void setDescription(String description) + { + this.description = description; + } + @UniqueId public String getUserName() { return userName; } + public void setUserName(String userName) + { + this.userName = userName; + } + public Boolean isEnabled() { return enabled; } + public void setEnabled(Boolean enabled) + { + this.enabled = enabled; + } + public void setAvatarId(NodeRef avatarId) { this.avatarId = avatarId; @@ -238,36 +268,71 @@ public class Person return jobTitle; } + public void setJobTitle(String jobTitle) + { + this.jobTitle = jobTitle; + } + public String getLocation() { return location; } + public void setLocation(String location) + { + this.location = location; + } + public String getTelephone() { return telephone; } + public void setTelephone(String telephone) + { + this.telephone = telephone; + } + public String getMobile() { return mobile; } + public void setMobile(String mobile) + { + this.mobile = mobile; + } + public String getEmail() { return email; } + public void setEmail(String email) + { + this.email = email; + } + public String getSkypeId() { return skypeId; } + public void setSkypeId(String skypeId) + { + this.skypeId = skypeId; + } + public String getUserStatus() { return userStatus; } + public void setUserStatus(String userStatus) + { + this.userStatus = userStatus; + } + public Date getStatusUpdatedAt() { return statusUpdatedAt; @@ -278,6 +343,11 @@ public class Person return emailNotificationsEnabled; } + public void setEmailNotificationsEnabled(Boolean emailNotificationsEnabled) + { + this.emailNotificationsEnabled = emailNotificationsEnabled; + } + public String getPassword() { return this.password; @@ -364,5 +434,4 @@ public class Person Boolean isEmailNotificationsEnabled = isEmailNotificationsEnabled(); addToMap(properties, ContentModel.PROP_EMAIL_FEED_DISABLED, (isEmailNotificationsEnabled == null ? null : !isEmailNotificationsEnabled.booleanValue())); } - } diff --git a/source/java/org/alfresco/rest/api/model/PersonUpdate.java b/source/java/org/alfresco/rest/api/model/PersonUpdate.java deleted file mode 100644 index 20529893fe..0000000000 --- a/source/java/org/alfresco/rest/api/model/PersonUpdate.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.rest.api.model; - -import org.alfresco.model.ContentModel; -import org.alfresco.rest.framework.resource.UniqueId; -import org.alfresco.service.namespace.QName; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * Create or update a person. - * - * @since 5.2 - * @author Matt Ward - */ -public class PersonUpdate -{ - protected final String userName; - protected final String firstName; - protected final String lastName; - protected final String description; - protected final String email; - protected final String skypeId; - protected final String googleId; - protected final String instantMessageId; - protected final String jobTitle; - protected final String location; - protected final Company company; - protected final String mobile; - protected final String telephone; - protected final String userStatus; - protected final Boolean enabled; - protected final Boolean emailNotificationsEnabled; - protected final String password; - - private PersonUpdate( - String userName, - String firstName, - String lastName, - String description, - String email, - String skypeId, - String googleId, - String instantMessageId, - String jobTitle, - String location, - Company company, - String mobile, - String telephone, - String userStatus, - Boolean enabled, - Boolean emailNotificationsEnabled, - String password) - { - this.userName = userName; - this.firstName = firstName; - this.lastName = lastName; - this.description = description; - this.email = email; - this.skypeId = skypeId; - this.googleId = googleId; - this.instantMessageId = instantMessageId; - this.jobTitle = jobTitle; - this.location = location; - this.company = company; - this.mobile = mobile; - this.telephone = telephone; - this.userStatus = userStatus; - this.enabled = enabled; - this.emailNotificationsEnabled = emailNotificationsEnabled; - this.password = password; - } - - public Company getCompany() - { - return company; - } - - public String getInstantMessageId() - { - return instantMessageId; - } - - public String getGoogleId() - { - return googleId; - } - - public String getDescription() - { - return description; - } - - @UniqueId - public String getUserName() - { - return userName; - } - - public Boolean isEnabled() - { - return enabled; - } - - public String getFirstName() - { - return firstName; - } - - public String getLastName() - { - return lastName; - } - - public String getJobTitle() - { - return jobTitle; - } - - public String getLocation() - { - return location; - } - - public String getTelephone() - { - return telephone; - } - - public String getMobile() - { - return mobile; - } - - public String getEmail() - { - return email; - } - - public String getSkypeId() - { - return skypeId; - } - - public String getUserStatus() - { - return userStatus; - } - - public Boolean isEmailNotificationsEnabled() - { - return emailNotificationsEnabled; - } - - public String getPassword() - { - return password; - } - - @Override - public String toString() - { - return "Person [userName=" + userName - + ", enabled=" + enabled - + ", firstName=" + firstName - + ", lastName=" + lastName - + ", jobTitle=" + jobTitle - + ", location=" + location - + ", telephone=" + telephone - + ", mobile=" + mobile - + ", email=" + email - + ", skypeId=" + skypeId - + ", instantMessageId=" + instantMessageId - + ", userStatus=" + userStatus - + ", googleId=" + googleId - + ", emailNotificationsEnabled=" + emailNotificationsEnabled - + ", description=" + description - + ", company=" + company - + ", password=(not shown)" - + "]"; - } - - public Map toProperties() - { - Map props = new HashMap<>(); - populateProps(props); - return props; - } - - private void addToMap(Map properties, QName name, Serializable value) - { - if(name != null && value != null) - { - properties.put(name, value); - } - } - - private void populateProps(Map properties) - { - addToMap(properties, ContentModel.PROP_USERNAME, getUserName()); - addToMap(properties, ContentModel.PROP_FIRSTNAME, getFirstName()); - addToMap(properties, ContentModel.PROP_LASTNAME, getLastName()); - addToMap(properties, ContentModel.PROP_EMAIL, getEmail()); - addToMap(properties, ContentModel.PROP_SKYPE, getSkypeId()); - addToMap(properties, ContentModel.PROP_GOOGLEUSERNAME, getGoogleId()); - addToMap(properties, ContentModel.PROP_INSTANTMSG, getInstantMessageId()); - addToMap(properties, ContentModel.PROP_JOBTITLE, getJobTitle()); - addToMap(properties, ContentModel.PROP_LOCATION, getLocation()); - - Company company = getCompany(); - if(company != null) - { - addToMap(properties, ContentModel.PROP_ORGANIZATION, company.getOrganization()); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS1, company.getAddress1()); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS2, company.getAddress2()); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS3, company.getAddress3()); - addToMap(properties, ContentModel.PROP_COMPANYPOSTCODE, company.getPostcode()); - addToMap(properties, ContentModel.PROP_COMPANYTELEPHONE, company.getTelephone()); - addToMap(properties, ContentModel.PROP_COMPANYFAX, company.getFax()); - addToMap(properties, ContentModel.PROP_COMPANYEMAIL, company.getEmail()); - } - else - { - addToMap(properties, ContentModel.PROP_ORGANIZATION, null); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS1, null); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS2, null); - addToMap(properties, ContentModel.PROP_COMPANYADDRESS3, null); - addToMap(properties, ContentModel.PROP_COMPANYPOSTCODE, null); - addToMap(properties, ContentModel.PROP_COMPANYTELEPHONE, null); - addToMap(properties, ContentModel.PROP_COMPANYFAX, null); - addToMap(properties, ContentModel.PROP_COMPANYEMAIL, null); - } - - addToMap(properties, ContentModel.PROP_MOBILE, getMobile()); - addToMap(properties, ContentModel.PROP_TELEPHONE, getTelephone()); - addToMap(properties, ContentModel.PROP_USER_STATUS, getUserStatus()); - addToMap(properties, ContentModel.PROP_ENABLED, isEnabled()); - addToMap(properties, ContentModel.PROP_EMAIL_FEED_DISABLED, - isEmailNotificationsEnabled() != null ? !isEmailNotificationsEnabled() : null); - - } - - public static class Builder - { - private String userName; // is "id" in request JSON - private String firstName; - private String lastName; - private String description; - private String email; - private String skypeId; - private String googleId; - private String instantMessageId; - private String jobTitle; - private String location; - private Company company; - private String mobile; - private String telephone; - private String userStatus; - private Boolean enabled; - private Boolean emailNotificationsEnabled; - private String password; - - public Builder id(String userId) - { - this.userName = userId; - return this; - } - - public Builder firstName(String fn) - { - this.firstName = fn; - return this; - } - - public Builder lastName(String ln) - { - this.lastName = ln; - return this; - } - - public Builder description(String description) - { - this.description = description; - return this; - } - - public Builder email(String email) - { - this.email = email; - return this; - } - - public Builder skypeId(String skypeId) - { - this.skypeId = skypeId; - return this; - } - - public Builder googleId(String googleId) - { - this.googleId = googleId; - return this; - } - - public Builder instantMessageId(String instantMessageId) - { - this.instantMessageId = instantMessageId; - return this; - } - - public Builder jobTitle(String jobTitle) - { - this.jobTitle = jobTitle; - return this; - } - - public Builder location(String location) - { - this.location = location; - return this; - } - - public Builder company(Company company) - { - this.company = company; - return this; - } - - public Builder mobile(String mobile) - { - this.mobile = mobile; - return this; - } - - public Builder telephone(String telephone) - { - this.telephone = telephone; - return this; - } - - public Builder userStatus(String userStatus) - { - this.userStatus = userStatus; - return this; - } - - public Builder enabled(Boolean enabled) - { - this.enabled = enabled; - return this; - } - - public Builder emailNotificationsEnabled(Boolean emailNotificationsEnabled) - { - this.emailNotificationsEnabled = emailNotificationsEnabled; - return this; - } - - public Builder password(String password) - { - this.password = password; - return this; - } - - public PersonUpdate build() - { - return new PersonUpdate( - userName, - firstName, - lastName, - description, - email, - skypeId, - googleId, - instantMessageId, - jobTitle, - location, - company, - mobile, - telephone, - userStatus, - enabled, - emailNotificationsEnabled, - password - ); - } - } -} diff --git a/source/java/org/alfresco/rest/api/people/PeopleEntityResource.java b/source/java/org/alfresco/rest/api/people/PeopleEntityResource.java index f9c85279e6..0cdab97dd5 100644 --- a/source/java/org/alfresco/rest/api/people/PeopleEntityResource.java +++ b/source/java/org/alfresco/rest/api/people/PeopleEntityResource.java @@ -27,7 +27,6 @@ package org.alfresco.rest.api.people; import org.alfresco.rest.api.People; import org.alfresco.rest.api.model.Person; -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; @@ -110,25 +109,24 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById result = new ArrayList<>(1); - PersonUpdate person = new PersonUpdate.Builder() - .id(p.getUserName()) - .firstName(p.getFirstName()) - .lastName(p.getLastName()) - .description(p.getDescription()) - .email(p.getEmail()) - .skypeId(p.getSkypeId()) - .googleId(p.getGoogleId()) - .instantMessageId(p.getInstantMessageId()) - .jobTitle(p.getJobTitle()) - .location(p.getLocation()) - .company(p.getCompany()) - .mobile(p.getMobile()) - .telephone(p.getTelephone()) - .userStatus(p.getUserStatus()) - .enabled(p.isEnabled()) - .emailNotificationsEnabled(p.isEmailNotificationsEnabled()) - .password(p.getPassword()). - build(); + Person person = new Person(); + person.setUserName(p.getUserName()); + person.setFirstName(p.getFirstName()); + person.setLastName(p.getLastName()); + person.setDescription(p.getDescription()); + person.setEmail(p.getEmail()); + person.setSkypeId(p.getSkypeId()); + person.setGoogleId(p.getGoogleId()); + person.setInstantMessageId(p.getInstantMessageId()); + person.setJobTitle(p.getJobTitle()); + person.setLocation(p.getLocation()); + person.setCompany(p.getCompany()); + person.setMobile(p.getMobile()); + person.setTelephone(p.getTelephone()); + person.setUserStatus(p.getUserStatus()); + person.setEnabled(p.isEnabled()); + person.setEmailNotificationsEnabled(p.isEmailNotificationsEnabled()); + person.setPassword(p.getPassword()); result.add(people.create(person)); return result; diff --git a/source/test-java/org/alfresco/rest/api/tests/TestPeople.java b/source/test-java/org/alfresco/rest/api/tests/TestPeople.java index 1d01e78fec..8b5437b30d 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestPeople.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestPeople.java @@ -25,7 +25,6 @@ */ package org.alfresco.rest.api.tests; -import org.alfresco.rest.api.model.PersonUpdate; import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.client.HttpResponse; import org.alfresco.rest.api.tests.client.Pair; @@ -151,25 +150,24 @@ public class TestPeople extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin")); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName00@"+account1.getId()). - firstName("Firstname"). - lastName("Lastname"). - description("my description"). - email("email@example.com"). - skypeId("my.skype.id"). - googleId("google"). - instantMessageId("jabber@im.example.com"). - jobTitle("International Man of Mystery"). - location("location"). - company(new Company("Org", "addr1", "addr2", "addr3", "AB1 1BA", "111 12312123", "222 345345345", "company.email@example.com")). - mobile("5657 567567 34543"). - telephone("1234 5678 9012"). - userStatus("userStatus"). - enabled(true). - emailNotificationsEnabled(true). - password("password"). - build(); + Person person = new Person(); + person.setUserName("myUserName00@"+account1.getId()); + person.setFirstName("Firstname"); + person.setLastName("Lastname"); + person.setDescription("my description"); + person.setEmail("email@example.com"); + person.setSkypeId("my.skype.id"); + person.setGoogleId("google"); + person.setInstantMessageId("jabber@im.example.com"); + person.setJobTitle("International Man of Mystery"); + person.setLocation("location"); + person.setCompany(new Company("Org", "addr1", "addr2", "addr3", "AB1 1BA", "111 12312123", "222 345345345", "company.email@example.com")); + person.setMobile("5657 567567 34543"); + person.setTelephone("1234 5678 9012"); + person.setUserStatus("userStatus"); + person.setEnabled(true); + person.setEmailNotificationsEnabled(true); + person.setPassword("password"); Person p = people.create(person); @@ -209,13 +207,12 @@ public class TestPeople extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin")); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName04@"+account1.getId()). - firstName("Firstname"). - email("myUserName04@"+account1.getId()). - enabled(false). - password("hello"). - build(); + Person person = new Person(); + person.setUserName("myUserName04@"+account1.getId()); + person.setFirstName("Firstname"); + person.setEmail("myUserName04@"+account1.getId()); + person.setEnabled(false); + person.setPassword("hello"); Person p = people.create(person); assertEquals(false, p.isEnabled()); @@ -243,13 +240,12 @@ public class TestPeople extends EnterpriseTestApi { publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin")); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName05@"+account1.getId()). - firstName("Firstname"). - email("myUserName05@"+account1.getId()). - enabled(true). - password("banana"). - build(); + Person person = new Person(); + person.setUserName("myUserName05@"+account1.getId()); + person.setFirstName("Firstname"); + person.setEmail("myUserName05@"+account1.getId()); + person.setEnabled(true); + person.setPassword("banana"); Person p = people.create(person); assertEquals(true, p.isEnabled()); @@ -275,17 +271,16 @@ public class TestPeople extends EnterpriseTestApi // +ve: a random subset of fields should succeed. { - PersonUpdate person = new PersonUpdate.Builder(). - id("joe.bloggs@" + account1.getId()). - firstName("Joe"). - lastName("Bloggs"). - email("joe.bloggs@example.com"). - skypeId("jb.skype.id"). - telephone("1234 5678 9012"). - enabled(false). - emailNotificationsEnabled(false). - password("password123"). - build(); + Person person = new Person(); + person.setUserName("joe.bloggs@" + account1.getId()); + person.setFirstName("Joe"); + person.setLastName("Bloggs"); + person.setEmail("joe.bloggs@example.com"); + person.setSkypeId("jb.skype.id"); + person.setTelephone("1234 5678 9012"); + person.setEnabled(false); + person.setEmailNotificationsEnabled(false); + person.setPassword("password123"); Person p = people.create(person); @@ -309,13 +304,12 @@ public class TestPeople extends EnterpriseTestApi // +ve: absolute minimum { - PersonUpdate person = new PersonUpdate.Builder(). - id("joe.bloggs.2@"+account1.getId()). - firstName("Joe"). - email("joe.bloggs.2@example.com"). - enabled(true). - password("password-is-secret"). - build(); + Person person = new Person(); + person.setUserName("joe.bloggs.2@"+account1.getId()); + person.setFirstName("Joe"); + person.setEmail("joe.bloggs.2@example.com"); + person.setEnabled(true); + person.setPassword("password-is-secret"); Person p = people.create(person); @@ -340,9 +334,8 @@ public class TestPeople extends EnterpriseTestApi // -ve: not enough fields! { // Create a person with no fields set. - PersonUpdate person = new PersonUpdate.Builder(). - id("joe.bloggs.2@"+account1.getId()). - build(); + Person person = new Person(); + person.setUserName("joe.bloggs.2@"+account1.getId()); people.create(person, 400); } } @@ -382,12 +375,11 @@ public class TestPeople extends EnterpriseTestApi { // Invalid auth details publicApiClient.setRequestContext(new RequestContext(account1.getId(), GUID.generate(), "password")); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName01@"+account1.getId()). - firstName("Caroline"). - email("caroline.smithson@example.com"). - enabled(true). - build(); + Person person = new Person(); + person.setUserName("myUserName01@"+account1.getId()); + person.setFirstName("Caroline"); + person.setEmail("caroline.smithson@example.com"); + person.setEnabled(true); people.create(person, 401); } @@ -395,13 +387,12 @@ public class TestPeople extends EnterpriseTestApi { String apiUser = account2PersonIt.next(); publicApiClient.setRequestContext(new RequestContext(account2.getId(), apiUser)); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName02@"+account2.getId()). - firstName("Kieth"). - email("keith.smith@example.com"). - enabled(true). - password("password"). - build(); + Person person = new Person(); + person.setUserName("myUserName02@"+account2.getId()); + person.setFirstName("Kieth"); + person.setEmail("keith.smith@example.com"); + person.setEnabled(true); + person.setPassword("password"); people.create(person, 403); publicApiClient.setRequestContext(new RequestContext(account2.getId(), account2Admin, "admin")); @@ -412,13 +403,12 @@ public class TestPeople extends EnterpriseTestApi // -ve: person already exists { publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin")); - PersonUpdate person = new PersonUpdate.Builder(). - id("myUserName03@"+account1.getId()). - firstName("Alison"). - email("alison.smythe@example.com"). - enabled(true). - password("secret"). - build(); + Person person = new Person(); + person.setUserName("myUserName03@"+account1.getId()); + person.setFirstName("Alison"); + person.setEmail("alison.smythe@example.com"); + person.setEnabled(true); + person.setPassword("secret"); people.create(person); // Attempt to create the person a second time. @@ -426,11 +416,11 @@ public class TestPeople extends EnterpriseTestApi } } - public static class PersonUpdateJSONSerializer implements JSONAble + public static class PersonJSONSerializer implements JSONAble { - private final PersonUpdate personUpdate; + private final Person personUpdate; - public PersonUpdateJSONSerializer(PersonUpdate personUpdate) + public PersonJSONSerializer(Person personUpdate) { this.personUpdate = personUpdate; } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java index 13be59cb0f..7bd7bff6ac 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/PublicApiClient.java @@ -44,7 +44,6 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl; import org.alfresco.opencmis.CMISDispatcherRegistry.Binding; -import org.alfresco.rest.api.model.PersonUpdate; import org.alfresco.rest.api.model.SiteUpdate; import org.alfresco.rest.api.tests.TestPeople; import org.alfresco.rest.api.tests.TestSites; @@ -75,7 +74,6 @@ import org.apache.chemistry.opencmis.commons.enums.BindingType; import org.apache.chemistry.opencmis.commons.enums.UnfileObject; import org.apache.chemistry.opencmis.commons.enums.VersioningState; import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; -import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; @@ -1072,14 +1070,14 @@ public class PublicApiClient return retSite; } - public Person create(PersonUpdate person) throws PublicApiException + public Person create(Person person) throws PublicApiException { return create(person, 201); } - public Person create(PersonUpdate person, int expectedStatus) throws PublicApiException + public Person create(Person person, int expectedStatus) throws PublicApiException { - TestPeople.PersonUpdateJSONSerializer jsonizer = new TestPeople.PersonUpdateJSONSerializer(person) ; + TestPeople.PersonJSONSerializer jsonizer = new TestPeople.PersonJSONSerializer(person) ; HttpResponse response = create("people", null, null, null, jsonizer.toJSON().toString(), "Failed to create person", expectedStatus); if ((response != null) && (response.getJsonResponse() != null)) { diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java index dcb88324eb..f12c47c1c2 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java @@ -53,6 +53,11 @@ public class Person private static Collator collator = Collator.getInstance(); + public Person() + { + super(); + } + public Person(String id, String username, Boolean enabled, String firstName, String lastName, Company company, String skype, String location, String tel, String mob, String instantmsg, String google, String description) @@ -209,8 +214,7 @@ public class Person String userStatus = (String) jsonObject.get("userStatus"); Boolean enabled = (Boolean)jsonObject.get("enabled"); Boolean emailNotificationsEnabled = (Boolean) jsonObject.get("emailNotificationsEnabled"); - - // TODO: create a PersonCreate request class. + Person person = new Person( userId, enabled,