Package org.apache.ldap.common.subtree

Examples of org.apache.ldap.common.subtree.SubtreeSpecification


        Attributes entry = nexus.lookup( name );
        Attribute objectClasses = entry.get( "objectClass" );

        if ( objectClasses.contains( "subentry" ) )
        {
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( name.toString() );
            subtrees.remove( ss );
            next.delete( name );

            /* ----------------------------------------------------------------
             * Find the baseDn for the subentry and use that to search the tree
             * for all entries included by the subtreeSpecification.  Then we
             * check the entry for subentry operational attribute that contain
             * the DN of the subentry.  These are the subentry operational
             * attributes we remove from the entry in a modify operation.
             * ----------------------------------------------------------------
             */
            Name apName = ( Name ) name.clone();
            apName.remove( name.size() - 1 );
            Name baseDn = ( Name ) apName.clone();
            baseDn.addAll( ss.getBase() );

            ExprNode filter = new PresenceNode( "objectclass" );
            SearchControls controls = new SearchControls();
            controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
            controls.setReturningAttributes( new String[] { "+", "*" } );
View Full Code Here


        while ( subentries.hasNext() )
        {
            String subentryDn = ( String ) subentries.next();
            Name apDn = new LdapName( subentryDn );
            apDn.remove( apDn.size() - 1 );
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn );
            boolean isOldNameSelected = evaluator.evaluate( ss, apDn, oldName, objectClasses );
            boolean isNewNameSelected = evaluator.evaluate( ss, apDn, newName, objectClasses );

            if ( isOldNameSelected == isNewNameSelected )
            {
View Full Code Here

        Attributes entry = nexus.lookup( name );
        Attribute objectClasses = entry.get( "objectClass" );

        if ( objectClasses.contains( "subentry" ) )
        {
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( name.toString() );
            Name apName = ( Name ) name.clone();
            apName.remove( apName.size() - 1 );
            Name baseDn = ( Name ) apName.clone();
            baseDn.addAll( ss.getBase() );
            Name newName = ( Name ) name.clone();
            newName.remove( newName.size() - 1 );
            Name rdn = dnParser.parse( newRn );
            newName.addAll( rdn );
View Full Code Here

        Attributes entry = nexus.lookup( oriChildName );
        Attribute objectClasses = entry.get( "objectClass" );

        if ( objectClasses.contains( "subentry" ) )
        {
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( oriChildName.toString() );
            Name apName = ( Name ) oriChildName.clone();
            apName.remove( apName.size() - 1 );
            Name baseDn = ( Name ) apName.clone();
            baseDn.addAll( ss.getBase() );
            Name newName = ( Name ) newParentName.clone();
            newName.remove( newName.size() - 1 );
            Name rdn = dnParser.parse( newRn );
            newName.addAll( rdn );
View Full Code Here

        Attributes entry = nexus.lookup( oriChildName );
        Attribute objectClasses = entry.get( "objectClass" );

        if ( objectClasses.contains( "subentry" ) )
        {
            SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( oriChildName.toString() );
            Name apName = ( Name ) oriChildName.clone();
            apName.remove( apName.size() - 1 );
            Name baseDn = ( Name ) apName.clone();
            baseDn.addAll( ss.getBase() );
            Name newName = ( Name ) newParentName.clone();
            newName.remove( newName.size() - 1 );
            newName.add( newParentName.get( newParentName.size() - 1 ) );

            subtrees.put( newName.toString(), ss );
View Full Code Here

        Attributes entry = nexus.lookup( name );
        Attribute objectClasses = entry.get( "objectClass" );

        if ( objectClasses.contains( "subentry" ) && mods.get( "subtreeSpecification" ) != null )
        {
            SubtreeSpecification ssOld = ( SubtreeSpecification ) subtrees.remove( name.toString() );
            SubtreeSpecification ssNew;

            try
            {
                ssNew = ssParser.parse( ( String ) mods.get( "subtreeSpecification" ).get() );
            }
            catch ( Exception e )
            {
                String msg = "failed to parse the new subtreeSpecification";
                log.error( msg, e );
                throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX );
            }

            subtrees.put( name.toString(), ssNew );
            next.modify( name, modOp, mods );

            // search for all entries selected by the old SS and remove references to subentry
            Name apName = ( Name ) name.clone();
            apName.remove( apName.size() - 1 );
            Name oldBaseDn = ( Name ) apName.clone();
            oldBaseDn.addAll( ssOld.getBase() );
            ExprNode filter = new PresenceNode( "objectClass" );
            SearchControls controls = new SearchControls();
            controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
            controls.setReturningAttributes( new String[] { "+", "*" } );
            NamingEnumeration subentries = nexus.search( oldBaseDn, factoryCfg.getEnvironment(), filter, controls );
            while ( subentries.hasMore() )
            {
                SearchResult result = ( SearchResult ) subentries.next();
                Attributes candidate = result.getAttributes();
                Name dn = dnParser.parse( result.getName() );

                if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) )
                {
                    nexus.modify( dn, getOperationalModsForRemove( name, candidate ) );
                }
            }

            // search for all selected entries by the new SS and add references to subentry
            Attributes apAttrs = nexus.lookup( apName );
            Attribute administrativeRole = apAttrs.get( "administrativeRole" );
            Attributes operational = getSubentryOperatationalAttributes( name, administrativeRole );
            Name newBaseDn = ( Name ) apName.clone();
            newBaseDn.addAll( ssNew.getBase() );
            subentries = nexus.search( newBaseDn, factoryCfg.getEnvironment(), filter, controls );
            while ( subentries.hasMore() )
            {
                SearchResult result = ( SearchResult ) subentries.next();
                Attributes candidate = result.getAttributes();
View Full Code Here

            }
        }

        if ( objectClasses.contains( "subentry" ) && isSubtreeSpecificationModification )
        {
            SubtreeSpecification ssOld = ( SubtreeSpecification ) subtrees.remove( name.toString() );
            SubtreeSpecification ssNew;

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

            subtrees.put( name.toString(), ssNew );
            next.modify( name, mods );

            // search for all entries selected by the old SS and remove references to subentry
            Name apName = ( Name ) name.clone();
            apName.remove( apName.size() - 1 );
            Name oldBaseDn = ( Name ) apName.clone();
            oldBaseDn.addAll( ssOld.getBase() );
            ExprNode filter = new PresenceNode( "objectClass" );
            SearchControls controls = new SearchControls();
            controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
            controls.setReturningAttributes( new String[] { "+", "*" } );
            NamingEnumeration subentries = nexus.search( oldBaseDn, factoryCfg.getEnvironment(), filter, controls );
            while ( subentries.hasMore() )
            {
                SearchResult result = ( SearchResult ) subentries.next();
                Attributes candidate = result.getAttributes();
                Name dn = dnParser.parse( result.getName() );

                if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) )
                {
                    nexus.modify( dn, getOperationalModsForRemove( name, candidate ) );
                }
            }

            // search for all selected entries by the new SS and add references to subentry
            Attributes apAttrs = nexus.lookup( apName );
            Attribute administrativeRole = apAttrs.get( "administrativeRole" );
            Attributes operational = getSubentryOperatationalAttributes( name, administrativeRole );
            Name newBaseDn = ( Name ) apName.clone();
            newBaseDn.addAll( ssNew.getBase() );
            subentries = nexus.search( newBaseDn, factoryCfg.getEnvironment(), filter, controls );
            while ( subentries.hasMore() )
            {
                SearchResult result = ( SearchResult ) subentries.next();
                Attributes candidate = result.getAttributes();
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.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.