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;
}
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);
}
}
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);
}
}
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;
}
Aggregations