public HttpTransferBase()

in commons-transfer/commons-transfer-http/src/main/java/org/apache/archiva/commons/transfer/http/HttpTransferBase.java [70:132]


    public HttpTransferBase( URI baseuri )
    {
        this.baseuri = baseuri;

        if ( !baseuri.isAbsolute() )
        {
            throw new IllegalArgumentException( "Base URI must be absolute (got \"" + baseuri.toASCIIString() + "\")." );
        }

        protocolMapping.put( "http", "http" );
        protocolMapping.put( "https", "https" );
        protocolMapping.put( "ssl", "https" );
        protocolMapping.put( "dav", "http" );
        protocolMapping.put( "davs", "https" );
        protocolMapping.put( "dav-https", "https" );
        protocolMapping.put( "dav-http", "http" );

        String protocol = baseuri.getScheme();

        if ( !protocolMapping.containsKey( protocol ) )
        {
            StringBuffer msg = new StringBuffer();
            msg.append( "Base URI for " ).append( getClass().getName() );
            msg.append( " must use one of the following protocols " );
            for ( String acceptableProtocol : protocolMapping.keySet() )
            {
                msg.append( "[" ).append( acceptableProtocol ).append( "] " );
            }
            msg.append( ". (got \"" ).append( baseuri.toASCIIString() ).append( "\")" );

            throw new IllegalArgumentException( msg.toString() );
        }
        else
        {
            // We might need to map the protocol.
            String actualProtocol = protocolMapping.get( protocol );
            if ( !actualProtocol.equals( protocol ) )
            {
                String tmpuri = baseuri.toASCIIString();
                try
                {
                    this.baseuri = new URI( actualProtocol + tmpuri.substring( protocol.length() ) );
                }
                catch ( URISyntaxException e )
                {
                    throw new IllegalArgumentException( "Unable to map protocol [" + protocol + "] to ["
                        + actualProtocol + "] with uri " + baseuri.toASCIIString(), e );
                }
            }
        }

        if ( !baseuri.toASCIIString().endsWith( "/" ) )
        {
            throw new IllegalArgumentException( "Base URI must end in '/' character \"" + baseuri + "\"" );
        }

        this.client = new HttpClient();
        this.client.getParams().setAuthenticationPreemptive( true );
        initAuth();
        initProxy( baseuri );

        this.isDav = isWebDavCapableServer();
    }