use of org.apache.directory.api.ldap.model.message.controls.ManageDsaITImpl in project directory-ldap-api by apache.
the class LdifUtilsTest method testConvertEntryOneControl.
@Test
public void testConvertEntryOneControl() throws Exception {
LdifReader reader = new LdifReader();
String expected = "dn: ou=test\n" + "control: 2.16.840.1.113730.3.4.2 false\n" + "changetype: add\n" + "ObjectClass: top\n" + "ObjectClass: metaTop\n" + "ObjectClass: metaSyntax\n" + "m-oid: 1.2.3.4\n" + "m-description: description\n\n";
List<LdifEntry> entries = reader.parseLdif(expected);
LdifEntry expectedEntry = entries.get(0);
LdifEntry entry = new LdifEntry();
entry.setDn("ou=test");
entry.addAttribute("ObjectClass", "top", "metaTop", "metaSyntax");
entry.addAttribute("m-oid", "1.2.3.4");
entry.addAttribute("m-description", "description");
ManageDsaITImpl control = new ManageDsaITImpl();
entry.addControl(control);
String converted = LdifUtils.convertToLdif(entry);
assertNotNull(converted);
entries = reader.parseLdif(converted);
LdifEntry convertedEntry = entries.get(0);
assertEquals(expectedEntry, convertedEntry);
reader.close();
}
use of org.apache.directory.api.ldap.model.message.controls.ManageDsaITImpl in project directory-ldap-api by apache.
the class LdapNetworkConnection method searchAsync.
/**
* {@inheritDoc}
*/
@Override
public SearchFuture searchAsync(SearchRequest searchRequest) throws LdapException {
if (searchRequest == null) {
String msg = "Cannot process a null searchRequest";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
if (searchRequest.getBase() == null) {
String msg = "Cannot process a searchRequest which base DN is null";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
// try to connect, if we aren't already connected.
connect();
// If the session has not been establish, or is closed, we get out immediately
checkSession();
int newId = messageId.incrementAndGet();
searchRequest.setMessageId(newId);
if (searchRequest.isIgnoreReferrals()) {
// We want to ignore the referral, inject the ManageDSAIT control in the request
searchRequest.addControl(new ManageDsaITImpl());
}
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03205_SENDING_REQUEST, searchRequest));
}
SearchFuture searchFuture = new SearchFuture(this, searchRequest.getMessageId());
addToFutureMap(searchRequest.getMessageId(), searchFuture);
// Send the request to the server
writeRequest(searchRequest);
// Check that the future hasn't be canceled
if (searchFuture.isCancelled()) {
// Throw an exception here
throw new LdapException(searchFuture.getCause());
}
// Ok, done return the future
return searchFuture;
}
Aggregations