use of com.zimbra.cs.account.ldap.entry.LdapXMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method deleteXMPPComponent.
@Override
public void deleteXMPPComponent(XMPPComponent comp) throws ServiceException {
String zimbraId = comp.getId();
ZLdapContext zlc = null;
LdapXMPPComponent l = (LdapXMPPComponent) get(Key.XMPPComponentBy.id, zimbraId);
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_XMPPCOMPONENT);
zlc.deleteEntry(l.getDN());
xmppComponentCache.remove(l);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to purge XMPPComponent : " + zimbraId, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapXMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllXMPPComponents.
@Override
public List<XMPPComponent> getAllXMPPComponents() throws ServiceException {
List<XMPPComponent> result = new ArrayList<XMPPComponent>();
try {
String base = mDIT.xmppcomponentBaseDN();
ZLdapFilter filter = filterFactory.allXMPPComponents();
ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
LdapXMPPComponent x = new LdapXMPPComponent(sr.getDN(), sr.getAttributes(), this);
result.add(x);
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all XMPPComponents", e);
}
if (result.size() > 0) {
xmppComponentCache.put(result, true);
}
Collections.sort(result);
return result;
}
use of com.zimbra.cs.account.ldap.entry.LdapXMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method renameXMPPComponent.
// Only called from renameDomain for now
void renameXMPPComponent(String zimbraId, String newName) throws ServiceException {
LdapXMPPComponent comp = (LdapXMPPComponent) get(Key.XMPPComponentBy.id, zimbraId);
if (comp == null)
throw AccountServiceException.NO_SUCH_XMPP_COMPONENT(zimbraId);
newName = newName.toLowerCase().trim();
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.RENAME_XMPPCOMPONENT);
String newDn = mDIT.xmppcomponentNameToDN(newName);
zlc.renameEntry(comp.getDN(), newDn);
// remove old comp from cache
xmppComponentCache.remove(comp);
} catch (LdapEntryAlreadyExistException nabe) {
throw AccountServiceException.IM_COMPONENT_EXISTS(newName);
} catch (LdapException e) {
throw e;
} catch (AccountServiceException e) {
throw e;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to rename XMPPComponent: " + zimbraId, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapXMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method getXMPPComponentByName.
private XMPPComponent getXMPPComponentByName(String name, boolean nocache) throws ServiceException {
if (!nocache) {
XMPPComponent x = xmppComponentCache.getByName(name);
if (x != null)
return x;
}
try {
String dn = mDIT.xmppcomponentNameToDN(name);
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_XMPPCOMPONENT, dn);
XMPPComponent x = new LdapXMPPComponent(dn, attrs, this);
xmppComponentCache.put(x);
return x;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup xmpp component by name: " + name + " message: " + e.getMessage(), e);
}
}
Aggregations