final int endIndex = (request.getEndRow() == null) ? -1 : request.getEndRow();
final int pageSize = (endIndex != -1) ? (endIndex - startIndex) : GWTConstants.MESSAGE_LIST_PAGE_SIZE;
final String folderId = GWTSessionManager.get().getCurrentMailFolder().getId();
boolean ascending = true;
MessageListFields sortColumn = null;
if ( request.getSortBy() != null && request.getSortBy().length > 0 ) {
SortSpecifier sortSpec = request.getSortBy()[0];
sortColumn = MessageListFields.valueOf( sortSpec.getField() );
ascending = SortDirection.ASCENDING == sortSpec.getSortDirection();