if (context.format == null) {
if (context.format == null)
    private MailItem resolveItem(Context context) throws ServiceException, UserServletException {        if (context.formatter != null && !context.formatter.requiresAuth())            return null;        MailItem item = null;        if (context.itemId != null) {            GetItemOperation op = new GetItemOperation(null, context.opContext, context.targetMailbox, Requester.REST, context.itemId.getId(), MailItem.TYPE_UNKNOWN);            op.schedule();            item = op.getItem();        } else if (context.imapId > 0) {            // fetch the folder from the path            GetFolderOperation gfop = new GetFolderOperation(null, context.opContext, context.targetMailbox, Requester.REST, context.itemPath);            gfop.schedule();            Folder folder = gfop.getFolder();            // and then fetch the item from the "imap_id" query parameter            GetItemOperation op = new GetItemOperation(null, context.opContext, context.targetMailbox, Requester.REST, context.imapId, folder.getId());            op.schedule();            item = op.getItem();        } else {            try {                // first, try the full path                GetItemOperation op = new GetItemOperation(null, context.opContext, context.targetMailbox, Requester.REST, context.itemPath, MailItem.TYPE_UNKNOWN);                op.schedule();                item = op.getItem();            } catch (NoSuchItemException nse) {                // no joy.  Perhaps they asked for something like "calendar.csv" -- where calendar was the folder name                // Try again, minus the extension                /*                 * if path == /foo/bar/baz.html, then                 * format   -> html                 * and                 * path ends up as /foo/bar/baz                 */                int dot = context.itemPath.lastIndexOf('.');                if (dot != -1) {                    if (context.format == null) {                        context.format = context.itemPath.substring(dot + 1);                    }                    context.itemPath = context.itemPath.substring(0, dot);                }                // try again, w/ the extension removed...                GetItemOperation op = new GetItemOperation(null, context.opContext, context.targetMailbox, Requester.REST, context.itemPath, MailItem.TYPE_UNKNOWN);                op.schedule();                item = op.getItem();            }        }                if (item == null && context.getQueryString() == null)            throw new UserServletException(HttpServletResponse.SC_BAD_REQUEST, "item not found");                return item;    }