Class FormArchiveUtils


  • public class FormArchiveUtils
    extends Object
    Provides a service to create a Form Archive POJO from the given FAR byte array.
    • Field Detail

      • SFM_CONFIG_CONTACT_EMAIL_ELEMENT

        public static final String SFM_CONFIG_CONTACT_EMAIL_ELEMENT
        The Form Archive 'META-INF/sfmconfig.xml' contactEmailXPath element
        See Also:
        Constant Field Values
      • SFM_CONFIG_CONTACT_PHONE_ELEMENT

        public static final String SFM_CONFIG_CONTACT_PHONE_ELEMENT
        The Form Archive 'META-INF/sfmconfig.xml' contactPhoneXPath element
        See Also:
        Constant Field Values
      • SFM_CONFIG_SAVE_CHALLENGE_ELEMENT

        public static final String SFM_CONFIG_SAVE_CHALLENGE_ELEMENT
        The Form Archive 'META-INF/sfmconfig.xml' saveChallengeXPath element
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_XPATH

        public static final String SFM_CONFIG_DATA_EXTRACT_XPATH
        The Form Archive 'META-INF/sfmconfig.xml' the data extract repeat element xPath
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_PUBLISH

        public static final String SFM_CONFIG_DATA_EXTRACT_PUBLISH
        The Form Archive 'META-INF/sfmconfig.xml' the data extract publish attribute
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_REPEAT

        public static final String SFM_CONFIG_DATA_EXTRACT_REPEAT
        The Form Archive 'META-INF/sfmconfig.xml' the data extract repeat attribute
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_SEARCHABLE

        public static final String SFM_CONFIG_DATA_EXTRACT_SEARCHABLE
        The Form Archive 'META-INF/sfmconfig.xml' the data extract searchable attribute This attribute is no longer supported in TM as of 18.11.0
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_SUBSCRIBE

        public static final String SFM_CONFIG_DATA_EXTRACT_SUBSCRIBE
        The Form Archive 'META-INF/sfmconfig.xml' the data extract subscribe attribute
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_NAME

        public static final String SFM_CONFIG_DATA_EXTRACT_NAME
        The Form Archive 'META-INF/sfmconfig.xml' the data extract name attribute
        See Also:
        Constant Field Values
      • SFM_CONFIG_DATA_EXTRACT_VALUE

        public static final String SFM_CONFIG_DATA_EXTRACT_VALUE
        The Form Archive 'META-INF/sfmconfig.xml' the data extract value attribute
        See Also:
        Constant Field Values
      • FAR_FORMSEED_PATH

        public static final String FAR_FORMSEED_PATH
        The Form Archive 'META-INF/formseed.xml' file path.
        See Also:
        Constant Field Values
      • FAR_SFMCONFIG_PATH

        public static final String FAR_SFMCONFIG_PATH
        The Form Archive 'META-INF/sfmconfig.xml' file path.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FormArchiveUtils

        public FormArchiveUtils()
    • Method Detail

      • createFormArchive

        public static FormArchive createFormArchive​(byte[] formArchiveData,
                                                    String farFileName)
                                             throws FormArchiveValidationException,
                                                    IOException
        Create a FormArchive from the given ZIP byte array.
        Parameters:
        formArchiveData - the FAR file byte array
        farFileName - the name of the FAR file (optional outside of the FAR file import context)
        Returns:
        a FormArchive object
        Throws:
        FormArchiveValidationException - the form archive validation exception
        IOException - if an I/O exception has occurred
      • getFormArchivesFromPackage

        public static Map<String,​FormArchive> getFormArchivesFromPackage​(byte[] packageData)
                                                                        throws FormArchiveValidationException,
                                                                               IOException
        Get map of form archives (keyed on archive name) from Composer Package data (ZIP).
        Parameters:
        packageData - the composer package data
        Returns:
        map of form archives (keyed on archive name) from Composer Package data (ZIP)
        Throws:
        FormArchiveValidationException - the form archive validation exception
        IOException - if an I/O exception has occurred
      • validateFormArchive

        public static String validateFormArchive​(byte[] formArchiveData)
        Validate the given form archive byte array content and return null if valid, or the validation error otherwise.
        Parameters:
        formArchiveData - the form archive to validate
        Returns:
        the validation error, or null if valid
      • getFormArchiveByFarKey

        public static FormArchive getFormArchiveByFarKey​(Map<String,​FormArchive> formArchives,
                                                         String farFormKey)
        Retrieve the form archive with the specified key
        Parameters:
        formArchives - the map of form archives
        farFormKey - the FAR form key to look for
        Returns:
        the matching form archive, or null if none was found
      • getFormArchiveBytes

        public static byte[] getFormArchiveBytes​(byte[] packageData,
                                                 String fileName)
                                          throws IOException
        Return a form archive with a given file name
        Parameters:
        packageData - the Composer package data containing the form archive
        fileName - the name of FAR file to retrieve
        Returns:
        a byte array representing the form archive
        Throws:
        IOException - if an error occurred traversing the Composer package