@Override
public PagedSet<T> execute(final ServiceActionContext inActionContext) throws ExecutionException
{
PagedSet<T> galleryItems = null;
GetGalleryItemsRequest currentRequest = (GetGalleryItemsRequest) inActionContext.getParams();
if (currentRequest.getSortCriteria().equals(POPULARITY_SORT_CRITERIA))
{
if (!currentRequest.getCategory().isEmpty())
{
galleryItems = mapper.findForCategorySortedByPopularity(currentRequest.getCategory(), currentRequest
.getStartIndex(), currentRequest.getEndIndex());
}
else
{
galleryItems = mapper.findSortedByPopularity(currentRequest.getStartIndex(), currentRequest
.getEndIndex());
}
}
else if (currentRequest.getSortCriteria().equals(RECENT_SORT_CRITERIA))
{
if (!currentRequest.getCategory().isEmpty())
{
galleryItems = mapper.findForCategorySortedByRecent(currentRequest.getCategory(), currentRequest
.getStartIndex(), currentRequest.getEndIndex());
}
else
{
galleryItems = mapper.findSortedByRecent(currentRequest.getStartIndex(), currentRequest.getEndIndex());
}
}
// the calls and concatenations could slow things down