Package org.apache.directory.api.ldap.model.message

Examples of org.apache.directory.api.ldap.model.message.Referral


                    List<String> urls = new ArrayList<String>();
                    {
                        while ( referralsInfo.hasMoreReferrals() )
                        {
                            Referral referral = referralsInfo.getNextReferral();
                            for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
                            {
                                logger.logSearchResultReference( connection, referral, referralsInfo, requestNum, null );
                            }
                            urls.addAll( referral.getLdapUrls() );
                        }
                    }


                    public SearchResult nextElement()
                    {
                        throw new UnsupportedOperationException( "Call next() instead of nextElement() !" ); //$NON-NLS-1$
                    }


                    public boolean hasMoreElements()
                    {
                        throw new UnsupportedOperationException( "Call hasMore() instead of hasMoreElements() !" ); //$NON-NLS-1$
                    }


                    public SearchResult next() throws NamingException
                    {
                        try
                        {
                            LdapUrl url = new LdapUrl( urls.remove( 0 ) );
                            SearchResult searchResult = new SearchResult( url.getDn().getName(), null,
                                new BasicAttributes(),
                                false );
                            searchResult.setNameInNamespace( url.getDn().getName() );
                            StudioSearchResult ssr = new StudioSearchResult( searchResult, null, false, url );
                            return ssr;
                        }
                        catch ( LdapURLEncodingException e )
                        {
                            throw new NamingException( e.getMessage() );
                        }
                    }


                    public boolean hasMore() throws NamingException
                    {
                        return !urls.isEmpty();
                    }


                    public void close() throws NamingException
                    {
                        urls.clear();
                        referralsInfo = null;
                    }
                };
            }
            else if ( referralsHandlingMethod == ReferralHandlingMethod.FOLLOW )
            {
                Referral referral = referralsInfo.getNextReferral();
                for ( IJndiLogger logger : ConnectionCorePlugin.getDefault().getJndiLoggers() )
                {
                    logger.logSearchResultReference( connection, referral, referralsInfo, requestNum, null );
                }
                List<String> urls = new ArrayList<String>( referral.getLdapUrls() );
                LdapUrl url = new LdapUrl( urls.get( 0 ) );
                Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral, monitor, this );
                if ( referralConnection != null )
                {
                    done = false;
View Full Code Here


     */
    public Referral getNextReferral()
    {
        if ( !referralsToProcess.isEmpty() )
        {
            Referral referral = referralsToProcess.removeFirst();
            for ( String url : referral.getLdapUrls() )
            {
                processedUrls.add( url );
            }
            return referral;
        }
View Full Code Here

                    return true;
                }

                if ( ( referralsList != null ) && ( referralsList.size() > 0 ) )
                {
                    Referral referral = referralsList.remove( 0 );
                    List<String> referralUrls = new ArrayList<String>( referral.getLdapUrls() );
                    LdapUrl url = new LdapUrl( referralUrls.get( 0 ) );

                    Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral, monitor,
                        this );
                    if ( referralConnection != null )
View Full Code Here

                {
                    logModification = false;
                    try
                    {
                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
                        Referral referral = newReferralsInfo.getNextReferral();
                        if ( referral != null )
                        {
                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
                                monitor, this );
                            if ( referralConnection != null )
                            {
                                List<String> urls = new ArrayList<String>( referral.getLdapUrls() );

                                String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
                                referralConnection.getConnectionWrapper().modifyEntry( referralDn,
                                    modificationItems, controls, monitor, newReferralsInfo );
                            }
View Full Code Here

                {
                    logModification = false;
                    try
                    {
                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
                        Referral referral = newReferralsInfo.getNextReferral();
                        if ( referral != null )
                        {
                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
                                monitor, this );
                            if ( referralConnection != null )
View Full Code Here

                {
                    logModification = false;
                    try
                    {
                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
                        Referral referral = newReferralsInfo.getNextReferral();
                        if ( referral != null )
                        {
                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
                                monitor, this );
                            if ( referralConnection != null )
                            {
                                List<String> urls = new ArrayList<String>( referral.getLdapUrls() );

                                String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
                                referralConnection.getConnectionWrapper().createEntry( referralDn, attributes,
                                    controls, monitor, newReferralsInfo );
                            }
View Full Code Here

                {
                    logModification = false;
                    try
                    {
                        ReferralsInfo newReferralsInfo = handleReferralException( re, referralsInfo );
                        Referral referral = newReferralsInfo.getNextReferral();
                        if ( referral != null )
                        {
                            Connection referralConnection = ConnectionWrapperUtils.getReferralConnection( referral,
                                monitor, this );
                            if ( referralConnection != null )
                            {
                                List<String> urls = new ArrayList<String>( referral.getLdapUrls() );

                                String referralDn = new LdapUrl( urls.get( 0 ) ).getDn().getName();
                                referralConnection.getConnectionWrapper().deleteEntry( referralDn, controls,
                                    monitor, newReferralsInfo );
                            }
View Full Code Here

        if ( initialReferralsInfo == null )
        {
            initialReferralsInfo = new ReferralsInfo();
        }

        Referral referral = handleReferralException( referralException, initialReferralsInfo, null );

        while ( referralException.skipReferral() )
        {
            try
            {
View Full Code Here

                }

                // if we get here then we have a valid referral ancestor
                try
                {
                    Referral referral = getReferralOnAncestorForSearch( session, req, referralAncestor );

                    result.setResultCode( ResultCodeEnum.REFERRAL );
                    result.setReferral( referral );
                    session.getIoSession().write( req.getResultResponse() );
                }
View Full Code Here

        {
            LOG.debug( "Inside getReferralOnAncestor()" );
        }

        Attribute refAttr = ( ( ClonedServerEntry ) referralAncestor ).getOriginalEntry().get( SchemaConstants.REF_AT );
        Referral referral = new ReferralImpl();

        for ( Value<?> value : refAttr )
        {
            String ref = value.getString();

            if ( IS_DEBUG )
            {
                LOG.debug( "Calculating LdapURL for referrence value {}", ref );
            }

            // need to add non-ldap URLs as-is
            if ( !ref.startsWith( "ldap" ) )
            {
                referral.addLdapUrl( ref );
                continue;
            }

            // Parse the ref value
            LdapUrl ldapUrl = null;

            try
            {
                ldapUrl = new LdapUrl( ref );
            }
            catch ( LdapURLEncodingException e )
            {
                LOG.error( I18n.err( I18n.ERR_165, ref, referralAncestor ) );
            }

            // Normalize the Dn to check for same dn
            Dn urlDn = new Dn( session.getCoreSession().getDirectoryService()
                .getSchemaManager(), ldapUrl.getDn().getName() );

            if ( urlDn.getNormName().equals( req.getBase().getNormName() ) )
            {
                ldapUrl.setForceScopeRendering( true );
                ldapUrl.setAttributes( req.getAttributes() );
                ldapUrl.setScope( req.getScope().getScope() );
                referral.addLdapUrl( ldapUrl.toString() );
                continue;
            }

            /*
             * If we get here then the Dn of the referral was not the same as the
             * Dn of the ref LDAP URL.  We must calculate the remaining (difference)
             * name past the farthest referral Dn which the target name extends.
             */
            Dn suffix = req.getBase().getDescendantOf( referralAncestor.getDn() );
            Dn refDn = urlDn.add( suffix );

            ldapUrl.setDn( refDn );
            ldapUrl.setForceScopeRendering( true );
            ldapUrl.setAttributes( req.getAttributes() );
            ldapUrl.setScope( req.getScope().getScope() );
            referral.addLdapUrl( ldapUrl.toString() );
        }

        return referral;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.message.Referral

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.