use of com.zimbra.cs.ldap.ZAttributes in project zm-mailbox by Zimbra.
the class LdapProvisioning method getZimlet.
private Zimlet getZimlet(String name, ZLdapContext initZlc, boolean useZimletCache) throws ServiceException {
LdapZimlet zimlet = null;
if (useZimletCache) {
zimlet = zimletCache.getByName(name);
}
if (zimlet != null) {
return zimlet;
}
try {
String dn = mDIT.zimletNameToDN(name);
ZAttributes attrs = helper.getAttributes(initZlc, LdapServerType.REPLICA, LdapUsage.GET_ZIMLET, dn, null);
zimlet = new LdapZimlet(dn, attrs, this);
if (useZimletCache) {
ZimletUtil.reloadZimlet(name);
// put LdapZimlet into the cache after successful ZimletUtil.reloadZimlet()
zimletCache.put(zimlet);
}
return zimlet;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException ne) {
throw ServiceException.FAILURE("unable to get zimlet: " + name, ne);
} catch (ZimletException ze) {
throw ServiceException.FAILURE("unable to load zimlet: " + name, ze);
}
}
use of com.zimbra.cs.ldap.ZAttributes in project zm-mailbox by Zimbra.
the class LdapProvisioning method getConfig.
@Override
public synchronized Config getConfig() throws ServiceException {
if (cachedGlobalConfig == null) {
String configDn = mDIT.configDN();
try {
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_GLOBALCONFIG, configDn);
LdapConfig config = new LdapConfig(configDn, attrs, this);
if (useCache) {
cachedGlobalConfig = config;
} else {
return config;
}
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to get config", e);
}
}
return cachedGlobalConfig;
}
use of com.zimbra.cs.ldap.ZAttributes in project zm-mailbox by Zimbra.
the class LdapProvisioning method getGlobalGrant.
@Override
public synchronized GlobalGrant getGlobalGrant() throws ServiceException {
if (cachedGlobalGrant == null) {
String globalGrantDn = mDIT.globalGrantDN();
try {
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_GLOBALGRANT, globalGrantDn);
LdapGlobalGrant globalGrant = new LdapGlobalGrant(globalGrantDn, attrs, this);
if (useCache) {
cachedGlobalGrant = globalGrant;
} else {
return globalGrant;
}
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to get globalgrant", e);
}
}
return cachedGlobalGrant;
}
use of com.zimbra.cs.ldap.ZAttributes in project zm-mailbox by Zimbra.
the class TestLdapZMutableEntry method setAttr.
@Test
public void setAttr() throws Exception {
String KEY = "key";
String VALUE1 = "value1";
String VALUE2 = "value2";
ZMutableEntry entry = LdapClient.createMutableEntry();
entry.setAttr(KEY, VALUE1);
// should REPLACE
entry.setAttr(KEY, VALUE2);
ZAttributes zattrs = entry.getAttributes();
Map<String, Object> attrs = zattrs.getAttrs();
Object valueGot = attrs.get(KEY);
assertTrue(valueGot instanceof String);
}
use of com.zimbra.cs.ldap.ZAttributes in project zm-mailbox by Zimbra.
the class TestLdapZMutableEntry method addAttr.
@Test
public void addAttr() throws Exception {
String KEY = "key";
String VALUE1 = "value1";
String VALUE2 = "value2";
String VALUE3 = "value3";
ZMutableEntry entry = LdapClient.createMutableEntry();
Set<String> values = new HashSet<String>();
values.add(VALUE1);
values.add(VALUE2);
entry.addAttr(KEY, values);
values.clear();
values.add(VALUE1);
values.add(VALUE3);
// should MERGE
entry.addAttr(KEY, values);
ZAttributes zattrs = entry.getAttributes();
Map<String, Object> attrs = zattrs.getAttrs();
Object valueGot = attrs.get(KEY);
assertTrue(valueGot instanceof String[]);
List<String> valuesGot = Arrays.asList((String[]) valueGot);
assertTrue(valuesGot.contains(VALUE1));
assertTrue(valuesGot.contains(VALUE2));
assertTrue(valuesGot.contains(VALUE3));
}
Aggregations