Search in sources :

Example 36 with ListResponse

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

the class Favourite method parseFavourites.

public static ListResponse<Favourite> parseFavourites(JSONObject jsonObject) throws ParseException {
    List<Favourite> favourites = new ArrayList<Favourite>();
    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");
        favourites.add(Favourite.parseFavourite(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<Favourite>(paging, favourites);
}
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 37 with ListResponse

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

the class SiteMembershipRequest method parseSiteMembershipRequests.

public static ListResponse<SiteMembershipRequest> parseSiteMembershipRequests(JSONObject jsonObject) throws ParseException {
    List<SiteMembershipRequest> siteMembershipRequests = new ArrayList<SiteMembershipRequest>();
    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");
        siteMembershipRequests.add(SiteMembershipRequest.parseSiteMembershipRequest(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<>(paging, siteMembershipRequests);
}
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 38 with ListResponse

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

the class NodeRating method parseNodeRatings.

public static ListResponse<NodeRating> parseNodeRatings(String nodeId, JSONObject jsonObject) {
    List<NodeRating> nodeRatings = new ArrayList<NodeRating>();
    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");
        nodeRatings.add(NodeRating.parseNodeRating(nodeId, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<NodeRating> resp = new ListResponse<NodeRating>(paging, nodeRatings);
    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 39 with ListResponse

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

the class Preference method parsePreferences.

public static ListResponse<Preference> parsePreferences(JSONObject jsonObject) {
    List<Preference> preferences = new ArrayList<Preference>();
    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");
        preferences.add(Preference.parsePreference(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<Preference> resp = new ListResponse<Preference>(paging, preferences);
    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 40 with ListResponse

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

the class PersonNetwork method parseNetworkMembers.

public static ListResponse<PersonNetwork> parseNetworkMembers(JSONObject jsonObject) {
    List<PersonNetwork> networkMembers = new ArrayList<PersonNetwork>();
    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");
        networkMembers.add(PersonNetwork.parseNetworkMember(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<PersonNetwork> resp = new ListResponse<PersonNetwork>(paging, networkMembers);
    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)

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