@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); } checkAdminLoginAsRight(zsc, prov, account); Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false); if (mbox == null) { throw MailServiceException.NO_SUCH_MBOX(accountId); } mbox.recalculateFolderAndTagCounts(); Element response = zsc.createElement(AdminConstants.RECALCULATE_MAILBOX_COUNTS_RESPONSE); response .addElement(AdminConstants.E_MAILBOX) .addAttribute(AdminConstants.A_ACCOUNTID, accountId) .addAttribute(AdminConstants.A_QUOTA_USED, mbox.getSize()); return response; }