use of org.apache.directory.api.ldap.model.message.AddRequestImpl in project ldapchai by ldapchai.
the class ApacheLdapProviderImpl method createEntry.
public void createEntry(final String entryDN, final Set<String> baseObjectClasses, final Map<String, String> stringAttributes) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().createEntry(entryDN, baseObjectClasses, stringAttributes);
try {
final AddRequest addRequest = new AddRequestImpl();
final Entry entry = new DefaultEntry();
entry.setDn(entryDN);
for (final String baseObjectClass : baseObjectClasses) {
entry.add(ChaiConstant.ATTR_LDAP_OBJECTCLASS, baseObjectClass);
}
for (final Map.Entry<String, String> entryIter : stringAttributes.entrySet()) {
final String name = entryIter.getKey();
final String value = entryIter.getValue();
entry.add(name, value);
}
final AddResponse response = connection.add(addRequest);
processResponse(response);
} catch (LdapException e) {
throw ChaiOperationException.forErrorMessage(e.getMessage());
}
}
use of org.apache.directory.api.ldap.model.message.AddRequestImpl in project directory-ldap-api by apache.
the class LdapNetworkConnection method addAsync.
/**
* {@inheritDoc}
*/
@Override
public AddFuture addAsync(Entry entry) throws LdapException {
if (entry == null) {
String msg = "Cannot add null entry";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry(entry);
return addAsync(addRequest);
}
use of org.apache.directory.api.ldap.model.message.AddRequestImpl in project directory-ldap-api by apache.
the class LdapNetworkConnection method add.
// ------------------------ The LDAP operations ------------------------//
// Add operations //
// ---------------------------------------------------------------------//
/**
* {@inheritDoc}
*/
@Override
public void add(Entry entry) throws LdapException {
if (entry == null) {
String msg = "Cannot add an empty entry";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry(entry);
AddResponse addResponse = add(addRequest);
processResponse(addResponse);
}
use of org.apache.directory.api.ldap.model.message.AddRequestImpl in project directory-ldap-api by apache.
the class InitAddRequest method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<AddRequestDecorator> container) throws DecoderException {
// Now, we can allocate the AddRequest Object
int messageId = container.getMessageId();
AddRequest internalAddRequest = new AddRequestImpl();
internalAddRequest.setMessageId(messageId);
AddRequestDecorator addRequest = new AddRequestDecorator(container.getLdapCodecService(), internalAddRequest);
container.setMessage(addRequest);
// We will check that the request is not null
TLV tlv = container.getCurrentTLV();
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04084);
LOG.error(msg);
// Will generate a PROTOCOL_ERROR
throw new DecoderException(msg);
}
}
Aggregations