String idStr = hit.getMailboxIdStr() + "/" + hit.getItemId(); e.addAttribute(MailService.A_ID, idStr);
ItemId iid = new ItemId(hit.getAcctIdStr(), hit.getItemId()); e.addAttribute(MailService.A_ID, iid.toString());
    protected Element putHits(ZimbraContext lc, Element response, ResultsPager pager, boolean includeMailbox, SearchParams params)    throws ServiceException {        int offset = params.getOffset();        int limit  = params.getLimit();        EmailElementCache eecache = new EmailElementCache();                    if (mLog.isDebugEnabled())            mLog.debug("Search results beginning with offset "+offset);                int totalNumHits = 0;                for (Iterator iter = pager.getHits().iterator(); iter.hasNext();) {            ZimbraHit hit = (ZimbraHit)iter.next();            //          for (ZimbraHit hit = results.skipToHit(offset); hit != null; hit = results.getNext()) {            totalNumHits++;            boolean inline = (totalNumHits == 1 && params.getFetchFirst());            boolean addSortField = true;            Element e = null;            if (hit instanceof ConversationHit) {                ConversationHit ch = (ConversationHit) hit;                e = addConversationHit(lc, response, ch, eecache, params);            } else if (hit instanceof MessageHit) {                MessageHit mh = (MessageHit) hit;                e = addMessageHit(lc, response, mh, eecache, inline, params);            } else if (hit instanceof MessagePartHit) {                MessagePartHit mph = (MessagePartHit) hit;                e = addMessagePartHit(response, mph, eecache);                            } else if (hit instanceof ContactHit) {                ContactHit ch = (ContactHit) hit;                e = ToXML.encodeContact(response, lc, ch.getContact(), null, true, null);            } else if (hit instanceof NoteHit) {                NoteHit nh = (NoteHit) hit;                e = ToXML.encodeNote(response,lc, nh.getNote());            } else if (hit instanceof ProxiedHit) {                ProxiedHit ph = (ProxiedHit) hit;                e = ph.getElement().detach();                response.addElement(e);                addSortField = false;            } else if (hit instanceof AppointmentHit) {                AppointmentHit ah = (AppointmentHit)hit;                e = addAppointmentHit(lc, response, ah, inline, params);            } else {                mLog.error("Got an unknown hit type putting search hits: "+hit);            }            if (e != null && addSortField) {            	e.addAttribute(MailService.A_SORT_FIELD, hit.getSortField(pager.getSortOrder()).toString());            }            if (includeMailbox) {                String idStr = hit.getMailboxIdStr() + "/" + hit.getItemId();                e.addAttribute(MailService.A_ID, idStr);            }            if (totalNumHits >= limit) {                if (mLog.isDebugEnabled()) {                    mLog.debug("Search results limited to " + limit + " hits.");                }                break;            }        }        response.addAttribute(MailService.A_QUERY_MORE, pager.hasNext());                return response;    }