use of com.zimbra.soap.account.type.AddressListInfo in project zm-mailbox by Zimbra.
the class LdapProvisioning method deleteAddressList.
@Override
public void deleteAddressList(String addressListId) throws ServiceException {
AddressListInfo adl = getAddressListById(addressListId);
if (adl == null) {
throw AccountServiceException.NO_SUCH_ADDRESS_LIST(addressListId);
}
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_ADDRESSLIST);
zlc.deleteEntry(adl.getDn());
} catch (ServiceException e) {
throw ServiceException.FAILURE(String.format("unable to purge address list: %s", addressListId), e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.soap.account.type.AddressListInfo in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAddressListByQuery.
private List<AddressListInfo> getAddressListByQuery(String base, ZLdapFilter filter, boolean activeOnly, boolean getDN) throws ServiceException {
List<AddressListInfo> result = new ArrayList<AddressListInfo>();
try {
ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE(), null, LdapServerType.REPLICA);
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
if (getDN) {
AddressListInfo adl = new AddressListInfo(sr.getDN());
result.add(adl);
} else {
ZAttributes attrs = sr.getAttributes();
if (attrs != null) {
boolean active = Boolean.parseBoolean(attrs.getAttrString(Provisioning.A_zimbraIsAddressListActive));
boolean addToRes = activeOnly ? active : Boolean.TRUE;
if (addToRes) {
AddressListInfo adl = new AddressListInfo(attrs.getAttrString(Provisioning.A_zimbraId), attrs.getAttrString(Provisioning.A_uid), attrs.getAttrString(Provisioning.A_description));
if (!activeOnly) {
adl.setActive(active);
adl.setGalFilter(attrs.getAttrString(Provisioning.A_zimbraAddressListGalFilter));
adl.setLdapFilter(attrs.getAttrString(Provisioning.A_zimbraAddressListLdapFilter));
}
result.add(adl);
}
}
}
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup address lists via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return result;
}
use of com.zimbra.soap.account.type.AddressListInfo in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllAddressLists.
@Override
public List<AddressListInfo> getAllAddressLists(Domain domain, boolean activeOnly) throws ServiceException {
LdapEntry ldapEntry = (LdapEntry) (domain instanceof LdapEntry ? domain : getDomainById(domain.getId()));
if (ldapEntry == null) {
throw AccountServiceException.NO_SUCH_DOMAIN(domain.getName());
}
List<AddressListInfo> result = getAddressListByQuery(ldapEntry.getDN(), filterFactory.allAddressLists(), activeOnly);
result = Collections.unmodifiableList(result);
return result;
}
use of com.zimbra.soap.account.type.AddressListInfo in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAddressListById.
private AddressListInfo getAddressListById(String zimbraId) throws ServiceException {
AddressListInfo adl = null;
List<AddressListInfo> adlList = getAddressListByQuery(mDIT.mailBranchBaseDN(), filterFactory.addressListById(zimbraId), false, true);
if (adlList.size() != 0) {
adl = adlList.get(0);
}
return adl;
}
use of com.zimbra.soap.account.type.AddressListInfo in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAddressListByName.
@Override
public AddressListInfo getAddressListByName(String name, Domain domain) throws ServiceException {
LdapEntry ldapEntry = (LdapEntry) (domain instanceof LdapEntry ? domain : getDomainById(domain.getId()));
if (ldapEntry == null) {
throw AccountServiceException.NO_SUCH_DOMAIN(domain.getName());
}
List<AddressListInfo> result = getAddressListByQuery(ldapEntry.getDN(), filterFactory.addressListByName(name), false);
if (result.size() < 1) {
throw AccountServiceException.NO_SUCH_ADDRESS_LIST(name);
}
// first should be what we want, ignore extras
return result.get(0);
}
Aggregations