org.exist.collections.triggers
Class HistoryTrigger
java.lang.Object
org.exist.collections.triggers.FilteringTrigger
org.exist.collections.triggers.HistoryTrigger
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, DocumentTrigger, org.xml.sax.ext.LexicalHandler, Trigger
- public class HistoryTrigger
- extends FilteringTrigger
- implements DocumentTrigger
This collection trigger will save all old versions of documents before
they are overwritten or removed. The old versions are kept in the
'history root' which is by default '/db/history', but can be
changed with the parameter 'root'.
You need to configure this trigger for every collection whose history you
want to preserve, by modifying 'collection.xconf' such that it
resembles this:
<?xml version='1.0'?>
<collection xmlns='http://exist-db.org/collection-config/1.0'>
<triggers>
<trigger
event='update'
class='org.exist.collections.triggers.HistoryTrigger'
/>
<trigger
event='remove'
class='org.exist.collections.triggers.HistoryTrigger'
/>
</triggers>
</collection>
- Author:
- Mark Spanbroek
- See Also:
Trigger
|
Field Summary |
protected java.lang.String |
root
|
|
Method Summary |
void |
configure(DBBroker broker,
Collection parent,
java.util.Map parameters)
The configure method is called once whenever the collection configuration is loaded. |
void |
finish(int event,
DBBroker broker,
Txn transaction,
DocumentImpl document)
This method is called after the operation completed. |
void |
prepare(int event,
DBBroker broker,
Txn transaction,
java.lang.String documentName,
DocumentImpl existingDocument)
This method is called once before the database will actually parse the input data. |
| Methods inherited from class org.exist.collections.triggers.FilteringTrigger |
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, getCollection, getInputHandler, getLexicalInputHandler, getLexicalOutputHandler, getLogger, getOutputHandler, ignorableWhitespace, isValidating, processingInstruction, setDocumentLocator, setLexicalOutputHandler, setOutputHandler, setValidating, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.exist.collections.triggers.Trigger |
getLogger |
| Methods inherited from interface org.xml.sax.ContentHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping |
| Methods inherited from interface org.xml.sax.ext.LexicalHandler |
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity |
root
protected java.lang.String root
HistoryTrigger
public HistoryTrigger()
configure
public void configure(DBBroker broker,
Collection parent,
java.util.Map parameters)
throws CollectionConfigurationException
- Description copied from interface:
Trigger
- The configure method is called once whenever the collection configuration is loaded. Use it to
initialize the trigger, probably by looking at the parameters.
- Specified by:
configure in interface Trigger- Overrides:
configure in class FilteringTrigger
- Throws:
CollectionConfigurationException
prepare
public void prepare(int event,
DBBroker broker,
Txn transaction,
java.lang.String documentName,
DocumentImpl existingDocument)
throws TriggerException
- Description copied from interface:
DocumentTrigger
- This method is called once before the database will actually parse the input data. You may take any action
here, using the supplied broker instance.
- Specified by:
prepare in interface DocumentTrigger
- Parameters:
event - the type of event that triggered this call (see the constants defined in this interface).broker - the database instance used to process the current action.transaction - the current transaction contextdocumentName - the full absolute path of the document currently processed.existingDocument - optional: if event is a Trigger.UPDATE_DOCUMENT_EVENT,
existingDocument will contain the Document object for the old document, which will be overwritten. Otherwise, the parameter
is null.
- Throws:
TriggerException - throwing a TriggerException will abort the current action.
finish
public void finish(int event,
DBBroker broker,
Txn transaction,
DocumentImpl document)
- Description copied from interface:
DocumentTrigger
- This method is called after the operation completed. At this point, the document has already
been stored.
- Specified by:
finish in interface DocumentTrigger- Overrides:
finish in class FilteringTrigger
<oXygen/>
XML Editor
provides support for editing and debugging XQuery
expressions against the eXist XML Database.