Currently, section 2.3 of the Core Data Specification says this...
Many service operations return a list of OpenSocial resources. Lists
are always returned in the "list" field of the result. Lists can
either be the full set of resources or a pageable subset. If the
operation supports random access indexing of the full list it will
support the "startIndex" and "count" parameters which control what
sublist of the full list is returned. The paging mechanisms described
here are based on the OpenSearch standard with the additional
requirement that all indexes are 0 based.
Section 2.4 of the specification says this...
OpenSocial 2.0 has incorporated support for the Activity Streams
community specification. This specification also defines a collection
structure. In order to maintain compatibility with endpoints that
expect an Activity Streams collection definition, OpenSocial
containers SHOULD append the additional fields onto collection
structures that are returned from the ActivityStreams service.
Note: The OpenSocial specification declares that extensions should be
wrapped in "tags" that "namespace" the extended fields. This is done
primarily to avoid collisions. However, an endpoint that is configured
to receive an Activity Stream collection would not expect collection
fields to be wrapped. Therefore, in order to support interoperability,
an exception has been made for OpenSocial Collection. Fields from
Activity Streams Collection SHOULD be appended directly to OpenSocial
Collection.
Collection = "{"
"result : {"
[ "totalResults : " number "," ]
[ "startIndex : " number "," ]
[ "itemsPerPage : " number "," ]
[ "filtered : " ( "true" / "false" ) "," ]
[ "updatedSince : " ( "true" / "false" ) "," ]
[ "sorted : " ( "true" / "false" ) "," ]
[ "itemsPerPage : " number "," ]
"entry :" Array<Object>
"}"
"}"
Within the JSON Activity Streams format, a Collection Object is
defined as having "url", "totalItems" and "items" properties... where
the array of items is contained within the "items" property... e.g.
{
"totalItems": 10,
"items": [ ... ]
}
Obviously we have some inconsistency here, and it's a problem. For
3.0, we need to clean this up.
What I propose is that, in 3.0, we baseline on the Activity Streams
Collection Object. Meaning that within Core Data, sections 2.3 and 2.4
will be changed. When I ask for a list of items back from the server,
regardless of whether it's a collection of Activities or any other
kind of object, what we'd get back would be...
{
"totalItems" : 10,
"items": [ ... ]
}
Right now, the ONLY thing that is said about paging is the last
sentence in section 2.3, "The paging mechanism described here are
based on the OpenSearch standard with the additional requirement that
all indexes are 0 based." The challenge with this is that it's never
actually defined what this means... What I recommend is the following
convention within 3.0...
{
"$next": "http://next.page.link",
"$previous": "http://previous.page.link",
"$first": "http://first.page.link",
"$last": "http://last.page.link"
"startIndex": 0,
"itemsPerPage": 10,
"totalItems": 100,
"items": [...]
}
Each of the $ prefixed fields are links. The names identified the
relevant Link Relation Names from the IANA registry.
I would also recommend that we simply deprecate the filtered, sorted
and updatedSince extra properties defined for the Activity Streams
collection as they do not really add any real value to the base
functionality that I can determine.
- James