use of com.zimbra.cs.index.DocumentHit in project zm-mailbox by Zimbra.
the class SearchResponse method add.
/* We need to pass in a boolean signifying whether to expand the message or not (bug 75990)
*/
void add(ZimbraHit hit, boolean expandMsg) throws ServiceException {
Element el = null;
if (params.getFetchMode() == SearchParams.Fetch.IDS) {
if (hit instanceof ConversationHit) {
// need to expand the contained messages
el = element.addElement(MailConstants.E_HIT);
el.addAttribute(MailConstants.A_ID, ifmt.formatItemId(hit.getParsedItemID()));
} else {
el = element.addElement(MailConstants.E_HIT);
el.addAttribute(MailConstants.A_ID, ifmt.formatItemId(hit.getParsedItemID()));
}
} else if (hit instanceof ProxiedHit) {
element.addElement(((ProxiedHit) hit).getElement().detach());
size++;
return;
} else {
if (hit instanceof ConversationHit) {
el = add((ConversationHit) hit);
} else if (hit instanceof MessageHit) {
el = add((MessageHit) hit, expandMsg);
} else if (hit instanceof MessagePartHit) {
el = add((MessagePartHit) hit);
} else if (hit instanceof ContactHit) {
el = add((ContactHit) hit);
} else if (hit instanceof NoteHit) {
el = add((NoteHit) hit);
} else if (hit instanceof CalendarItemHit) {
// el could be null
el = add((CalendarItemHit) hit);
} else if (hit instanceof DocumentHit) {
el = add((DocumentHit) hit);
} else {
LOG.error("Got an unknown hit type putting search hits: " + hit);
return;
}
}
if (el != null) {
size++;
el.addAttribute(MailConstants.A_SORT_FIELD, hit.getSortField(sortOrder).toString());
if (includeMailbox) {
el.addAttribute(MailConstants.A_ID, new ItemId(hit.getAcctIdStr(), hit.getItemId()).toString());
}
}
}
Aggregations