final String uri = this.getURI( keyMap, map , "save");
final String profileName = (String)map.get("profile");
// 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(), profileName, profile);
return;
}
} finally {
resolver.release(source);
manager.release(converter);
manager.release(resolver);
source = null;
converter = null;
resolver = null;
}
final StringBuffer buffer = this.getCompleteURI(uri, keyMap, map );
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, profileName, profile);
buffer.append("&content=");
buffer.append(SourceUtil.encode(writer.toString()));
source = resolver.resolveURI(buffer.toString());