Search in sources :

Example 1 with AccountNameSelector

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);
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AccountNameSelector(com.zimbra.soap.type.AccountNameSelector) Provisioning(com.zimbra.cs.account.Provisioning) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest) AccountBy(com.zimbra.common.account.Key.AccountBy)

Aggregations

AccountBy (com.zimbra.common.account.Key.AccountBy)1 Account (com.zimbra.cs.account.Account)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 LockoutMailboxRequest (com.zimbra.soap.admin.message.LockoutMailboxRequest)1 AccountNameSelector (com.zimbra.soap.type.AccountNameSelector)1