Search in sources :

Example 46 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class ModifyIdentity method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    Identity identity = null;
    if (!canModifyOptions(zsc, account))
        throw ServiceException.PERM_DENIED("can not modify options");
    Provisioning prov = Provisioning.getInstance();
    Element eIdentity = request.getElement(AccountConstants.E_IDENTITY);
    Map<String, Object> attrs = AccountService.getAttrs(eIdentity, AccountConstants.A_NAME);
    // remove anything that doesn't start with zimbraPref. ldap will also do additional checks
    for (Iterator<String> it = attrs.keySet().iterator(); it.hasNext(); ) if (// if this changes, make sure we don't let them ever change objectclass
    !it.next().toLowerCase().startsWith("zimbrapref"))
        it.remove();
    String key, id = eIdentity.getAttribute(AccountConstants.A_ID, null);
    if (id != null) {
        identity = prov.get(account, Key.IdentityBy.id, key = id);
    } else {
        identity = prov.get(account, Key.IdentityBy.name, key = eIdentity.getAttribute(AccountConstants.A_NAME));
    }
    if (identity == null) {
        String[] childIds = account.getChildAccount();
        for (String childId : childIds) {
            Account childAccount = prov.get(AccountBy.id, childId, zsc.getAuthToken());
            if (childAccount != null) {
                Identity childIdentity;
                if (id != null) {
                    childIdentity = prov.get(childAccount, Key.IdentityBy.id, key = id);
                } else {
                    childIdentity = prov.get(childAccount, Key.IdentityBy.name, key = eIdentity.getAttribute(AccountConstants.A_NAME));
                }
                if (childIdentity != null) {
                    identity = childIdentity;
                    account = childAccount;
                    break;
                }
            }
        }
    }
    if (identity == null)
        throw AccountServiceException.NO_SUCH_IDENTITY(key);
    prov.modifyIdentity(account, identity.getName(), attrs);
    Element response = zsc.createElement(AccountConstants.MODIFY_IDENTITY_RESPONSE);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Identity(com.zimbra.cs.account.Identity) Provisioning(com.zimbra.cs.account.Provisioning)

Example 47 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetAllLocales method handle.

@Override
public Element handle(Element request, Map<String, Object> context) {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Locale[] locales = WebClientL10nUtil.getAllLocalesSorted();
    Element response = zsc.createElement(AccountConstants.GET_ALL_LOCALES_RESPONSE);
    for (Locale locale : locales) {
        ToXML.encodeLocale(response, locale, Locale.US);
    }
    return response;
}
Also used : Locale(java.util.Locale) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element)

Example 48 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetAvailableLocales method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    if (!canAccessAccount(zsc, account)) {
        throw ServiceException.PERM_DENIED("can not access account");
    }
    Locale displayLocale = getDisplayLocale(account, context);
    // get installed locales, sorted
    Locale[] installedLocales = WebClientL10nUtil.getLocales(displayLocale);
    // get avail locales for this account/COS
    Set<String> allowedLocales = account.getMultiAttrSet(Provisioning.A_zimbraAvailableLocale);
    Locale[] availLocales = null;
    if (allowedLocales.size() > 0) {
        availLocales = computeAvailLocales(installedLocales, allowedLocales);
    } else {
        availLocales = installedLocales;
    }
    Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_LOCALES_RESPONSE);
    for (Locale locale : availLocales) {
        if (locale != null) {
            ToXML.encodeLocale(response, locale, displayLocale);
        } else {
            break;
        }
    }
    return response;
}
Also used : Locale(java.util.Locale) Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element)

Example 49 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetAvailableSkins method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    if (!canAccessAccount(zsc, account)) {
        throw ServiceException.PERM_DENIED("can not access account");
    }
    String[] availSkins = SkinUtil.getSkins(account);
    Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_SKINS_RESPONSE);
    for (String skin : availSkins) {
        Element skinElem = response.addElement(AccountConstants.E_SKIN);
        skinElem.addAttribute(AccountConstants.A_NAME, skin);
    }
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element)

Example 50 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetDistributionList method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Account acct = getAuthenticatedAccount(zsc);
    Element response = zsc.createElement(AccountConstants.GET_DISTRIBUTION_LIST_RESPONSE);
    Group group = getGroupBasic(request, prov);
    GetDistributionListHandler handler = new GetDistributionListHandler(group, request, response, prov, acct);
    handler.handle();
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)382 Element (com.zimbra.common.soap.Element)315 Provisioning (com.zimbra.cs.account.Provisioning)162 Account (com.zimbra.cs.account.Account)158 Mailbox (com.zimbra.cs.mailbox.Mailbox)106 OperationContext (com.zimbra.cs.mailbox.OperationContext)82 ItemId (com.zimbra.cs.service.util.ItemId)58 Server (com.zimbra.cs.account.Server)47 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)44 ServiceException (com.zimbra.common.service.ServiceException)40 HashMap (java.util.HashMap)37 Domain (com.zimbra.cs.account.Domain)32 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)23 IOException (java.io.IOException)20 Group (com.zimbra.cs.account.Group)17 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)17 Message (com.zimbra.cs.mailbox.Message)17 MimeMessage (javax.mail.internet.MimeMessage)16 Map (java.util.Map)15