Resource existing = wrapped.child(newName);
if( existing != null ) {
if( existing instanceof ReplaceableResource ) {
log.trace("existing resource is replaceable, so replace content");
ReplaceableResource rr = (ReplaceableResource) existing;
rr.replaceContent(in, null);
} else {
log.trace("existing resource is not replaceable, will be deleted");
if( existing instanceof DeletableResource ) {
DeletableResource dr = (DeletableResource) existing;
dr.delete();