
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
We will now follow Gavin Cornwell https://community.alfresco.com/community/ecm/blog/2017/04/18/v1-rest-api-part-10-people examples and see how we can achieve the same experience using the SDK
To make the exercise more concise we will execute each request in a synchronous way.
Important Notice
Alfresco Java Client is currently in Early Access mode. It evolves as you use them, as you give feedback, and as the developers update and add file. We like to think app & lib development as services that grow and evolve with the involvement of the community.
Prerequisites
In order to follow along you'll need an environment to do so, firstly download and install the 5.2.c Early Access Community Release. In our case we will consider Alfresco is available at http://localhost:8080/alfresco and the "admin" user is available and has "admin" as password.
Create person
//Create PersonPeopleAPI peopleAPI = client.getPeopleAPI();PersonBodyCreate bodyCreate = new PersonBodyCreate("jdoe").firstName("John").lastName("Doe") .email("john.doe@example.com").password("jdoe").skypeId("johndoe_skype").jobTitle("Software Engineer");PersonRepresentation personRepresentation = peopleAPI.createPersonCall(bodyCreate).execute().body();Assert.assertEquals(personRepresentation.getId(), "jdoe");Assert.assertEquals(personRepresentation.getFirstName(), "John");Assert.assertEquals(personRepresentation.getLastName(), "Doe");Assert.assertEquals(personRepresentation.getEmail(), "john.doe@example.com");Assert.assertEquals(personRepresentation.getSkypeId(), "johndoe_skype");Assert.assertEquals(personRepresentation.getJobTitle(), "Software Engineer");
List people
ResultPaging<PersonRepresentation> personList = peopleAPI.listPeopleCall().execute().body();Assert.assertEquals(personList.getCount(), 7);
Find people
ResultPaging<PersonRepresentation> searchPersonList = client.getQueriesAPI().findPeopleCall("jdoe").execute().body();Assert.assertEquals(searchPersonList.getCount(), 1);Assert.assertEquals(searchPersonList.getList().get(0).getId(), "jdoe");
Person Details
PersonRepresentation jdoeDetails = peopleAPI.getPersonCall("jdoe").execute().body();Assert.assertEquals(jdoeDetails.getId(), "jdoe");Assert.assertEquals(jdoeDetails.getFirstName(), "John");Assert.assertEquals(jdoeDetails.getLastName(), "Doe");Assert.assertEquals(jdoeDetails.getEmail(), "john.doe@example.com");Assert.assertEquals(jdoeDetails.getSkypeId(), "johndoe_skype");Assert.assertEquals(jdoeDetails.getJobTitle(), "Software Engineer");
Update person details
PersonBodyUpdate bodyUpdate = new PersonBodyUpdate().firstName("Johnathon").mobile("07000 123456");PersonRepresentation updatedPerson = peopleAPI.updatePersonCall("jdoe", bodyUpdate, null).execute().body();Assert.assertEquals(updatedPerson.getMobile(), "07000 123456");Assert.assertEquals(updatedPerson.getFirstName(), "Johnathon");
Change password
PersonBodyUpdate changePassword = new PersonBodyUpdate().oldPassword("jdoe").password("my-new-password");PersonRepresentation updatedPPerson = peopleAPI.updatePersonCall("jdoe", changePassword, null).execute().body();
Disable person
PersonBodyUpdate disablePersonBody = new PersonBodyUpdate().enabled(false);PersonRepresentation disablePerson = peopleAPI.updatePersonCall("jdoe", disablePersonBody, null).execute().body();Assert.assertEquals(disablePerson.isEnabled(), Boolean.FALSE);
Alfresco Java Client SDK Series
- https://community.alfresco.com/community/ecm/blog/2016/11/17/alfresco-java-client-sdk
- https://community.alfresco.com/community/ecm/blog/2016/11/16/alfresco-java-client-sdk-usage
- https://community.alfresco.com/community/ecm/blog/2016/11/16/alfresco-java-client-sdk-usage-part-3
- https://community.alfresco.com/community/ecm/blog/2016/11/16/alfresco-java-client-sdk-usage-part-4
- https://community.alfresco.com/community/ecm/blog/2016/11/16/alfresco-java-client-sdk-usage-part-5
- https://community.alfresco.com/community/ecm/blog/2016/11/25/alfresco-java-client-sdk-usage-part-6
- https://community.alfresco.com/community/ecm/blog/2017/04/26/alfresco-java-client-sdk-usage-part-7
- https://community.alfresco.com/community/ecm/blog/2017/04/26/alfresco-java-client-sdk-usage-part-8
- https://community.alfresco.com/community/ecm/blog/2017/04/26/alfresco-java-client-sdk-usage-part-9
- https://community.alfresco.com/community/ecm/blog/2017/04/26/alfresco-java-client-sdk-usage-part-10
- https://community.alfresco.com/community/ecm/blog/2017/04/26/alfresco-java-client-sdk-usage-part-11
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.