Class ApplicationPackageArchiveService


public class ApplicationPackageArchiveService extends BaseArchiveService
Provides a application package archive export and import service.
Since:
4.3.0
  • Field Details

    • APPLICATION_PACKAGE_CONFIG_FILENAME

      public static final String APPLICATION_PACKAGE_CONFIG_FILENAME
      The client configuration file name
      See Also:
    • METADATA_CLIENT_CODE

      public static final String METADATA_CLIENT_CODE
      The name of the metadata value storing the client code of the client that will be imported to
      See Also:
    • METADATA_APPLICATION_PACKAGE_NAME

      public static final String METADATA_APPLICATION_PACKAGE_NAME
      The name of the metadata value storing the name of the application package that will be imported to
      See Also:
  • Constructor Details

    • ApplicationPackageArchiveService

      public ApplicationPackageArchiveService()
  • Method Details

    • setNewClientCode

      public void setNewClientCode(String newClientCode)
      Set the client code of the import target client.
      Parameters:
      newClientCode - the client code (optional; if not specified, the client in the archive will be used)
    • validateImportData

      public void validateImportData(byte[] importData) throws ImportValidationException, IOException
      Validate a application package archive before it is imported.
      Specified by:
      validateImportData in class BaseArchiveService
      Parameters:
      importData - the import archive as a byte array
      Throws:
      ImportValidationException - if the archive can be parsed, but does not contain the expected archive files
      IOException - if an error occurs loading the import archive contents
    • getImportMetadata

      public Map<String,String> getImportMetadata(byte[] importData) throws IOException, ImportValidationException
      Retrieve the set of metadata values describing an application package archive that is being imported.
      Specified by:
      getImportMetadata in class BaseArchiveService
      Parameters:
      importData - the import archive as a byte array
      Returns:
      a map of metadata names and their values
      Throws:
      IOException - if an error occurs while parsing the import archive
      ImportValidationException - if the XML file describing the application package was not found in the archive
    • getImportMetadata

      public Map<String,String> getImportMetadata(byte[] importData, String newClientCode) throws IOException, ImportValidationException
      Retrieve the set of metadata values describing an application package archive that is being imported.
      Parameters:
      importData - the import archive as a byte array
      newClientCode - the client to import to (optional)
      Returns:
      a map of metadata names and their values
      Throws:
      IOException - if an error occurs while parsing the import archive
      ImportValidationException - if the XML file describing the application package was not found in the archive
    • setExportCurrentVersionOnly

      public void setExportCurrentVersionOnly(boolean exportCurrentVersionOnly)
      Specify whether to export only the current version of forms included in the application package
      Parameters:
      exportCurrentVersionOnly - true if only the current form versions shall be included
    • getImportOptionEnum

      public IJMImportOption getImportOptionEnum()
      Return a value from the import option enum, if this service has import options. Can be used to call IJMImportOption.defaultForImportAction(String)
      Overrides:
      getImportOptionEnum in class BaseArchiveService
      Returns:
      one of the import options
    • writeExportData

      protected void writeExportData(Object object, ZipOutputStream zos, Map<String,String> additionalHeaders) throws IOException, ParserConfigurationException
      Description copied from class: BaseArchiveService
      Does the actual export of the data without having to worry about handling errors or preparing and closing the stream
      Specified by:
      writeExportData in class BaseArchiveService
      Parameters:
      object - the non-null object to be exported
      zos - the stream to be written to
      additionalHeaders - the map of additional headers to be included in metadata
      Throws:
      IOException
      ParserConfigurationException
    • postExport

      protected void postExport(Object exportObject)
      Description copied from class: BaseArchiveService
      Called after the export has been done, and the file created. Can be used to do service-specific activities such as logging.
      Overrides:
      postExport in class BaseArchiveService
      Parameters:
      exportObject - the object that was passed to exportData
    • processImportFile

      protected void processImportFile(String fileName, byte[] fileData) throws UnsupportedEncodingException
      Description copied from class: BaseArchiveService
      For a given file in the imported archive, the service stores its contents as it sees fit, preserving what it will need to recreate entities later. This operation happens before the database transaction wrapping the actual import to the SFM database.
      Specified by:
      processImportFile in class BaseArchiveService
      Parameters:
      fileName - the full file name of the ZIP file entry (e.g. form/TestForm.pdf)
      fileData - the file data of the ZIP file entry
      Throws:
      UnsupportedEncodingException
    • performImport

      protected void performImport(ImportAction importAction, Set<? extends Enum> importOptions, Map<String,Object> parameters) throws ParseException
      Description copied from class: BaseArchiveService
      Performs the act of importing the data contained in the archive to the SFM database. When this method will be called, the caller is expected to have established a transaction, and will also handle errors thrown by this method.
      Specified by:
      performImport in class BaseArchiveService
      Parameters:
      importAction - the import action related to this import
      importOptions - the set of import options that should be applied
      parameters - optional parameters to be used during import
      Throws:
      ParseException
    • getEntityName

      protected String getEntityName()
      Description copied from class: BaseArchiveService
      Return the name identifying the individual entity being exported (e.g. for a client, the client's name)
      Specified by:
      getEntityName in class BaseArchiveService
      Returns:
      the entity name
    • getFormData

      protected BaseArchiveService.FormData getFormData(Element formElement, Form form, TemplateVersion version)
      Overrides:
      getFormData in class BaseArchiveService
    • exportAuditLogger

      protected void exportAuditLogger(Object object)
      Create an entry in the audit log when an export is performed
      Specified by:
      exportAuditLogger in class BaseArchiveService
      Parameters:
      object - Object of type ApplicationPackage that was exported (Optional)
      Since:
      17.10.2
    • importAuditLogger

      protected void importAuditLogger(ImportAction importAction)
      Create an entry in the audit log when an import is performed
      Specified by:
      importAuditLogger in class BaseArchiveService
      Parameters:
      importAction - ImportAction containing action performed (required)
      object - ImportAction containing action performed (required)
      Since:
      17.10.2