Document Pre/Post Processing

From LogicalDOC Community Wiki

Jump to: navigation, 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:

  1. public interface DocumentListener {
  2. 	/**
  3. 	 * Called before a document is stored in the database
  4. 	 * 
  5. 	 * @param document The document to be stored
  6. 	 * @param dictionary Dictionary of the execution pipeline
  7. 	 */
  8. 	public void beforeStore(Document document, Map<String, Object> dictionary);
  9.  
  10. 	/**
  11. 	 * Called after a document is stored in the database
  12. 	 * 
  13. 	 * @param document The document to be stored
  14. 	 * @param dictionary Dictionary of the execution pipeline
  15. 	 */
  16. 	public void afterStore(Document document, Map<String, Object> dictionary);
  17. }


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.