Package org.apache.directory.shared.ldap.subtree

Examples of org.apache.directory.shared.ldap.subtree.SubtreeSpecification


        EntryAttribute objectClasses = entry.get( objectClassType );

        if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
        {
            Subentry subentry = subentryCache.getSubentry( oriChildName.toNormName() );
            SubtreeSpecification ss = subentry.getSubtreeSpecification();
            LdapDN apName = ( LdapDN ) oriChildName.clone();
            apName.remove( apName.size() - 1 );
            LdapDN baseDn = ( LdapDN ) apName.clone();
            baseDn.addAll( ss.getBase() );
            LdapDN newName = ( LdapDN ) parent.clone();
            newName.remove( newName.size() - 1 );

            newName.add( opContext.getNewRdn() );
View Full Code Here


        EntryAttribute objectClasses = entry.get( SchemaConstants.OBJECT_CLASS_AT );

        if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
        {
            Subentry subentry = subentryCache.getSubentry( oriChildName.toString() );
            SubtreeSpecification ss = subentry.getSubtreeSpecification();
            LdapDN apName = ( LdapDN ) oriChildName.clone();
            apName.remove( apName.size() - 1 );
            LdapDN baseDn = ( LdapDN ) apName.clone();
            baseDn.addAll( ss.getBase() );
            LdapDN newName = ( LdapDN ) newParentName.clone();
            newName.remove( newName.size() - 1 );
            newName.add( newParentName.get( newParentName.size() - 1 ) );

            String newNormName = newName.toNormName();
View Full Code Here

            }
        }

        if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) && isSubtreeSpecificationModification )
        {
            SubtreeSpecification ssOld = subentryCache.removeSubentry( name.toString() ).getSubtreeSpecification();
            SubtreeSpecification ssNew;

            try
            {
                ssNew = ssParser.parse( ( ( ServerAttribute ) subtreeMod.getAttribute() ).getString() );
            }
            catch ( Exception e )
            {
                String msg = "failed to parse the new subtreeSpecification";
                LOG.error( msg, e );
                throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
            }

            subentryCache.setSubentry( name.toNormName(), ssNew, getSubentryTypes( entry, mods ) );
            next.modify( opContext );

            // search for all entries selected by the old SS and remove references to subentry
            LdapDN apName = ( LdapDN ) name.clone();
            apName.remove( apName.size() - 1 );
            LdapDN oldBaseDn = ( LdapDN ) apName.clone();
            oldBaseDn.addAll( ssOld.getBase() );
            ExprNode filter = new PresenceNode( oidRegistry.getOid( SchemaConstants.OBJECT_CLASS_AT ) );
            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( opContext.getSession(),
                oldBaseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );

            while ( subentries.next() )
            {
                ServerEntry candidate = subentries.get();
                LdapDN dn = candidate.getDn();
                dn.normalize( atRegistry.getNormalizerMapping() );

                if ( evaluator.evaluate( ssOld, apName, dn, candidate ) )
                {
                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn,
                        getOperationalModsForRemove( name, candidate ) ) );
                }
            }

            // search for all selected entries by the new SS and add references to subentry
            Subentry subentry = subentryCache.getSubentry( name.toNormName() );
            ServerEntry operational = getSubentryOperatationalAttributes( name, subentry );
            LdapDN newBaseDn = ( LdapDN ) apName.clone();
            newBaseDn.addAll( ssNew.getBase() );
            subentries = nexus.search( new SearchOperationContext( opContext.getSession(), newBaseDn,
                AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ) );
           
            while ( subentries.next() )
            {
View Full Code Here

        while ( subentries.hasNext() )
        {
            String subentryDn = subentries.next();
            Name apDn = new LdapDN( subentryDn );
            apDn.remove( apDn.size() - 1 );
            SubtreeSpecification ss = subentryCache.getSubentry( subentryDn ).getSubtreeSpecification();
            boolean isOldEntrySelected = evaluator.evaluate( ss, apDn, name, oldEntry );
            boolean isNewEntrySelected = evaluator.evaluate( ss, apDn, name, newEntry );

            if ( isOldEntrySelected == isNewEntrySelected )
            {
View Full Code Here

    @Test
    public void testDefaults() throws Exception
    {
        SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );

        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

    @Test
    public void testWithBase() throws Exception
    {
        SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
        modifier.setBase( new LdapDN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );

        assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

    {
        SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
        modifier.setMinBaseDistance( 1 );
        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new LdapDN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

        chopAfter.add( new LdapDN( "ou=twolevels,uid=akarasulu" ) );
        modifier.setChopAfterExclusions( chopAfter );
        modifier.setMinBaseDistance( 1 );
        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new LdapDN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

        chopBefore.add( new LdapDN( "ou=threelevels,ou=twolevels,uid=akarasulu" ) );
        modifier.setChopBeforeExclusions( chopBefore );
        modifier.setMinBaseDistance( 1 );
        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new LdapDN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );

        assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
View Full Code Here

        SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
        modifier.setRefinement( refinement );
        modifier.setMinBaseDistance( 1 );
        modifier.setMaxBaseDistance( 3 );
        modifier.setBase( new LdapDN( "ou=users" ) );
        SubtreeSpecification ss = modifier.getSubtreeSpecification();
        LdapDN apDn = new LdapDN( "ou=system" );
        LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
        ServerEntry entry = new DefaultServerEntry( registries, entryDn );
        entry.put( "objectClass", "person" );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.subtree.SubtreeSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.