Docmosis API 4.5.0

com.docmosis.template.store
Class StoreHelper

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

public class StoreHelper
extends Object

This class provides methods to register templates into the template store. The Template Store should be thought of as a cache of templates. Your original templates are analysed and optimised when you register them into the template store. It is these optimised versions of your templates that are then used for document production. Some methods in the DocumentProcessor class rely on the templates having been previously registered, and other methods will register templates automatically.


Constructor Summary
StoreHelper()
           
 
Method Summary
static TemplateDetails storeTemplate(String templateName, File templateFile, boolean overwrite, TemplateStore store)
          Store a template in the given template store (this process is known as template registration) specifying whether to overwrite any existing registrations or not.
static TemplateDetails storeTemplate(String templateName, File templateFile, TemplateStore store)
          Store a template in the given template store.
static TemplateDetails storeTemplate(TemplateIdentifier templateId, File templateFile, boolean overwrite, boolean waitForConverter, TemplateStore store)
          Store a template in the given template store (this process is known as template registration).
static TemplateDetails storeTemplate(TemplateIdentifier templateId, File templateFile, TemplateStore store)
          Store a template in the given template store (this process is known as template registration).
static TemplateDetails storeTemplate(TemplateIdentifier templateId, InputStream origTemplateStream, boolean overwrite, boolean waitForConverter, TemplateStore store)
          Store the given template stream against the given templateId in the given store.
static boolean templateExists(TemplateIdentifier templateId, TemplateStore store)
          Determines whether the given template exists in the store.
static TemplateValidationResult validateTemplate(InputStream templateStream)
          Process the given stream as a template and return a TemplateValidationResult.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoreHelper

public StoreHelper()
Method Detail

storeTemplate

public static TemplateDetails storeTemplate(String templateName,
                                            File templateFile,
                                            TemplateStore store)
                                     throws IOException,
                                            ConversionException,
                                            TemplateStoreException,
                                            NoConvertersRunningException
Store a template in the given template store. This process is known as template registration. The given file is registered with the given templateName into the root of the template store. This method will wait for a converter to come online to assist with analysing the template. This method automatically overwrites any existing template registration. The template stored can be retrieved from the TemplateStore by creating a TemplateIdentifier matching the given templateName. For example:
   // register a template
   StoreHelper.storeTemplate("account", accountTemplateFile, TemplateStoreFactory.getStore());
   .... 
   // later, refer to the template for rendering
   TemplateIdentifier tid = new TemplateIdentifier("account");
   DocumentProcessor.renderDoc(tid, ...);
   
 

Parameters:
templateName - the name of the template that will reside in the store.
templateFile - the template to store
store - the store to use.
Returns:
the details of the template just stored.
Throws:
IOException - if an IO problem occurs
ConversionException - if the template is not valid
TemplateStoreException - if there is a problem with the template store
NoConvertersRunningException - if a converter cannot be obtained to support the analysis of the template.

storeTemplate

public static TemplateDetails storeTemplate(String templateName,
                                            File templateFile,
                                            boolean overwrite,
                                            TemplateStore store)
                                     throws IOException,
                                            ConversionException,
                                            TemplateStoreException,
                                            NoConvertersRunningException
Store a template in the given template store (this process is known as template registration) specifying whether to overwrite any existing registrations or not. The given file is registered with the given templateName into the root of the template store. This method will wait for a converter to come online to assist with analysing the template.

Parameters:
templateName - the name of the template that will reside in the store.
templateFile - the template to store.
overwrite - true to overwrite existing objects in the store; false to not overwrite.
store - the store to use.
Returns:
the details of the template just stored.
Throws:
IOException - if an IO problem occurs
ConversionException - if the template is not valid
TemplateStoreException - if there is a problem with the template store
NoConvertersRunningException - if a converter cannot be obtained to support the analysis of the template.

storeTemplate

public static TemplateDetails storeTemplate(TemplateIdentifier templateId,
                                            File templateFile,
                                            TemplateStore store)
                                     throws IOException,
                                            ConversionException,
                                            TemplateStoreException,
                                            NoConvertersRunningException
Store a template in the given template store (this process is known as template registration). The given file is registered with the given templateIdentifier into the template store. This method will automatically overwrite any existing registrations. This method will wait for a converter to come online to assist with analysing the template.

Parameters:
templateId - the identifier for the template
templateFile - the template to store.
store - the store to use.
Returns:
the details of the template just stored.
Throws:
IOException - if an IO problem occurs
ConversionException - if the template is not valid
TemplateStoreException - if there is a problem with the template store
NoConvertersRunningException - if a converter cannot be obtained to support the analysis of the template.

storeTemplate

public static TemplateDetails storeTemplate(TemplateIdentifier templateId,
                                            InputStream origTemplateStream,
                                            boolean overwrite,
                                            boolean waitForConverter,
                                            TemplateStore store)
                                     throws IOException,
                                            ConversionException,
                                            TemplateStoreException,
                                            NoConvertersRunningException
Store the given template stream against the given templateId in the given store.

Parameters:
templateId - the identifier for the template (name and or path) to use for the stored template
origTemplateStream - an InputStream over the template
overwrite - true to overwrite existing objects in the store; false to not overwrite (an exception will be thrown if attempted).
waitForConverter - true will force this method to wait for a converter to become available if there are none; false will force this method to throw an exception if there are no converters.
store - the template store to use
Returns:
the details of the template just stored
Throws:
IOException - if an IO problem occurs
ConversionException - if the template is not valid
TemplateStoreException - if there is a problem with the template store
NoConvertersRunningException - if there are no converters running and the waitForConverter parameter has been set to false.

storeTemplate

public static TemplateDetails storeTemplate(TemplateIdentifier templateId,
                                            File templateFile,
                                            boolean overwrite,
                                            boolean waitForConverter,
                                            TemplateStore store)
                                     throws IOException,
                                            ConversionException,
                                            TemplateStoreException,
                                            NoConvertersRunningException
Store a template in the given template store (this process is known as template registration). The given file is registered with the given templateName into the root of the template store. This method will automatically overwrite any existing registrations. This method will wait for a converter to come online to assist with analysing the template.

Parameters:
templateId - the identifier for the template
templateFile - the template to store.
overwrite - true to overwrite existing objects in the store; false to not overwrite.
waitForConverter - true will force this method to wait for a converter to become available if there are none; false will force this method to throw an exception if there are no converters.
store - the store to use.
Returns:
the details of the template just stored.
Throws:
IOException - if an IO problem occurs
ConversionException - if the template is not valid
TemplateStoreException - if there is a problem with the template store
NoConvertersRunningException - if there are no converters running and the waitForConverter parameter has been set to false.

templateExists

public static boolean templateExists(TemplateIdentifier templateId,
                                     TemplateStore store)
                              throws IOException,
                                     TemplateStoreException
Determines whether the given template exists in the store.

Parameters:
templateId - the identifier of the template to look for.
store - the store to look inside.
Returns:
true if the template exists in the store; false otherwise.
Throws:
IOException - if an IO problem occurs
TemplateStoreException - if there is a problem with the template store

validateTemplate

public static TemplateValidationResult validateTemplate(InputStream templateStream)
                                                 throws TemplateStoreException
Process the given stream as a template and return a TemplateValidationResult. The result will indicate if there are any errors, and if so, details about the error message and any suggested remedies are embodied in the result.

Parameters:
templateStream - a stream for the template to validate
Throws:
TemplateStoreException - if a problem occurs trying to validate
See Also:
TemplateValidationResult

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.