Search in sources :

Example 11 with AlwaysOnCluster

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

the class LdapProvisioning method getAlwaysOnClusterById.

private AlwaysOnCluster getAlwaysOnClusterById(String zimbraId, ZLdapContext zlc, boolean nocache) throws ServiceException {
    if (zimbraId == null)
        return null;
    AlwaysOnCluster c = null;
    if (!nocache)
        c = alwaysOnClusterCache.getById(zimbraId);
    if (c == null) {
        c = getAlwaysOnClusterByQuery(filterFactory.alwaysOnClusterById(zimbraId), zlc);
        alwaysOnClusterCache.put(c);
    }
    return c;
}
Also used : LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster)

Example 12 with AlwaysOnCluster

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

the class LdapProvisioning method createAlwaysOnCluster.

@Override
public AlwaysOnCluster createAlwaysOnCluster(String name, Map<String, Object> clusterAttrs) throws ServiceException {
    name = name.toLowerCase().trim();
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    AttributeManager.getInstance().preModify(clusterAttrs, null, callbackContext, true);
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_SERVER);
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(clusterAttrs);
        Set<String> ocs = LdapObjectClass.getAlwaysOnClusterObjectClasses(this);
        entry.addAttr(A_objectClass, ocs);
        String zimbraIdStr = LdapUtil.generateUUID();
        entry.setAttr(A_zimbraId, zimbraIdStr);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        entry.setAttr(A_cn, name);
        String dn = mDIT.alwaysOnClusterNameToDN(name);
        entry.setDN(dn);
        zlc.createEntry(entry);
        AlwaysOnCluster cluster = getAlwaysOnClusterById(zimbraIdStr, zlc, true);
        AttributeManager.getInstance().postModify(clusterAttrs, cluster, callbackContext);
        return cluster;
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.ALWAYSONCLUSTER_EXISTS(name);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to create akwaysOnCluster: " + name, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) LdapException(com.zimbra.cs.ldap.LdapException) Date(java.util.Date)

Example 13 with AlwaysOnCluster

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

the class LdapProvisioning method getAlwaysOnClusterByName.

private AlwaysOnCluster getAlwaysOnClusterByName(String name, boolean nocache) throws ServiceException {
    if (!nocache) {
        AlwaysOnCluster c = alwaysOnClusterCache.getByName(name);
        if (c != null)
            return c;
    }
    try {
        String dn = mDIT.alwaysOnClusterNameToDN(name);
        ZAttributes attrs = helper.getAttributes(LdapUsage.GET_ALWAYSONCLUSTER, dn);
        LdapAlwaysOnCluster c = new LdapAlwaysOnCluster(dn, attrs, null, this);
        alwaysOnClusterCache.put(c);
        return c;
    } catch (LdapEntryNotFoundException e) {
        return null;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to lookup alwaysOnCluster by name: " + name + " message: " + e.getMessage(), e);
    }
}
Also used : LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapEntryNotFoundException(com.zimbra.cs.ldap.LdapException.LdapEntryNotFoundException) ZAttributes(com.zimbra.cs.ldap.ZAttributes)

Example 14 with AlwaysOnCluster

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

the class ProvTestUtil method createAlwaysOnCluster.

public AlwaysOnCluster createAlwaysOnCluster(String alwaysOnClusterName, Map<String, Object> attrs) throws Exception {
    if (attrs == null) {
        attrs = new HashMap<String, Object>();
    }
    AlwaysOnCluster cluster = prov.get(Key.AlwaysOnClusterBy.name, alwaysOnClusterName);
    assertNull(cluster);
    cluster = prov.createAlwaysOnCluster(alwaysOnClusterName, attrs);
    assertNotNull(cluster);
    cluster = prov.get(Key.AlwaysOnClusterBy.name, alwaysOnClusterName);
    assertNotNull(cluster);
    assertEquals(alwaysOnClusterName.toLowerCase(), cluster.getName().toLowerCase());
    createdEntries.add(cluster);
    return cluster;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster)

Aggregations

AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)14 LdapAlwaysOnCluster (com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster)7 Element (com.zimbra.common.soap.Element)5 Provisioning (com.zimbra.cs.account.Provisioning)5 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)5 ServiceException (com.zimbra.common.service.ServiceException)4 AccountServiceException (com.zimbra.cs.account.AccountServiceException)4 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)4 Account (com.zimbra.cs.account.Account)3 Domain (com.zimbra.cs.account.Domain)3 GuestAccount (com.zimbra.cs.account.GuestAccount)3 Server (com.zimbra.cs.account.Server)3 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)3 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)3 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)3 LdapServer (com.zimbra.cs.account.ldap.entry.LdapServer)3 InMemoryLdapServer (com.zimbra.cs.ldap.unboundid.InMemoryLdapServer)3 Cos (com.zimbra.cs.account.Cos)2 LdapZimlet (com.zimbra.cs.account.ldap.entry.LdapZimlet)2 Key (com.zimbra.common.account.Key)1