Search in sources :

Example 1 with DomainInfo

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

the class ZSoapProvisioning method getDomainInfo.

public ZDomain getDomainInfo(DomainBy keyType, String key) throws ServiceException {
    DomainSelector domSel = new DomainSelector(toJaxb(keyType), key);
    try {
        GetDomainInfoResponse resp = invokeJaxb(new GetDomainInfoRequest(domSel, null));
        DomainInfo domainInfo = resp.getDomain();
        return domainInfo == null ? null : new ZDomain(domainInfo);
    } catch (ServiceException e) {
        if (e.getCode().equals(Constants.ERROR_CODE_NO_SUCH_DOMAIN))
            return null;
        else
            throw e;
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) DomainSelector(com.zimbra.soap.admin.type.DomainSelector) GetDomainInfoRequest(com.zimbra.soap.admin.message.GetDomainInfoRequest) DomainInfo(com.zimbra.soap.admin.type.DomainInfo) GetDomainInfoResponse(com.zimbra.soap.admin.message.GetDomainInfoResponse)

Example 2 with DomainInfo

use of com.zimbra.soap.admin.type.DomainInfo 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) CalendarResourceInfo(com.zimbra.soap.admin.type.CalendarResourceInfo) ArrayList(java.util.ArrayList) 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)

Example 3 with DomainInfo

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

the class SoapProvisioning method getAllDomains.

// SoapProvisioning only, for zmprov
public List<Domain> getAllDomains(boolean applyDefault) throws ServiceException {
    ArrayList<Domain> result = new ArrayList<Domain>();
    GetAllDomainsResponse resp = invokeJaxb(new GetAllDomainsRequest(applyDefault));
    for (DomainInfo domainInfo : resp.getDomainList()) {
        result.add(new SoapDomain(domainInfo, this));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DomainInfo(com.zimbra.soap.admin.type.DomainInfo) Domain(com.zimbra.cs.account.Domain)

Example 4 with DomainInfo

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

the class SoapProvisioning method getDomainInfo.

public Domain getDomainInfo(DomainBy keyType, String key) throws ServiceException {
    DomainSelector domSel = new DomainSelector(toJaxb(keyType), key);
    try {
        GetDomainInfoResponse resp = invokeJaxb(new GetDomainInfoRequest(domSel, null));
        DomainInfo domainInfo = resp.getDomain();
        return domainInfo == null ? null : new SoapDomain(domainInfo, this);
    } catch (ServiceException e) {
        if (e.getCode().equals(Constants.ERROR_CODE_NO_SUCH_DOMAIN))
            return null;
        else
            throw e;
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) DomainSelector(com.zimbra.soap.admin.type.DomainSelector) DomainInfo(com.zimbra.soap.admin.type.DomainInfo)

Aggregations

DomainInfo (com.zimbra.soap.admin.type.DomainInfo)4 ServiceException (com.zimbra.common.service.ServiceException)2 DomainSelector (com.zimbra.soap.admin.type.DomainSelector)2 ArrayList (java.util.ArrayList)2 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 Domain (com.zimbra.cs.account.Domain)1 NamedEntry (com.zimbra.cs.account.NamedEntry)1 GetDomainInfoRequest (com.zimbra.soap.admin.message.GetDomainInfoRequest)1 GetDomainInfoResponse (com.zimbra.soap.admin.message.GetDomainInfoResponse)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