public boolean davCollectionExists()

in commons-transfer/commons-transfer-http/src/main/java/org/apache/archiva/commons/transfer/http/HttpTransferUploader.java [63:107]


    public boolean davCollectionExists( URI uri )
        throws TransferException
    {
        PropFindMethod method = new PropFindMethod( uri );
        try
        {
            method.setDepth( 1 );
            int status = client.executeMethod( method );
            if ( ( status == HttpStatus.SC_MULTI_STATUS ) || ( status == HttpStatus.SC_OK ) )
            {
                MultiStatus multistatus = method.getMultiStatus();
                if ( multistatus == null )
                {
                    return false;
                }

                DavResource resource = multistatus.getResource( uri.getPath() );
                if ( resource == null )
                {
                    return false;
                }

                return resource.isCollection();
            }

            if ( status == HttpStatus.SC_BAD_REQUEST )
            {
                throw new TransferException( "Bad HTTP Request (400) during PROPFIND on \"" + uri.toASCIIString()
                    + "\"" );
            }
        }
        catch ( HttpException e )
        {
            LOG.info( "Can't determine if collection exists: " + uri, e );
        }
        catch ( IOException e )
        {
            LOG.info( "Can't determine if collection exists: " + uri, e );
        }
        finally
        {
            method.releaseConnection();
        }
        return false;
    }