if ( subentry.isAutonomousAreaSubentry() ) { operational.add( subentryDn.toString() ); }
    public void add( NextInterceptor next, LdapDN normName, Attributes entry ) throws NamingException    {        Attribute objectClasses = entry.get( "objectClass" );        if ( objectClasses.contains( "subentry" ) )        {            // get the name of the administrative point and its administrativeRole attributes            LdapDN apName = ( LdapDN ) normName.clone();            apName.remove( normName.size() - 1 );            Attributes ap = nexus.lookup( apName );            Attribute administrativeRole = ap.get( "administrativeRole" );            // check that administrativeRole has something valid in it for us            if ( administrativeRole == null || administrativeRole.size() <= 0 )            {                throw new LdapNoSuchAttributeException( "Administration point " + apName                    + " does not contain an administrativeRole attribute! An"                    + " administrativeRole attribute in the administrative point is"                    + " required to add a subordinate subentry." );            }            /* ----------------------------------------------------------------             * Build the set of operational attributes to be injected into             * entries that are contained within the subtree repesented by this             * 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.             * ----------------------------------------------------------------             */            Attributes operational = getSubentryOperatationalAttributes( normName, administrativeRole );            /* ----------------------------------------------------------------             * 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.             * ----------------------------------------------------------------             */            String subtree = ( String ) entry.get( "subtreeSpecification" ).get();            SubtreeSpecification ss;            try            {                ss = ssParser.parse( subtree );            }            catch ( Exception e )            {                String msg = "Failed while parsing subtreeSpecification for " + normName.getUpName();                log.warn( msg );                throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX );            }            subentryCache.setSubentry( normName.toString(), ss, getSubentryTypes( entry ) );            next.add(normName, entry );            /* ----------------------------------------------------------------             * 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( "2.5.4.0" ); // (objectClass=*)            SearchControls controls = new SearchControls();            controls.setSearchScope( SearchControls.SUBTREE_SCOPE );            controls.setReturningAttributes( new String[]                { "+", "*" } );            NamingEnumeration subentries = nexus.search( baseDn, factoryCfg.getEnvironment(), filter, controls );            while ( subentries.hasMore() )            {                SearchResult result = ( SearchResult ) subentries.next();                Attributes candidate = result.getAttributes();                LdapDN dn = new LdapDN( result.getName() );                dn.normalize( attrRegistry.getNormalizerMapping() );                if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) )                {                    nexus.modify( dn, getOperationalModsForAdd( candidate, operational ) );                }            }        }        else        {            Iterator list = subentryCache.nameIterator();            while ( list.hasNext() )            {                String subentryDnStr = ( String ) list.next();                LdapDN subentryDn = new LdapDN( subentryDnStr );                LdapDN apDn = ( LdapDN ) subentryDn.clone();                apDn.remove( apDn.size() - 1 );                Subentry subentry = subentryCache.getSubentry( subentryDn.toNormName() );                SubtreeSpecification ss = subentry.getSubtreeSpecification();                if ( evaluator.evaluate( ss, apDn, normName, objectClasses ) )                {                    Attribute administrativeRole = nexus.lookup( apDn ).get( "administrativeRole" );                    NamingEnumeration roles = administrativeRole.getAll();                    while ( roles.hasMore() )                    {                        Attribute operational;                        String role = ( String ) roles.next();                        if ( role.equalsIgnoreCase( AUTONOUMOUS_AREA ) )                        {                            operational = entry.get( AUTONOUMOUS_AREA_SUBENTRY );                            if ( operational == null )                            {                                operational = new LockableAttributeImpl( AUTONOUMOUS_AREA_SUBENTRY );                                entry.put( operational );                            }                                                        if ( subentry.isAutonomousAreaSubentry() )                            {                                operational.add( subentryDn.toString() );                            }                        }                        else if ( role.equalsIgnoreCase( AC_AREA ) || role.equalsIgnoreCase( AC_INNERAREA ) )                        {                            operational = entry.get( AC_SUBENTRY );                            if ( operational == null )                            {                                operational = new LockableAttributeImpl( AC_SUBENTRY );                                entry.put( operational );                            }                                                        if ( subentry.isAccessControlSubentry() )                            {                                operational.add( subentryDn.toString() );                            }                        }                        else if ( role.equalsIgnoreCase( SCHEMA_AREA ) )                        {                            operational = entry.get( SCHEMA_AREA_SUBENTRY );                            if ( operational == null )                            {                                operational = new LockableAttributeImpl( SCHEMA_AREA_SUBENTRY );                                entry.put( operational );                            }                                                        if ( subentry.isSchemaSubentry() )                            {                                operational.add( subentryDn.toString() );                            }                        }                        else if ( role.equalsIgnoreCase( COLLECTIVE_AREA )                            || role.equalsIgnoreCase( COLLECTIVE_INNERAREA ) )                        {                            operational = entry.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES );                            if ( operational == null )                            {                                operational = new LockableAttributeImpl( COLLECTIVE_ATTRIBUTE_SUBENTRIES );                                entry.put( operational );                            }                                                        if ( subentry.isCollectiveSubentry() )                            {                                operational.add( subentryDn.toString() );                            }                        }                        else if ( role.equalsIgnoreCase( TRIGGER_AREA ) || role.equalsIgnoreCase( TRIGGER_INNERAREA ) )                        {                            operational = entry.get( TRIGGER_SUBENTRIES );                            if ( operational == null )                            {                                operational = new LockableAttributeImpl( TRIGGER_SUBENTRIES );                                entry.put( operational );                            }                        }                        else                        {                            throw new LdapInvalidAttributeValueException(                                "Encountered invalid administrativeRole '"                                    + role                                    + "' in administrative point of subentry "                                    + subentryDnStr                                    + ". The values of this attribute"                                    + " are constrained to autonomousArea, accessControlSpecificArea, accessControlInnerArea,"                                    + " subschemaAdminSpecificArea, collectiveAttributeSpecificArea, collectiveAttributeInnerArea,"                                    + " triggerArea and triggerInnerArea.", ResultCodeEnum.CONSTRAINTVIOLATION );                        }//                        operational.add( subentryDn.toString() );                    }                }            }            next.add(normName, entry );        }    }