* new subentry. In the process we make sure the proper roles are
* supported by the administrative point to allow the addition of
* this new subentry.
* ----------------------------------------------------------------
*/
Subentry subentry = new Subentry();
subentry.setAdministrativeRoles( getSubentryAdminRoles( entry ) );
List<Attribute> operationalAttributes = getSubentryOperationalAttributes( dn, subentry );
/* ----------------------------------------------------------------
* Parse the subtreeSpecification of the subentry and add it to the
* SubtreeSpecification cache. If the parse succeeds we continue
* to add the entry to the DIT. Thereafter we search out entries
* to modify the subentry operational attributes of.
* ----------------------------------------------------------------
*/
setSubtreeSpecification( subentry, entry );
directoryService.getSubentryCache().addSubentry( dn, subentry );
// Now inject the subentry into the backend
next( 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.
* ----------------------------------------------------------------
*/
Dn baseDn = apDn;
baseDn = baseDn.add( subentry.getSubtreeSpecification().getBase() );
updateEntries( OperationEnum.ADD, addContext.getSession(), dn, apDn, subentry.getSubtreeSpecification(),
baseDn, operationalAttributes );
// Store the newly modified entry into the context for later use in interceptor
// just in case
addContext.setEntry( entry );
}
else
{
// The added entry is not a Subentry.
// Nevertheless, we have to check if the entry is added into an AdministrativePoint
// and is associated with some SubtreeSpecification
// We brutally check *all* the subentries, as we don't hold a hierarchy
// of AP
// TODO : add a hierarchy of subentries
for ( Dn subentryDn : directoryService.getSubentryCache() )
{
Dn apDn = subentryDn.getParent();
// No need to evaluate the entry if it's not below an AP.
if ( dn.isDescendantOf( apDn ) )
{
Subentry subentry = directoryService.getSubentryCache().getSubentry( subentryDn );
SubtreeSpecification ss = subentry.getSubtreeSpecification();
// Now, evaluate the entry wrt the subentry ss
// and inject a ref to the subentry if it evaluates to true
if ( directoryService.getEvaluator().evaluate( ss, apDn, dn, entry ) )
{
if ( subentry.isAccessControlAdminRole() )
{
setOperationalAttribute( entry, subentryDn, ACCESS_CONTROL_SUBENTRIES_AT );
}
if ( subentry.isSchemaAdminRole() )
{
setOperationalAttribute( entry, subentryDn, SUBSCHEMA_SUBENTRY_AT );
}
if ( subentry.isCollectiveAdminRole() )
{
setOperationalAttribute( entry, subentryDn, COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
}
if ( subentry.isTriggersAdminRole() )
{
setOperationalAttribute( entry, subentryDn, TRIGGER_EXECUTION_SUBENTRIES_AT );
}
}
}