Document Pre/Post Processing

From LogicalDOC Community Wiki
Jump to navigationJump to search

Some analisys sessions in various organizations where LogicalDOC was adopted, reported that it would be useful to add some kind of logic during the document storage procedure.
For example a common need is to have a customizable numeration of inserted documents. The idea is to define a new extension point in the core plug-in that can be extended by custom plug-ins in order to provide specific logic before and after a document is saved into the database.

Basically if a client wants to interact with the store procedure it must implement an interface like this:

public interface DocumentListener {
	/**
	 * Called before a document is stored in the database
	 * 
	 * @param document The document to be stored
	 * @param dictionary Dictionary of the execution pipeline
	 */
	public void beforeStore(Document document, Map<String, Object> dictionary);

	/**
	 * Called after a document is stored in the database
	 * 
	 * @param document The document to be stored
	 * @param dictionary Dictionary of the execution pipeline
	 */
	public void afterStore(Document document, Map<String, Object> dictionary);
}


Each time a document is stored, all enlisted listeners are notified and each listener can do a particular job. A convenient dictionary map can be passed through the execution chain so that one listener can share informations with others. The extension point must define the implementation class and a position so that this can be used to choose the right notification order.