// distinguishedName value.
if (nameInsertElement.toUpperCase().equals("DN")) { //$NON-NLS-1$
insertValue = ((Literal)insertValueList.get(i)).getValue();
if (insertValue == null) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNNullError"); //$NON-NLS-1$
throw new TranslatorException(msg);
}
if (!(insertValue instanceof java.lang.String)) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNTypeError"); //$NON-NLS-1$
throw new TranslatorException(msg);
}
distinguishedName = (String)insertValue;
}
// for other attributes specified in the insert command,
// create a new
else {
insertAttr = new BasicAttribute(nameInsertElement);
insertValue = ((Literal)insertValueList.get(i)).getValue();
insertAttr.add(insertValue);
insertAttrs.put(insertAttr);
}
}
// if the DN is not specified, we don't know enough to attempt
// the LDAP add operation, so throw an exception
if (distinguishedName == null) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.noInsertSourceNameDNError"); //$NON-NLS-1$
throw new TranslatorException(msg);
}
// just try to create a new LDAP entry using the DN and
// attributes specified in the INSERT operation. If it isn't
// legal, we'll get a NamingException back, whose explanation
// we'll return in a ConnectorException
try {
ldapCtx.createSubcontext(distinguishedName, insertAttrs);
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailed",distinguishedName,ne.getExplanation()); //$NON-NLS-1$
throw new TranslatorException(msg);
} catch (Exception e) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailedUnexpected",distinguishedName); //$NON-NLS-1$
throw new TranslatorException(e, msg);
}
}