in commons-transfer/commons-transfer-http/src/main/java/org/apache/archiva/commons/transfer/http/HttpTransferUploader.java [215:263]
public void upload( File sourceFile, URI uri )
throws TransferException, IOException
{
assertURI( uri );
URI absoluteURI = baseuri.resolve( uri );
if ( !isDav )
{
throw new TransferException( "Can't upload (not WebDav capable): " + absoluteURI.toASCIIString() );
}
// Try to put file first.
int status = putFile( sourceFile, absoluteURI );
if ( isSuccessfulPUT( status ) )
{
// Expected path.
return;
}
// Problem. Check that the collections exist.
if ( status == HttpStatus.SC_CONFLICT )
{
URI parentURI = absoluteURI.resolve( "./" ).normalize();
Stack<URI> missingPaths = davGetMissingPaths( parentURI );
if ( missingPaths.empty() )
{
throw new TransferException( "Unable to upload (Conflict, collections exist) file "
+ sourceFile.getAbsolutePath() + " to " + absoluteURI.toASCIIString() );
}
while ( !missingPaths.empty() )
{
URI missingPath = missingPaths.pop();
davCreateCollection( missingPath );
}
status = putFile( sourceFile, absoluteURI );
if ( isSuccessfulPUT( status ) )
{
// Expected Good result.
return;
}
}
throw new TransferException( "Unable to upload (" + status + "/" + HttpStatus.getStatusText( status )
+ ") file " + sourceFile.getAbsolutePath() + " to " + absoluteURI.toASCIIString() );
}