public ListRecordsResponse processRequest(TokenListRequest req, int pos, SearchResult result, ServiceContext context) throws Exception {
int num = 0;
ListRecordsResponse res = new ListRecordsResponse();
//--- loop to retrieve metadata
while (num<Lib.MAX_RECORDS && pos < result.getIds().size())
{
int id = result.getIds().get(pos);
Record r = buildRecord(context, id, result.prefix);
if (r != null)
{
res.addRecord(r);
num++;
}
pos++;
}