Docmosis API 3.0.1

com.docmosis.template.store
Class DropStoreHelper

java.lang.Object
  extended bycom.docmosis.template.store.DropStoreHelper

public class DropStoreHelper
extends Object

This class makes it easier to pick up documents in a directory and register them into the (configured) store. Only templates that have changed or are new will be uploaded into the store, replacing any previously registered counterparts. Any errors that occur will result in the template causing the error to not be stored, and a log error message. Templates not causing any errors will still be processed. The templates are located in the store under a context that is based on the path that the original template resides in. Several methods throw NoConvertersRunningException if there are no converters online at the time of the render. If all converters are busy, these methods will still wait up to the configured max wait. This exception is only thrown if there are no operating converters in the pool.


Constructor Summary
DropStoreHelper(TemplateStore store)
          Create a new DropStoreHelper object.
 
Method Summary
 void process(File dropDirectory)
          Drop a whole directory of templates into the store processing sub-directories.
 void process(File dropDirectory, boolean isRecursive)
          Drop a whole directory of templates into the store optionally processing sub-directories.
 void process(File dropDirectory, boolean isRecursive, boolean deleteUnknownTemplates)
          Deprecated. Deletion of unknown templates is no longer supported. The deletion flag is ignored.
 void process(File dropDirectory, TemplateContext storeContext)
          Drop a whole directory of templates into the store optionally processing sub-directories.
 void process(File dropDirectory, TemplateContext storeContext, boolean isRecursive)
          Drop a whole directory of templates into the store optionally processing sub-directories.
 void process(File dropDirectory, TemplateContext storeContext, boolean isRecursive, boolean deleteUnknownTemplates)
          Deprecated. Deletion of unknown templates is no longer supported. The deletion flag is ignored.
 void processJarOrZipFile(File file, TemplateContext storeContext, boolean logErrors)
          Process the contents of a Jar or Zip file as it if was a directory.
 void processResource(URL url, TemplateContext baseContext, boolean logErrors)
          Process templates from the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DropStoreHelper

public DropStoreHelper(TemplateStore store)
Create a new DropStoreHelper object.

Parameters:
store - the store to use.
Method Detail

process

public void process(File dropDirectory)
             throws IOException,
                    ConversionException,
                    ConverterPoolException,
                    TemplateStoreException,
                    NoConvertersRunningException
Drop a whole directory of templates into the store processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
Throws:
ConversionException - if a template cannot be processed
ConverterPoolException - if the converter pool is not working
TemplateStoreException - if the underlying template store has an error
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

process

public void process(File dropDirectory,
                    TemplateContext storeContext)
             throws TemplateStoreException,
                    IOException,
                    NoConvertersRunningException
Drop a whole directory of templates into the store optionally processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
storeContext - the context within the store to use.
Throws:
TemplateStoreException - if the underlying template store has an error
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

process

public void process(File dropDirectory,
                    TemplateContext storeContext,
                    boolean isRecursive)
             throws TemplateStoreException,
                    IOException,
                    NoConvertersRunningException
Drop a whole directory of templates into the store optionally processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
storeContext - the context within the store to use.
isRecursive - true to recursively drop sub-directories; false to only process the given directory.
Throws:
TemplateStoreException - if the underlying template store has an error
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

process

public void process(File dropDirectory,
                    boolean isRecursive)
             throws TemplateStoreException,
                    IOException,
                    NoConvertersRunningException
Drop a whole directory of templates into the store optionally processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
isRecursive - true to recursively drop sub-directories; false to only process the given directory.
Throws:
TemplateStoreException - if the underlying template store has an error
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

process

public void process(File dropDirectory,
                    boolean isRecursive,
                    boolean deleteUnknownTemplates)
             throws TemplateStoreException,
                    IOException,
                    NoConvertersRunningException
Deprecated. Deletion of unknown templates is no longer supported. The deletion flag is ignored.

Drop a whole directory of templates into the store optionally processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
isRecursive - true to recursively drop sub-directories; false to only process the given directory.
deleteUnknownTemplates - true to delete templates that are in the store but not in the source ; false to leave them alone.
Throws:
TemplateStoreException - if the underlying template store has an error
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

process

public void process(File dropDirectory,
                    TemplateContext storeContext,
                    boolean isRecursive,
                    boolean deleteUnknownTemplates)
             throws TemplateStoreException,
                    IOException,
                    NoConvertersRunningException
Deprecated. Deletion of unknown templates is no longer supported. The deletion flag is ignored.

Drop a whole directory of templates into the store, optionally processing sub-directories.

Parameters:
dropDirectory - the directory to pick up documents from.
storeContext - the context within the store to use.
isRecursive - true to recursively drop sub-directories; false to only process the given directory.
deleteUnknownTemplates - true to delete templates that are in the store but not in the source ; false to leave them alone.
Throws:
TemplateStoreException - if the underlying template store has an error or the given dropDirectory is not valid
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running

processJarOrZipFile

public void processJarOrZipFile(File file,
                                TemplateContext storeContext,
                                boolean logErrors)
                         throws NoConvertersRunningException,
                                IOException,
                                ConversionException,
                                ConverterPoolException,
                                TemplateStoreException
Process the contents of a Jar or Zip file as it if was a directory. Any templates in the root of the Jar file will be dropped into the given context. All templates in sub-directories within the Jar file will be dropped into a matching sub-context so that the templates will be stored in a structure that matches the directory structure within the Jar or Zip file.

Parameters:
file - the file to process
storeContext - the context under which the templates are stored
logErrors - if true, errors are logged but not thrown so that as much processing as possible is done.
Throws:
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running
ConversionException - if a template cannot be processed
ConverterPoolException - if the converter pool is not working
TemplateStoreException - if the underlying template store has an error

processResource

public void processResource(URL url,
                            TemplateContext baseContext,
                            boolean logErrors)
                     throws IOException,
                            TemplateStoreException,
                            NoConvertersRunningException,
                            ConversionException
Process templates from the specified URL. This method is provided to allow templates to be loaded from Resources obtained from the classloader. It will process all templates found under the given resource location, including those in sub-folders and zip/jar archives. For example:
	URL myTemplates = getClass().getClassLoader().getResource("my/company/project/templates");
	new DropStoreHelper(mystore).processResource(myTemplates, null);
 

Parameters:
url - the URL to the
baseContext - an optional context under which to store these templates. null means store the templates starting in the root of the store.
logErrors - if true errors will be logged and processing will do its best effort to process all templates found. If false, an exception will be thrown on first problem encountered.
Throws:
TemplateStoreException - if there is a problem storing the template
IOException - if an IO error occurs
NoConvertersRunningException - if there are no converters running
ConversionException - if the template cannot be analyzed and stored

Docmosis API 3.0.1

Copyright © 2011 Docmosis. All Rights Reserved.