in flow/src/java/org/apache/struts/flow/core/source/SourceUtil.java [452:526]
static public void copy(Source source,
Source destination)
throws SourceException
{
if (source instanceof MoveableSource
&& source.getClass().equals(destination.getClass()))
{
((MoveableSource) source).copyTo(destination);
}
else
{
if ( !(destination instanceof ModifiableSource)) {
throw new SourceException("Source '"+
destination.getURI()+
"' is not writeable");
}
IOException firstE = null;
ModifiableSource modDestination = (ModifiableSource)destination;
try
{
InputStream in = source.getInputStream();
try
{
OutputStream out = modDestination.getOutputStream();
try
{
try
{
copy(in, out);
}
catch ( IOException e )
{
// Remebver the original exception in case there are problems closing
// any streams.
firstE = e;
// If possible, cancel the destination.
if ( modDestination.canCancel( out ) )
{
modDestination.cancel( out );
out = null;
}
}
}
finally
{
// out may have already been closed if there was a problem.
if ( out != null )
{
out.close();
}
}
}
finally
{
in.close();
}
} catch (IOException ioe) {
if ( firstE == null )
{
firstE = ioe;
}
}
// If there were any problems then wrap the original exception in a SourceException.
if ( firstE != null )
{
throw new SourceException("Could not copy source '"+
source.getURI()+"' to '"+
destination.getURI()+"' :"+
firstE.getMessage(), firstE);
}
}
}