Search in sources :

Example 1 with IndexStats

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;
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) IndexStats(com.zimbra.cs.mailbox.MailboxIndex.IndexStats) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 CalendarResource (com.zimbra.cs.account.CalendarResource)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 IndexStats (com.zimbra.cs.mailbox.MailboxIndex.IndexStats)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1