use of com.zimbra.soap.admin.type.MailboxWithMailboxId in project zm-mailbox by Zimbra.
the class PurgeMessages method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Element mreq = request.getOptionalElement(AdminConstants.E_MAILBOX);
String[] accounts;
if (mreq != null) {
accounts = new String[] { mreq.getAttribute(AdminConstants.A_ACCOUNTID) };
// accounts are specified, check right or each account
Provisioning prov = Provisioning.getInstance();
for (String acctId : accounts) {
Account acct = prov.get(AccountBy.id, acctId);
if (acct == null)
throw AccountServiceException.NO_SUCH_ACCOUNT(acctId);
checkAccountRight(zsc, acct, Admin.R_purgeMessages);
}
} else {
// all accounts on the system, has to be a system admin
checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
accounts = MailboxManager.getInstance().getAccountIds();
}
PurgeMessagesResponse purgeResponse = new PurgeMessagesResponse();
for (int i = 0; i < accounts.length; i++) {
Account account = Provisioning.getInstance().getAccountById(accounts[i]);
if (account == null)
continue;
MailboxWithMailboxId mboxResp;
if (Provisioning.onLocalServer(account)) {
// local
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
if (mbox == null)
continue;
mbox.purgeMessages(null);
mboxResp = new MailboxWithMailboxId(mbox.getId(), account.getId(), Long.valueOf(mbox.getSize()));
} else {
// remote
Server server = account.getServer();
if (server == null)
continue;
SoapProvisioning soapProvisioning = SoapProvisioning.getAdminInstance();
mboxResp = soapProvisioning.purgeMessages(account);
if (mboxResp == null)
continue;
mboxResp.setAccountId(account.getId());
}
purgeResponse.addMailbox(mboxResp);
}
return JaxbUtil.jaxbToElement(purgeResponse);
}
use of com.zimbra.soap.admin.type.MailboxWithMailboxId in project zm-mailbox by Zimbra.
the class GetMailbox method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
GetMailboxRequest req = JaxbUtil.elementToJaxb(request);
String accountId = req.getMbox().getId();
Account account = Provisioning.getInstance().get(AccountBy.id, accountId, zsc.getAuthToken());
defendAgainstAccountHarvesting(account, AccountBy.id, accountId, zsc, Admin.R_getMailboxInfo);
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
GetMailboxResponse resp = new GetMailboxResponse(new MailboxWithMailboxId(mbox.getId(), null, mbox.getSize()));
return zsc.jaxbToElement(resp);
}
Aggregations