use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.
the class LdapProvisioning method getUCServiceByName.
private UCService getUCServiceByName(String name, boolean nocache) throws ServiceException {
if (!nocache) {
UCService s = ucServiceCache.getByName(name);
if (s != null) {
return s;
}
}
try {
String dn = mDIT.ucServiceNameToDN(name);
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_UCSERVICE, dn);
LdapUCService s = new LdapUCService(dn, attrs, this);
ucServiceCache.put(s);
return s;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup ucservice by name: " + name + " message: " + e.getMessage(), e);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.
the class LdapProvisioning method renameUCService.
@Override
public void renameUCService(String zimbraId, String newName) throws ServiceException {
LdapUCService ucService = (LdapUCService) getUCServiceById(zimbraId, null, false);
if (ucService == null) {
throw AccountServiceException.NO_SUCH_UC_SERVICE(zimbraId);
}
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.RENAME_UCSERVICE);
String newDn = mDIT.ucServiceNameToDN(newName);
zlc.renameEntry(ucService.getDN(), newDn);
ucServiceCache.remove(ucService);
} catch (LdapEntryAlreadyExistException nabe) {
throw AccountServiceException.UC_SERVICE_EXISTS(newName);
} catch (LdapException e) {
throw e;
} catch (AccountServiceException e) {
throw e;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to rename ucservice: " + zimbraId, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.
the class LdapProvisioning method deleteUCService.
@Override
public void deleteUCService(String zimbraId) throws ServiceException {
LdapUCService ucService = (LdapUCService) getUCServiceById(zimbraId, null, false);
if (ucService == null) {
throw AccountServiceException.NO_SUCH_UC_SERVICE(zimbraId);
}
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_UCSERVICE);
zlc.deleteEntry(ucService.getDN());
ucServiceCache.remove(ucService);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to purge ucservice: " + zimbraId, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllUCServices.
@Override
public List<UCService> getAllUCServices() throws ServiceException {
List<UCService> result = new ArrayList<UCService>();
ZLdapFilter filter = filterFactory.allUCServices();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.ucServiceBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
LdapUCService s = new LdapUCService(sr.getDN(), sr.getAttributes(), this);
result.add(s);
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all servers", e);
}
if (result.size() > 0) {
ucServiceCache.put(result, true);
}
Collections.sort(result);
return result;
}
Aggregations