if ( objectClass == null )
{
String msg = I18n.err( I18n.ERR_217, entryDn.getName(), entry );
ResultCodeEnum rc = ResultCodeEnum.OBJECT_CLASS_VIOLATION;
LdapSchemaViolationException e = new LdapSchemaViolationException( rc, msg );
//e.setResolvedName( entryDn );
throw e;
}
for ( Value<?> value : objectClass )
{
if ( value.equals( SchemaConstants.TOP_OC ) )
{
continue;
}
objectClassIdx.add( ( String ) value.getNormValue(), id );
}
if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
{
Attribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT );
addAliasIndices( id, entryDn, aliasAttr.getString() );
}
// Update the EntryCsn index
Attribute entryCsn = entry.get( ENTRY_CSN_AT );
if ( entryCsn == null )
{
String msg = I18n.err( I18n.ERR_219, entryDn.getName(), entry );
throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
}
entryCsnIdx.add( entryCsn.getString(), id );
// Now work on the user defined userIndices
for ( Attribute attribute : entry )
{
AttributeType attributeType = attribute.getAttributeType();
String attributeOid = attributeType.getOid();
if ( hasUserIndexOn( attributeType ) )
{
Index<Object, Entry, String> idx = ( Index<Object, Entry, String> ) getUserIndex( attributeType );
// here lookup by attributeId is OK since we got attributeId from
// the entry via the enumeration - it's in there as is for sure
for ( Value<?> value : attribute )
{
idx.add( value.getNormValue(), id );
}
// Adds only those attributes that are indexed
presenceIdx.add( attributeOid, id );
}
}
// Add the parentId in the entry
entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
try
{
lockWrite();
// Update the RDN index
rdnIdx.add( key, id );
// Update the parent's nbChildren and nbDescendants values
if ( parentId != Partition.ROOT_ID )
{
updateRdnIdx( parentId, ADD_CHILD, 0 );
}
// And finally add the entry into the master table
master.put( id, entry );
}
finally
{
unlockWrite();
}
if ( isSyncOnWrite.get() )
{
sync();
}
}
catch ( LdapException le )
{
throw le;
}
catch ( Exception e )
{
e.printStackTrace();
throw new LdapException( e );
}
}