Package org.apache.directory.studio.connection.core.io

Examples of org.apache.directory.studio.connection.core.io.ConnectionIOException


        {
            document = saxReader.read( stream );
        }
        catch ( DocumentException e )
        {
            throw new ConnectionIOException( e.getMessage() );
        }

        Element rootElement = document.getRootElement();
        if ( !rootElement.getName().equals( BROWSER_CONNECTIONS_TAG ) )
        {
            throw new ConnectionIOException( "The file does not seem to be a valid BrowserConnections file." );
        }

        for ( Iterator<?> i = rootElement.elementIterator( BROWSER_CONNECTION_TAG ); i.hasNext(); )
        {
            Element browserConnectionElement = ( Element ) i.next();
View Full Code Here


            {
                searchParameter.setSearchBase( new LdapDN( searchBaseAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Search Base' of search '"
                    + searchParameter.getName() + "' :" + searchBaseAttribute.getValue() );
            }
        }

        // Filter
        Attribute filterAttribute = searchParameterElement.attribute( FILTER_TAG );
        if ( filterAttribute != null )
        {
            searchParameter.setFilter( filterAttribute.getValue() );
        }

        // Returning Attributes
        Element returningAttributesElement = searchParameterElement.element( RETURNING_ATTRIBUTES_TAG );
        if ( returningAttributesElement != null )
        {
            List<String> returningAttributes = new ArrayList<String>();
            for ( Iterator<?> i = returningAttributesElement.elementIterator( RETURNING_ATTRIBUTE_TAG ); i.hasNext(); )
            {
                Element returningAttributeElement = ( Element ) i.next();

                Attribute valueAttribute = returningAttributeElement.attribute( VALUE_TAG );
                if ( valueAttribute != null )
                {
                    returningAttributes.add( valueAttribute.getValue() );
                }
            }
            searchParameter.setReturningAttributes( returningAttributes
                .toArray( new String[returningAttributes.size()] ) );
        }

        // Scope
        Attribute scopeAttribute = searchParameterElement.attribute( SCOPE_TAG );
        if ( scopeAttribute != null )
        {
            try
            {
                searchParameter.setScope( SearchScope.valueOf( scopeAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Scope' of search '" + searchParameter.getName()
                    + "' as int value. Scope value :" + scopeAttribute.getValue() );
            }
        }

        // Time limit
        Attribute timeLimitAttribute = searchParameterElement.attribute( TIME_LIMIT_TAG );
        if ( timeLimitAttribute != null )
        {
            try
            {
                searchParameter.setTimeLimit( Integer.parseInt( timeLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Time limit' of search '" + searchParameter.getName()
                    + "' as int value. Time limit value :" + timeLimitAttribute.getValue() );
            }
        }

        // Count limit
        Attribute countLimitAttribute = searchParameterElement.attribute( COUNT_LIMIT_TAG );
        if ( countLimitAttribute != null )
        {
            try
            {
                searchParameter.setCountLimit( Integer.parseInt( countLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Count limit' of search '"
                    + searchParameter.getName() + "' as int value. Count limit value :"
                    + countLimitAttribute.getValue() );
            }
        }

        // Alias dereferencing method
        Attribute aliasesDereferencingMethodAttribute = searchParameterElement
            .attribute( ALIASES_DEREFERENCING_METHOD_TAG );
        if ( aliasesDereferencingMethodAttribute != null )
        {
            try
            {
                searchParameter.setAliasesDereferencingMethod( Connection.AliasDereferencingMethod
                    .valueOf( aliasesDereferencingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Aliases Dereferencing Method' of search '"
                    + searchParameter.getName() + "' as int value. Aliases Dereferencing Method value :"
                    + aliasesDereferencingMethodAttribute.getValue() );
            }
        }

        // Referrals handling method
        Attribute referralsHandlingMethodAttribute = searchParameterElement.attribute( REFERRALS_HANDLING_METHOD_TAG );
        if ( referralsHandlingMethodAttribute != null )
        {
            try
            {
                searchParameter.setReferralsHandlingMethod( Connection.ReferralHandlingMethod
                    .valueOf( referralsHandlingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Referrals Handling Method' of search '"
                    + searchParameter.getName() + "' as int value. Referrals Handling Method value :"
                    + referralsHandlingMethodAttribute.getValue() );
            }
        }

        // Controls
        Element controlsElement = searchParameterElement.element( CONTROLS_TAG );
        if ( controlsElement != null )
        {
            for ( Iterator<?> i = controlsElement.elementIterator( CONTROL_TAG ); i.hasNext(); )
            {
                Element controlElement = ( Element ) i.next();

                Attribute valueAttribute = controlElement.attribute( VALUE_TAG );
                if ( valueAttribute != null )
                {
                    byte[] bytes = Base64.decode( valueAttribute.getValue().toCharArray() );
                    ByteArrayInputStream bais = null;
                    ObjectInputStream ois = null;
                    try
                    {
                        bais = new ByteArrayInputStream( bytes );
                        ois = new ObjectInputStream( bais );
                        StudioControl control = ( StudioControl ) ois.readObject();
                        searchParameter.getControls().add( control );
                        ois.close();
                    }
                    catch ( Exception e )
                    {
                        throw new ConnectionIOException( "Unable to parse 'Control' of search '"
                            + searchParameter.getName() + "'. Control value :" + valueAttribute.getValue() );
                    }
                }
            }
        }
View Full Code Here

            {
                bookmarkParameter.setDn( new LdapDN( dnAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'DN' of bookmark '" + bookmarkParameter.getName()
                    + "' :" + dnAttribute.getValue() );
            }
        }

        return bookmarkParameter;
View Full Code Here

        {
            document = saxReader.read( stream );
        }
        catch ( DocumentException e )
        {
            throw new ConnectionIOException( e.getMessage() );
        }

        Element rootElement = document.getRootElement();
        if ( !rootElement.getName().equals( BROWSER_CONNECTIONS_TAG ) )
        {
            throw new ConnectionIOException( "The file does not seem to be a valid BrowserConnections file." );
        }

        for ( Iterator<?> i = rootElement.elementIterator( BROWSER_CONNECTION_TAG ); i.hasNext(); )
        {
            Element browserConnectionElement = ( Element ) i.next();
View Full Code Here

            {
                searchParameter.setSearchBase( new LdapDN( searchBaseAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Search Base' of search '" + searchParameter.getName()
                    + "' :" + searchBaseAttribute.getValue() );
            }
        }
       
        // Filter
        Attribute filterAttribute = searchParameterElement.attribute( FILTER_TAG );
        if ( filterAttribute != null )
        {
            searchParameter.setFilter( filterAttribute.getValue() );
        }
       
        // Returning Attributes
        Element returningAttributesElement = searchParameterElement.element( RETURNING_ATTRIBUTES_TAG );
        if ( returningAttributesElement != null )
        {
            List<String> returningAttributes = new ArrayList<String>();
            for ( Iterator<?> i = returningAttributesElement.elementIterator( RETURNING_ATTRIBUTE_TAG ); i.hasNext(); )
            {
                Element returningAttributeElement = ( Element ) i.next();
               
                Attribute valueAttribute = returningAttributeElement.attribute( VALUE_TAG );
                if ( valueAttribute != null )
                {
                    returningAttributes.add( valueAttribute.getValue() );
                }
            }
            searchParameter.setReturningAttributes( returningAttributes
                .toArray( new String[returningAttributes.size()] ) );
        }
       
        // Scope
        Attribute scopeAttribute = searchParameterElement.attribute( SCOPE_TAG );
        if ( scopeAttribute != null )
        {
            try
            {
                searchParameter.setScope( SearchScope.valueOf( scopeAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Scope' of search '"
                    + searchParameter.getName() + "' as int value. Scope value :"
                    + scopeAttribute.getValue() );
            }
        }
       
        // Time limit
        Attribute timeLimitAttribute = searchParameterElement.attribute( TIME_LIMIT_TAG );
        if ( timeLimitAttribute != null )
        {
            try
            {
                searchParameter.setTimeLimit( Integer.parseInt( timeLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Time limit' of search '" + searchParameter.getName()
                    + "' as int value. Time limit value :" + timeLimitAttribute.getValue() );
            }
        }
       
        // Count limit
        Attribute countLimitAttribute = searchParameterElement.attribute( COUNT_LIMIT_TAG );
        if ( countLimitAttribute != null )
        {
            try
            {
                searchParameter.setCountLimit( Integer.parseInt( countLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Count limit' of search '" + searchParameter.getName()
                    + "' as int value. Count limit value :" + countLimitAttribute.getValue() );
            }
        }
       
        // Alias dereferencing method
        Attribute aliasesDereferencingMethodAttribute = searchParameterElement.attribute( ALIASES_DEREFERENCING_METHOD_TAG );
        if ( aliasesDereferencingMethodAttribute != null )
        {
            try
            {
                searchParameter.setAliasesDereferencingMethod( Connection.AliasDereferencingMethod
                    .valueOf( aliasesDereferencingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Aliases Dereferencing Method' of search '"
                    + searchParameter.getName() + "' as int value. Aliases Dereferencing Method value :"
                    + aliasesDereferencingMethodAttribute.getValue() );
            }
        }
       
        // Referrals handling method
        Attribute referralsHandlingMethodAttribute = searchParameterElement.attribute( REFERRALS_HANDLING_METHOD_TAG );
        if ( referralsHandlingMethodAttribute != null )
        {
            try
            {
                searchParameter.setReferralsHandlingMethod( Connection.ReferralHandlingMethod
                    .valueOf( referralsHandlingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Referrals Handling Method' of search '"
                    + searchParameter.getName() + "' as int value. Referrals Handling Method value :"
                    + referralsHandlingMethodAttribute.getValue() );
            }
        }
   
View Full Code Here

            {
                bookmarkParameter.setDn( new LdapDN( dnAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'DN' of bookmark '" + bookmarkParameter.getName()
                    + "' :" + dnAttribute.getValue() );
            }
        }
   
        return bookmarkParameter;
View Full Code Here

        {
            document = saxReader.read( stream );
        }
        catch ( DocumentException e )
        {
            throw new ConnectionIOException( e.getMessage() );
        }

        Element rootElement = document.getRootElement();
        if ( !rootElement.getName().equals( BROWSER_CONNECTIONS_TAG ) )
        {
            throw new ConnectionIOException( "The file does not seem to be a valid BrowserConnections file." );
        }

        for ( Iterator<?> i = rootElement.elementIterator( BROWSER_CONNECTION_TAG ); i.hasNext(); )
        {
            Element browserConnectionElement = ( Element ) i.next();
View Full Code Here

            {
                searchParameter.setSearchBase( new LdapDN( searchBaseAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Search Base' of search '" + searchParameter.getName()
                    + "' :" + searchBaseAttribute.getValue() );
            }
        }
       
        // Filter
        Attribute filterAttribute = searchParameterElement.attribute( FILTER_TAG );
        if ( filterAttribute != null )
        {
            searchParameter.setFilter( filterAttribute.getValue() );
        }
       
        // Returning Attributes
        Element returningAttributesElement = searchParameterElement.element( RETURNING_ATTRIBUTES_TAG );
        if ( returningAttributesElement != null )
        {
            List<String> returningAttributes = new ArrayList<String>();
            for ( Iterator<?> i = returningAttributesElement.elementIterator( RETURNING_ATTRIBUTE_TAG ); i.hasNext(); )
            {
                Element returningAttributeElement = ( Element ) i.next();
               
                Attribute valueAttribute = returningAttributeElement.attribute( VALUE_TAG );
                if ( valueAttribute != null )
                {
                    returningAttributes.add( valueAttribute.getValue() );
                }
            }
            searchParameter.setReturningAttributes( returningAttributes
                .toArray( new String[returningAttributes.size()] ) );
        }
       
        // Scope
        Attribute scopeAttribute = searchParameterElement.attribute( SCOPE_TAG );
        if ( scopeAttribute != null )
        {
            try
            {
                searchParameter.setScope( SearchScope.valueOf( scopeAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Scope' of search '"
                    + searchParameter.getName() + "' as int value. Scope value :"
                    + scopeAttribute.getValue() );
            }
        }
       
        // Time limit
        Attribute timeLimitAttribute = searchParameterElement.attribute( TIME_LIMIT_TAG );
        if ( timeLimitAttribute != null )
        {
            try
            {
                searchParameter.setTimeLimit( Integer.parseInt( timeLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Time limit' of search '" + searchParameter.getName()
                    + "' as int value. Time limit value :" + timeLimitAttribute.getValue() );
            }
        }
       
        // Count limit
        Attribute countLimitAttribute = searchParameterElement.attribute( COUNT_LIMIT_TAG );
        if ( countLimitAttribute != null )
        {
            try
            {
                searchParameter.setCountLimit( Integer.parseInt( countLimitAttribute.getValue() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Count limit' of search '" + searchParameter.getName()
                    + "' as int value. Count limit value :" + countLimitAttribute.getValue() );
            }
        }
       
        // Alias dereferencing method
        Attribute aliasesDereferencingMethodAttribute = searchParameterElement.attribute( ALIASES_DEREFERENCING_METHOD_TAG );
        if ( aliasesDereferencingMethodAttribute != null )
        {
            try
            {
                searchParameter.setAliasesDereferencingMethod( Connection.AliasDereferencingMethod
                    .valueOf( aliasesDereferencingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Aliases Dereferencing Method' of search '"
                    + searchParameter.getName() + "' as int value. Aliases Dereferencing Method value :"
                    + aliasesDereferencingMethodAttribute.getValue() );
            }
        }
       
        // Referrals handling method
        Attribute referralsHandlingMethodAttribute = searchParameterElement.attribute( REFERRALS_HANDLING_METHOD_TAG );
        if ( referralsHandlingMethodAttribute != null )
        {
            try
            {
                searchParameter.setReferralsHandlingMethod( Connection.ReferralHandlingMethod
                    .valueOf( referralsHandlingMethodAttribute.getValue() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new ConnectionIOException( "Unable to parse 'Referrals Handling Method' of search '"
                    + searchParameter.getName() + "' as int value. Referrals Handling Method value :"
                    + referralsHandlingMethodAttribute.getValue() );
            }
        }
   
View Full Code Here

            {
                bookmarkParameter.setDn( new LdapDN( dnAttribute.getValue() ) );
            }
            catch ( InvalidNameException e )
            {
                throw new ConnectionIOException( "Unable to parse 'DN' of bookmark '" + bookmarkParameter.getName()
                    + "' :" + dnAttribute.getValue() );
            }
        }
   
        return bookmarkParameter;
View Full Code Here

        {
            document = saxReader.read( stream );
        }
        catch ( DocumentException e )
        {
            throw new ConnectionIOException( e.getMessage() );
        }

        Element rootElement = document.getRootElement();
        if ( !rootElement.getName().equals( BROWSER_CONNECTIONS_TAG ) )
        {
            throw new ConnectionIOException( BrowserCoreMessages.BrowserConnectionIO_TheFileDoesNotSeemToBeValid );
        }

        for ( Iterator<?> i = rootElement.elementIterator( BROWSER_CONNECTION_TAG ); i.hasNext(); )
        {
            Element browserConnectionElement = ( Element ) i.next();
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.connection.core.io.ConnectionIOException

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.