Search in sources :

Example 6 with ListResponse

use of org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse in project alfresco-remote-api by Alfresco.

the class Person method parsePeople.

public static ListResponse<Person> parsePeople(JSONObject jsonObject) {
    List<Person> people = new ArrayList<Person>();
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);
    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);
    for (int i = 0; i < jsonEntries.size(); i++) {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        people.add(parsePerson(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<Person> resp = new ListResponse<Person>(paging, people);
    return resp;
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Example 7 with ListResponse

use of org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse in project alfresco-remote-api by Alfresco.

the class SiteContainer method parseSiteContainers.

public static ListResponse<SiteContainer> parseSiteContainers(JSONObject jsonObject) {
    List<SiteContainer> siteContainers = new ArrayList<SiteContainer>();
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);
    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);
    for (int i = 0; i < jsonEntries.size(); i++) {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        siteContainers.add(SiteContainer.parseSiteContainer(null, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<SiteContainer> resp = new ListResponse<SiteContainer>(paging, siteContainers);
    return resp;
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Example 8 with ListResponse

use of org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse in project alfresco-remote-api by Alfresco.

the class SiteMember method parseSiteMembers.

public static ListResponse<SiteMember> parseSiteMembers(String siteId, JSONObject jsonObject) {
    List<SiteMember> siteMembers = new ArrayList<SiteMember>();
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);
    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);
    for (int i = 0; i < jsonEntries.size(); i++) {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        siteMembers.add(parseSiteMember(siteId, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<SiteMember> resp = new ListResponse<SiteMember>(paging, siteMembers);
    return resp;
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Example 9 with ListResponse

use of org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse in project alfresco-remote-api by Alfresco.

the class Tag method parseTags.

public static ListResponse<Tag> parseTags(String nodeId, JSONObject jsonObject) {
    List<Tag> tags = new ArrayList<Tag>();
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);
    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);
    for (int i = 0; i < jsonEntries.size(); i++) {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        tags.add(parseTag(nodeId, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<Tag> resp = new ListResponse<Tag>(paging, tags);
    return resp;
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Example 10 with ListResponse

use of org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse in project alfresco-remote-api by Alfresco.

the class FavouriteSite method parseFavouriteSites.

public static ListResponse<FavouriteSite> parseFavouriteSites(JSONObject jsonObject) {
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    List<FavouriteSite> favouriteSites = new ArrayList<FavouriteSite>(jsonList.size());
    if (jsonList != null) {
        JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
        if (jsonEntries != null) {
            for (int i = 0; i < jsonEntries.size(); i++) {
                JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
                JSONObject entry = (JSONObject) jsonEntry.get("entry");
                favouriteSites.add(parseFavouriteSite(entry));
            }
        }
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<FavouriteSite>(paging, favouriteSites);
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Aggregations

ListResponse (org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse)41 ArrayList (java.util.ArrayList)30 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)22 JSONObject (org.json.simple.JSONObject)21 Test (org.junit.Test)21 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)20 ExpectedPaging (org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)19 JSONArray (org.json.simple.JSONArray)19 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)18 List (java.util.List)13 TestSite (org.alfresco.rest.api.tests.RepoService.TestSite)10 TenantRunAsWork (org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork)8 TestNetwork (org.alfresco.rest.api.tests.RepoService.TestNetwork)8 TestPerson (org.alfresco.rest.api.tests.RepoService.TestPerson)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Sites (org.alfresco.rest.api.tests.client.PublicApiClient.Sites)6 People (org.alfresco.rest.api.tests.client.PublicApiClient.People)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 ParseException (java.text.ParseException)4