Search in sources :

Example 1 with AdminObjectInterface

use of com.zimbra.soap.admin.type.AdminObjectInterface in project zm-mailbox by Zimbra.

the class SoapProvisioning method searchDirectory.

@Override
public List<NamedEntry> searchDirectory(SearchDirectoryOptions options) throws ServiceException {
    List<NamedEntry> result = new ArrayList<NamedEntry>();
    SearchDirectoryRequest req = new SearchDirectoryRequest();
    req.setQuery(options.getFilterString());
    if (options.getMaxResults() != 0) {
        req.setMaxResults(options.getMaxResults());
    }
    if (options.getDomain() != null) {
        req.setDomain(options.getDomain().getName());
    }
    if (options.getSortAttr() != null) {
        req.setSortBy(options.getSortAttr());
    }
    Set<SearchDirectoryOptions.ObjectType> types = options.getTypes();
    if (types != null) {
        req.setTypes(SearchDirectoryOptions.ObjectType.toCSVString(types));
    }
    req.setSortAscending(options.getSortOpt() != SortOpt.SORT_DESCENDING);
    if (options.getReturnAttrs() != null) {
        req.addAttrs(options.getReturnAttrs());
    }
    // TODO: handle ApplyCos, limit, offset?
    SearchDirectoryResponse resp = invokeJaxb(req);
    List<AdminObjectInterface> entries = resp.getEntries();
    for (AdminObjectInterface entry : entries) {
        if (entry instanceof AccountInfo) {
            result.add(new SoapAccount((AccountInfo) entry, this));
        } else if (entry instanceof CalendarResourceInfo) {
            result.add(new SoapCalendarResource((CalendarResourceInfo) entry, this));
        } else if (entry instanceof AliasInfo) {
            result.add(new SoapAlias((AliasInfo) entry, this));
        } else if (entry instanceof DistributionListInfo) {
            result.add(new SoapDistributionList((DistributionListInfo) entry, this));
        } else if (entry instanceof DomainInfo) {
            result.add(new SoapDomain((DomainInfo) entry, this));
        }
    }
    return result;
}
Also used : DistributionListInfo(com.zimbra.soap.admin.type.DistributionListInfo) SearchDirectoryResponse(com.zimbra.soap.admin.message.SearchDirectoryResponse) CalendarResourceInfo(com.zimbra.soap.admin.type.CalendarResourceInfo) ArrayList(java.util.ArrayList) SearchDirectoryRequest(com.zimbra.soap.admin.message.SearchDirectoryRequest) NamedEntry(com.zimbra.cs.account.NamedEntry) AliasInfo(com.zimbra.soap.admin.type.AliasInfo) DomainInfo(com.zimbra.soap.admin.type.DomainInfo) AdminObjectInterface(com.zimbra.soap.admin.type.AdminObjectInterface) AccountInfo(com.zimbra.soap.admin.type.AccountInfo)

Aggregations

NamedEntry (com.zimbra.cs.account.NamedEntry)1 SearchDirectoryRequest (com.zimbra.soap.admin.message.SearchDirectoryRequest)1 SearchDirectoryResponse (com.zimbra.soap.admin.message.SearchDirectoryResponse)1 AccountInfo (com.zimbra.soap.admin.type.AccountInfo)1 AdminObjectInterface (com.zimbra.soap.admin.type.AdminObjectInterface)1 AliasInfo (com.zimbra.soap.admin.type.AliasInfo)1 CalendarResourceInfo (com.zimbra.soap.admin.type.CalendarResourceInfo)1 DistributionListInfo (com.zimbra.soap.admin.type.DistributionListInfo)1 DomainInfo (com.zimbra.soap.admin.type.DomainInfo)1 ArrayList (java.util.ArrayList)1