Programmatic access to change tracking
Posted: Wed Jul 29, 2009 5:55 pm
Hi, me again,
I have a problem concerning change tracking and failed XML inserts.
A requirement is that we turn change tracking on for all documents edited in our framework. I use an ExtensionBundle and the createAuthorExtensionStateListener() to provide a listener that flips change tracking to on whenever the activated() callback method is invoked, and flip it back off again in the deactivated() method. This works great; however the fact change tracking is on causes some problems in some of the framework's Operations.
I have an Operation that expands the currently selected text into an XML element. The selected text is then deleted and the XML fragment inserted where the text used to be. Incidentaly I can't use the surroundInFragment() method as I need to control where in the XML fragment the selected text occurs. This is fine unless the XML fragement is invalid (I have relativley little control over the exact XML used as it comes from a 3rd party tool). When it is invalid I get an AuthorOperationException thrown, which I catch and then roll back the insert. I do this by re-inserting the orignal text. This would be fine if it weren't for the change tracking which flags this failure case as 2 changes, one being the original text as deleted, and the second being that same text re-inserted. Ideally in the case of a failure I would like no chnages recorded. To my mind this means getting access to the change tracking framework and removing the last two changes, or supressing change tracking during the opertaion and applying all chnages if and only if the insert succeeds.
Have you any suggestions about how I might address this problem?
Simon.
I have a problem concerning change tracking and failed XML inserts.
A requirement is that we turn change tracking on for all documents edited in our framework. I use an ExtensionBundle and the createAuthorExtensionStateListener() to provide a listener that flips change tracking to on whenever the activated() callback method is invoked, and flip it back off again in the deactivated() method. This works great; however the fact change tracking is on causes some problems in some of the framework's Operations.
I have an Operation that expands the currently selected text into an XML element. The selected text is then deleted and the XML fragment inserted where the text used to be. Incidentaly I can't use the surroundInFragment() method as I need to control where in the XML fragment the selected text occurs. This is fine unless the XML fragement is invalid (I have relativley little control over the exact XML used as it comes from a 3rd party tool). When it is invalid I get an AuthorOperationException thrown, which I catch and then roll back the insert. I do this by re-inserting the orignal text. This would be fine if it weren't for the change tracking which flags this failure case as 2 changes, one being the original text as deleted, and the second being that same text re-inserted. Ideally in the case of a failure I would like no chnages recorded. To my mind this means getting access to the change tracking framework and removing the last two changes, or supressing change tracking during the opertaion and applying all chnages if and only if the insert succeeds.
Have you any suggestions about how I might address this problem?
Simon.