use of com.zimbra.soap.type.AccountNameSelector in project zm-mailbox by Zimbra.
the class LockoutMailbox method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = super.getZimbraSoapContext(context);
LockoutMailboxRequest req = JaxbUtil.elementToJaxb(request);
AccountNameSelector acctSel = req.getAccount();
if (acctSel == null) {
throw ServiceException.INVALID_REQUEST(String.format("missing <%s>", AdminConstants.E_ACCOUNT), null);
}
String accountSelectorKey = acctSel.getKey();
AccountBy by = acctSel.getBy().toKeyAccountBy();
Provisioning prov = Provisioning.getInstance();
Account account = prov.get(by, accountSelectorKey, zsc.getAuthToken());
defendAgainstAccountOrCalendarResourceHarvesting(account, by, accountSelectorKey, zsc, Admin.R_moveAccountMailbox, Admin.R_moveCalendarResourceMailbox);
// Reload account to pick up any changes made by other servers.
prov.reload(account);
// check rights
checkRights(zsc, context, account);
String method = request.getAttribute(AdminConstants.A_OPERATION, AdminConstants.A_START);
if (method.equalsIgnoreCase(AdminConstants.A_START)) {
MailboxManager.getInstance().lockoutMailbox(account.getId());
} else if (method.equalsIgnoreCase(AdminConstants.A_END)) {
MailboxManager.getInstance().undoLockout(account.getId());
} else {
throw ServiceException.FAILURE("Unknown lockout method " + method, null);
}
return zsc.createElement(AdminConstants.LOCKOUT_MAILBOX_RESPONSE);
}
Aggregations