final String uri = this.getURI( keyMap, parameters );
// first test: modifiable source?
SourceResolver resolver = null;
CastorSourceConverter converter = null;
Source source = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
source = resolver.resolveURI(uri);
if ( source instanceof ModifiableSource ) {
converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
converter.storeObject( ((ModifiableSource)source).getOutputStream(), parameters, profile);
return;
}
} finally {
if ( resolver != null ) {
resolver.release(source);
}
manager.release(converter);
manager.release(resolver);
source = null;
converter = null;
resolver = null;
}
final StringBuffer buffer = this.getSaveURI( keyMap, parameters );
SAXParser parser = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
ByteArrayOutputStream writer = new ByteArrayOutputStream();
converter.storeObject(writer, parameters, profile);
buffer.append("&content=");
buffer.append(SourceUtil.encode(writer.toString()));
source = resolver.resolveURI(buffer.toString());