Search in sources :

Example 1 with DLMembersResult

use of com.zimbra.cs.gal.GalGroupMembers.DLMembersResult in project zm-mailbox by Zimbra.

the class GetDistributionListMembers 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");
    }
    Element eDL = request.getElement(AdminConstants.E_DL);
    String dlName = eDL.getText();
    int offset = getOffset(request);
    int limit = getLimit(request);
    // null offset/limit and set _offset/_limit before calling searchGal().
    request.addAttribute(MailConstants.A_QUERY_OFFSET, (String) null);
    request.addAttribute(MailConstants.A_LIMIT, (String) null);
    request.addAttribute(AccountConstants.A_OFFSET_INTERNAL, offset);
    request.addAttribute(AccountConstants.A_LIMIT_INTERNAL, limit);
    boolean proxiedToHomeOfInternalGroup = request.getAttributeBool(A_PROXIED_TO_HOME_OF_GROUP, false);
    DLMembersResult dlMembersResult = null;
    /*
         * see if the group is an internal group
         */
    Provisioning prov = Provisioning.getInstance();
    Group group = prov.getGroupBasic(DistributionListBy.name, dlName);
    if (group != null) {
        /*
             * Is an internal group, get members from LDAP instead of GAL
             * for group owners and members.
             *
             * This makes updates on internal groups reflected in the UI
             * sooner than the next GSA delta sync cycle for group owners and members.
             * (bug 72482 and bug 73460).
             */
        dlMembersResult = getMembersFromLdap(context, request, account, group, proxiedToHomeOfInternalGroup);
    }
    if (dlMembersResult == null) {
        /*
             * - this is not an internal group, or
             * - this is an internal group but the requesting account is not an owner
             *   or member of the group, or
             * - this is an internal hideInGal group and the requesting account is not
             *   an owner of the group.
             *
             * Do GAL search if this is not a hideInGal group.  This check is a small
             * optimization and is not necessary, because if the group is hideInGal, it
             * won't be found in GAL anyway, so just save the GAL search.
             *
             * If proxiedToHomeOfInternalGroup is true, we were proxied here from inside the
             * getMembersFromLdap() path in the previous hop.  We must have gone into the above
             * getMembersFromLdap() in this hop, and it returned null (or in a nearly
             * impossible case the group cannot be found in this server and we did not
             * even go into the above getMembersFromLdap).  In this case, do not do
             * a GAL search, because the GAL search could once again proxy the request
             * to the GAL sync account's home server.  We will just leave dlMembersResult
             * null and let the NO_SUCH_DISTRIBUTION_LIST be thrown.  When the
             * NO_SUCH_DISTRIBUTION_LIST got back to the previous hop, in
             * getMembersFromLdap, it will return null and control will reach here again
             * (in the "previous" hop).   Now, since the proxiedToHomeOfInternalGroup
             * flag is not on, we will proceed to do the GAL search if the group is not hideInGal.
             */
        boolean hideInGal = (group != null && group.hideInGal());
        if (!hideInGal && !proxiedToHomeOfInternalGroup) {
            dlMembersResult = GalGroupMembers.searchGal(zsc, account, dlName, request);
        }
    }
    if (dlMembersResult == null) {
        throw AccountServiceException.NO_SUCH_DISTRIBUTION_LIST(dlName);
    }
    if (dlMembersResult instanceof ProxiedDLMembers) {
        return ((ProxiedDLMembers) dlMembersResult).getResponse();
    } else if (dlMembersResult instanceof DLMembers) {
        return processDLMembers(zsc, dlName, account, limit, offset, (DLMembers) dlMembersResult);
    } else {
        throw ServiceException.FAILURE("unsopported DLMembersResult class: " + dlMembersResult.getClass().getCanonicalName(), null);
    }
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) ProxiedDLMembers(com.zimbra.cs.gal.GalGroupMembers.ProxiedDLMembers) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning) DLMembersResult(com.zimbra.cs.gal.GalGroupMembers.DLMembersResult) ProxiedDLMembers(com.zimbra.cs.gal.GalGroupMembers.ProxiedDLMembers) DLMembers(com.zimbra.cs.gal.GalGroupMembers.DLMembers) LdapDLMembers(com.zimbra.cs.gal.GalGroupMembers.LdapDLMembers)

Aggregations

Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 Group (com.zimbra.cs.account.Group)1 Provisioning (com.zimbra.cs.account.Provisioning)1 DLMembers (com.zimbra.cs.gal.GalGroupMembers.DLMembers)1 DLMembersResult (com.zimbra.cs.gal.GalGroupMembers.DLMembersResult)1 LdapDLMembers (com.zimbra.cs.gal.GalGroupMembers.LdapDLMembers)1 ProxiedDLMembers (com.zimbra.cs.gal.GalGroupMembers.ProxiedDLMembers)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1