use of com.zimbra.cs.mailbox.MailboxIndex.IndexStats in project zm-mailbox by Zimbra.
the class GetIndexStats method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Element mreq = request.getElement(AdminConstants.E_MAILBOX);
String accountId = mreq.getAttribute(AdminConstants.A_ACCOUNTID);
Provisioning prov = Provisioning.getInstance();
Account account = prov.get(AccountBy.id, accountId, zsc.getAuthToken());
if (account == null) {
throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
}
if (account.isCalendarResource()) {
// need a CalendarResource instance for RightChecker
CalendarResource resource = prov.get(Key.CalendarResourceBy.id, account.getId());
checkCalendarResourceRight(zsc, resource, Admin.R_reindexCalendarResourceMailbox);
} else {
checkAccountRight(zsc, account, Admin.R_reindexMailbox);
}
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
if (mbox == null) {
throw ServiceException.FAILURE("mailbox not found for account " + accountId, null);
}
Element response = zsc.createElement(AdminConstants.GET_INDEX_STATS_RESPONSE);
IndexStats stats = mbox.index.getIndexStats();
Element statsElem = response.addElement(AdminConstants.E_STATS);
statsElem.addAttribute(AdminConstants.A_MAX_DOCS, stats.getMaxDocs());
statsElem.addAttribute(AdminConstants.A_DELETED_DOCS, stats.getNumDeletedDocs());
return response;
}
Aggregations