return list;
}
public OutputStream createOutputStream( long offset ) throws IOException {
log.debug( "createOutputStream: " + offset );
final BufferingOutputStream out = new BufferingOutputStream( 50000 );
if( r instanceof ReplaceableResource ) {
log.debug( "resource is replaceable" );
final ReplaceableResource rr = (ReplaceableResource) r;
Runnable runnable = new Runnable() {
public void run() {
try {
rr.replaceContent(out.getInputStream(), out.getSize());
} catch (BadRequestException ex) {
throw new RuntimeException(ex);
} catch (ConflictException ex) {
throw new RuntimeException(ex);
} catch (NotAuthorizedException ex) {
throw new RuntimeException(ex);
}
}
};
out.setOnClose( runnable );
return out;
} else {
CollectionResource col;
col = getParent();
if( col == null ) {
throw new IOException( "parent not found" );
} else if( col instanceof PutableResource ) {
final PutableResource putableResource = (PutableResource) col;
final String newName = path.getName();
Runnable runnable = new Runnable() {
public void run() {
try {
putableResource.createNew( newName, out.getInputStream(), out.getSize(), null );
} catch( BadRequestException ex ) {
throw new RuntimeException( ex );
} catch( NotAuthorizedException ex ) {
throw new RuntimeException( ex );
} catch( ConflictException ex ) {
throw new RuntimeException( ex );
} catch( IOException ex ) {
throw new RuntimeException( ex );
}
}
};
out.setOnClose( runnable );
return out;
} else {
throw new IOException( "folder doesnt support PUT, and the resource is not replaceable" );
}
}