From: Alister P. <gsp...@gm...> - 2015-04-11 05:42:42
|
So now that I have the trigger working, I can see the real error. (Line: 129 /db/apps/pekoe/templates/template-trigger.xqm) BEFORE MOVE DOCUMENT /db/pekoe/tenants/bkfa/templates/test-member.odt (Line: 129 /db/apps/pekoe/templates/template-trigger.xqm) PEKOE AFTER MOVE DOCUMENT /db/pekoe/tenants/bkfa/templates/test-member.odt The after-move-document receives the OLD uri - not the new. See the “execute” calls below… It should probably receive both (as per the documentation). (from XQueryTrigger.java 746) @Override public void beforeMoveDocument(DBBroker broker, Txn txn, DocumentImpl document, XmldbURI newUri) throws TriggerException { if (events.contains(TriggerEvents.EVENTS.MOVE_DOCUMENT)) { prepare(6, broker, txn, document.getURI(), newUri, false); } else { execute(true, broker, txn, beforeMoveDocument, document.getURI()); } } @Override public void afterMoveDocument(DBBroker broker, Txn txn, DocumentImpl document, XmldbURI oldUri) throws TriggerException { if (events.contains(TriggerEvents.EVENTS.MOVE_DOCUMENT)) { finish(6, broker, txn, oldUri, document.getURI(), false); } else { execute(false, broker, txn, afterMoveDocument, oldUri); } } Also, the documented order of params for after-copy-collection is wrong - it should be the same as before-copy-collection: declare function trigger:before-copy-collection($uri as xs:anyURI, $new-uri as xs:anyURI) declare function trigger:after-copy-collection($new-uri as xs:anyURI, $uri as xs:anyURI) WRONG ORDER The code shows the order for both is the same (in the ‘execute’ calls…) @Override public void beforeCopyCollection(DBBroker broker, Txn txn, Collection collection, XmldbURI newUri) throws TriggerException { if (events.contains(TriggerEvents.EVENTS.COPY_COLLECTION)) { prepare(5, broker, txn, collection.getURI(), newUri, true); } else { execute(true, broker, txn, beforeCopyCollection, collection.getURI(), newUri); } } @Override public void afterCopyCollection(DBBroker broker, Txn txn, Collection collection, XmldbURI newUri) throws TriggerException { if (events.contains(TriggerEvents.EVENTS.COPY_COLLECTION)) { finish(5, broker, txn, collection.getURI(), newUri, true); } else { execute(false, broker, txn, afterCopyCollection, collection.getURI(), newUri); } } I will create an issue for this. |