startEvent = Long.parseLong( indices[0] );
endEvent = Long.parseLong( indices[1] );
limit = 1+endEvent-startEvent;
} else
throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
if (startEvent > 0)
{
long previousStart = Math.max(0, startEvent-pageSize);
long previousEnd = startEvent-1;
Link link = new Link( new Reference( previousStart+","+previousEnd ), new Relation( "previous" ), MediaType.APPLICATION_ATOM );
link.setTitle( "Previous page" );
links.add( link );
}
long nextStart = endEvent+1;
long nextEnd = nextStart+pageSize-1;
if (nextStart < eventCount)
if (nextEnd >= eventCount)
{
Link next = new Link( new Reference( nextStart+"" ), new Relation( "next" ), MediaType.APPLICATION_ATOM );
next.setTitle( "Working set" );
links.add( next );
} else
{
Link next = new Link( new Reference( nextStart+","+nextEnd ), new Relation( "next" ), MediaType.APPLICATION_ATOM );
next.setTitle( "Next page" );
links.add( next );
}
}
try
{
source.events( startEvent, limit ).transferTo( Outputs.collection( eventsValues ) );
} catch (Throwable throwable)
{
throw new ResourceException( Status.SERVER_ERROR_INTERNAL, throwable );
}
Link last = new Link( new Reference( "0,"+(pageSize-1) ), new Relation( "last" ), MediaType.APPLICATION_ATOM );
last.setTitle( "Last archive page" );
links.add( last );