* to add the entry to the DIT. Thereafter we search out entries
* to modify the subentry operational attributes of.
* ----------------------------------------------------------------
*/
String subtree = entry.get( SchemaConstants.SUBTREE_SPECIFICATION_AT ).getString();
SubtreeSpecification ss;
try
{
ss = ssParser.parse( subtree );
}
catch ( Exception e )
{
String msg = "Failed while parsing subtreeSpecification for " + name.getUpName();
LOG.warn( msg );
throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
}
subentryCache.setSubentry( name.getNormName(), ss, getSubentryTypes( entry ) );
next.add( addContext );
/* ----------------------------------------------------------------
* Find the baseDn for the subentry and use that to search the tree
* while testing each entry returned for inclusion within the
* subtree of the subentry's subtreeSpecification. All included
* entries will have their operational attributes merged with the
* operational attributes calculated above.
* ----------------------------------------------------------------
*/
LdapDN baseDn = ( LdapDN ) apName.clone();
baseDn.addAll( ss.getBase() );
ExprNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT_OID ); // (objectClass=*)
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
EntryFilteringCursor subentries = nexus.search( new SearchOperationContext( addContext.getSession(),
baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
while ( subentries.next() )
{
ServerEntry candidate = subentries.get();
LdapDN dn = candidate.getDn();
dn.normalize( atRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, candidate ) )
{
nexus.modify( new ModifyOperationContext( addContext.getSession(), dn,
getOperationalModsForAdd( candidate, operational ) ) );
}
}
// TODO why are we doing this here if we got the entry from the
// opContext in the first place - got to look into this
addContext.setEntry( entry );
}
else
{
Iterator<String> list = subentryCache.nameIterator();
while ( list.hasNext() )
{
String subentryDnStr = list.next();
LdapDN subentryDn = new LdapDN( subentryDnStr );
LdapDN apDn = ( LdapDN ) subentryDn.clone();
apDn.remove( apDn.size() - 1 );
Subentry subentry = subentryCache.getSubentry( subentryDnStr );
SubtreeSpecification ss = subentry.getSubtreeSpecification();
if ( evaluator.evaluate( ss, apDn, name, entry ) )
{
EntryAttribute operational;