uriInfo.getOrderBy(),
uriInfo.getSkipToken(),
uriInfo.getSkip(),
uriInfo.getTop());
ODataContext context = getContext();
String nextLink = null;
// Limit the number of returned entities and provide a "next" link
// if there are further entities.
// Almost all system query options in the current request must be carried
// over to the URI for the "next" link, with the exception of $skiptoken
// and $skip.
if (data.size() > SERVER_PAGING_SIZE) {
if (uriInfo.getOrderBy() == null
&& uriInfo.getSkipToken() == null
&& uriInfo.getSkip() == null
&& uriInfo.getTop() == null) {
sortInDefaultOrder(entitySet, data);
}
nextLink = context.getPathInfo().getServiceRoot().relativize(context.getPathInfo().getRequestUri()).toString();
nextLink = percentEncodeNextLink(nextLink);
nextLink += (nextLink.contains("?") ? "&" : "?")
+ "$skiptoken=" + getSkipToken(entitySet, data.get(SERVER_PAGING_SIZE));
while (data.size() > SERVER_PAGING_SIZE) {
data.remove(SERVER_PAGING_SIZE);
}
}
final EdmEntityType entityType = entitySet.getEntityType();
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (final Object entryData : data) {
values.add(getStructuralTypeValueMap(entryData, entityType));
}
final EntityProviderWriteProperties feedProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot())
.inlineCountType(inlineCountType)
.inlineCount(count)
.expandSelectTree(UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand()))
.callbacks(getCallbacks(data, entityType))
.nextLink(nextLink)
.build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeFeed");
final ODataResponse response = EntityProvider.writeFeed(contentType, entitySet, values, feedProperties);
context.stopRuntimeMeasurement(timingHandle);
return ODataResponse.fromResponse(response).build();
}