destinationDirectory += "/";
}
String url = getRepository().getUrl() + "/" + destinationDirectory;
HttpGet getMethod = new HttpGet( url );
try
{
HttpResponse response = execute( getMethod );
int statusCode = response.getStatusLine().getStatusCode();
fireTransferDebug( url + " - Status code: " + statusCode );
// TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is required
switch ( statusCode )
{
case HttpStatus.SC_OK:
break;
case SC_NULL:
throw new TransferFailedException( "Failed to transfer file: " );
case HttpStatus.SC_FORBIDDEN:
throw new AuthorizationException( "Access denied to: " + url );
case HttpStatus.SC_UNAUTHORIZED:
throw new AuthorizationException( "Not authorized." );
case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
throw new AuthorizationException( "Not authorized by proxy." );
case HttpStatus.SC_NOT_FOUND:
throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
//add more entries here
default:
throw new TransferFailedException(
"Failed to transfer file: " + url + ". Return code is: " + statusCode );
}
InputStream is = response.getEntity().getContent();
return HtmlFileListParser.parseFileList( url, is );
}
catch ( IOException e )
{
throw new TransferFailedException( "Could not read response body.", e );
}
catch ( HttpException e )
{
throw new TransferFailedException( "Could not read response body.", e );
}
finally
{
getMethod.abort();
}
}