Christoph Hermann schrieb: Hello,
> i'm trying to integrate Cocoon and eXist XML DB. So far it works fine, i > can edit and save a document through cforms and the bindings, but this > is only working if i make the documents in my collection > world-writable/updatable. > > So my question is: where do i specify which user/password is used when > accessing the eXist database (i would like to do this in flow (if > possible) alternatively which configuration file handles this)? I now wrote a new saveDocumentAuth() function for this: > ---snip--- > var form = new Form("cforms/definition/test_def.xml"); > var bindingURI = "cforms/binding/test_bind.xml"; > form.createBinding(bindingURI); var docBaseURI = "xmldb:exist:///db/test/"; var docName = "test.xml"; var document = loadDocument(docBaseURI + docName); form.load(document); form.showForm("test-display-pipeline"); form.save(document); // saveDocument(document, docURI); saveDocumentAuth(document, "test.xml", docBaseURI, "user", "pass", "true"); and the function looks like this: ---snip--- function saveDocumentAuth(document, docname, dburi, user, password, overwrite) { // exist API http://exist.sourceforge.net/api/index.html // XMLUtils API http://cocoon.apache.org/2.1/apidocs/ importClass(Packages.org.xmldb.api.DatabaseManager); importClass(Packages.org.xmldb.api.base.Collection); importClass(Packages.org.xmldb.api.modules.XMLResource); importClass(Packages.org.apache.excalibur.xml.sax.SAXParser); // Error Messages var _errmsg = null; var _errdesc = null; // set the document xml data var xmldata = Packages.org.apache.cocoon.xml.XMLUtils.serializeNodeToXML(document); // Collection (org.xmldb.api.base.Collection) var collection = null; // ressource (org.xmldb.api.modules.XMLResource) var _resource = null; try { collection = DatabaseManager.getCollection(dburi, user, password); collection.setProperty("sax-document-events", "false"); try { _resource = collection.getResource(docname); if(_resource != null) { if(overwrite.equals("true")) { collection.removeResource(_resource); _resource = collection.createResource( docname, "XMLResource" ); _resource.setContent(xmldata); collection.storeResource(_resource); } else { _errmsg = "Resource " + docname + " does already exist"; _errdesc = "Resource " + docname + " does already exist"; cocoon.log.error(_errmsg); cocoon.log.error(_errdesc); } } else { _resource = collection.createResource( docname, "XMLResource" ); _resource.setContent(xmldata); collection.storeResource(_resource); } } catch(_ex) { // XMLDBException _errmsg = _ex.getMessage; _errdesc = "Failed to store document" + docname; cocoon.log.error(_errmsg); cocoon.log.error(_errdesc); } } catch(_e) { // XMLDBException _errmsg = _e.toString(); _errdesc = "Failed to get collection " + dburi; cocoon.log.error(_errmsg); cocoon.log.error(_errdesc); } } ---snap--- So if anyone is able to use this, or to find a better way of handling this, feel free to modify it to your needs. With kind regards, Christoph Hermann --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]