Search in sources :

Example 16 with CallbackContext

use of com.zimbra.cs.account.callback.CallbackContext in project zm-mailbox by Zimbra.

the class LdapProvisioning method modifyEphemeralAttrsInLdap.

/**
     * Modifies this entry. If any of the provided attributes are ephemeral,
     * they will be stored in LDAP instead of routed to EphemeralStore.
     * Used by LdapEphemeralStore.
     * @param e
     * @param attrs
     * @throws ServiceException
     */
public void modifyEphemeralAttrsInLdap(Entry e, Map<String, ? extends Object> attrs) throws ServiceException {
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.MODIFY);
    AttributeManager.getInstance().preModify(attrs, e, callbackContext, false, true);
    modifyAttrsInternal(e, null, attrs, true);
    AttributeManager.getInstance().postModify(attrs, e, callbackContext, true);
}
Also used : CallbackContext(com.zimbra.cs.account.callback.CallbackContext)

Example 17 with CallbackContext

use of com.zimbra.cs.account.callback.CallbackContext in project zm-mailbox by Zimbra.

the class LdapProvisioning method createXMPPComponent.

@Override
public XMPPComponent createXMPPComponent(String name, Domain domain, Server server, Map<String, Object> inAttrs) throws ServiceException {
    name = name.toLowerCase().trim();
    // sanity checking
    removeAttrIgnoreCase("objectclass", inAttrs);
    removeAttrIgnoreCase(A_zimbraDomainId, inAttrs);
    removeAttrIgnoreCase(A_zimbraServerId, inAttrs);
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    AttributeManager.getInstance().preModify(inAttrs, null, callbackContext, true);
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_XMPPCOMPONENT);
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(inAttrs);
        entry.setAttr(A_objectClass, "zimbraXMPPComponent");
        String compId = LdapUtil.generateUUID();
        entry.setAttr(A_zimbraId, compId);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        entry.setAttr(A_cn, name);
        String dn = mDIT.xmppcomponentNameToDN(name);
        entry.setDN(dn);
        entry.setAttr(A_zimbraDomainId, domain.getId());
        entry.setAttr(A_zimbraServerId, server.getId());
        zlc.createEntry(entry);
        XMPPComponent comp = getXMPPComponentById(compId, zlc, true);
        AttributeManager.getInstance().postModify(inAttrs, comp, callbackContext);
        return comp;
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.IM_COMPONENT_EXISTS(name);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent) Date(java.util.Date)

Aggregations

CallbackContext (com.zimbra.cs.account.callback.CallbackContext)17 LdapEntryAlreadyExistException (com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException)14 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)14 ZMutableEntry (com.zimbra.cs.ldap.ZMutableEntry)14 AccountServiceException (com.zimbra.cs.account.AccountServiceException)13 LdapException (com.zimbra.cs.ldap.LdapException)13 Date (java.util.Date)13 ServiceException (com.zimbra.common.service.ServiceException)12 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)12 Domain (com.zimbra.cs.account.Domain)4 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)4 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)3 Account (com.zimbra.cs.account.Account)2 Cos (com.zimbra.cs.account.Cos)2 GuestAccount (com.zimbra.cs.account.GuestAccount)2 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)2 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)2 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 AttributeInfo (com.zimbra.cs.account.AttributeInfo)1 DataSource (com.zimbra.cs.account.DataSource)1