Class ServiceConnectionArchiveService


  • public class ServiceConnectionArchiveService
    extends BaseArchiveService
    Provides a service connection archive export and import service.
    Since:
    5.0.0
    • Field Detail

      • CONNECTION_CONFIG_FILENAME

        public static final String CONNECTION_CONFIG_FILENAME
        The service connection configuration file name
        See Also:
        Constant Field Values
      • METADATA_CONNECTION_NAME

        public static final String METADATA_CONNECTION_NAME
        The name of the metadata value storing the name of the service connection to be imported
        See Also:
        Constant Field Values
      • METADATA_CLIENT_CODE

        public static final String METADATA_CLIENT_CODE
        The name of the metadata value storing the organization for which services were exported (if applicable)
        See Also:
        Constant Field Values
    • Constructor Detail

      • ServiceConnectionArchiveService

        public ServiceConnectionArchiveService()
    • Method Detail

      • getImportMetadata

        public Map<String,​String> getImportMetadata​(byte[] importData)
                                                   throws Exception
        Return metadata information about a given import archive.
        Specified by:
        getImportMetadata in class BaseArchiveService
        Parameters:
        importData - the archive byte data (required)
        Returns:
        a map containing metadata describing the contents of the import archive and predicted outcome of the import
        Throws:
        Exception - if an error occurs
      • getImportMetadata

        public Map<String,​String> getImportMetadata​(byte[] importData,
                                                          String newClientCode)
                                                   throws Exception
        Return metadata information about a given import archive.
        Parameters:
        importData - the archive byte data (required)
        newClientCode - the code of the client to be imported to (optional; if not set, the client specified in the import archive will be used)
        Returns:
        a map containing metadata describing the contents of the import archive and predicted outcome of the import
        Throws:
        Exception - if an error occurs
      • setNewClientCode

        public void setNewClientCode​(String newClientCode)
        Set the client code of the import target client. Note: This client code will be ignored if importAsGlobal is set to true (it defaults to false, but can be flipped using ServiceConnectionArchiveService#setImportAsGlobal(boolean)).
        Parameters:
        newClientCode - the client code (optional; if not specified, the client in the archive will be used)
      • writeExportData

        protected void writeExportData​(Object object,
                                       ZipOutputStream zos,
                                       Map<String,​String> additionalHeaders)
                                throws Exception
        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:
        Exception - if an error occurs
      • processImportFile

        protected void processImportFile​(String fileName,
                                         byte[] fileData)
                                  throws Exception
        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:
        Exception - if an error occurs
      • performImport

        protected void performImport​(ImportAction importAction,
                                     Set<? extends Enum> importOptions,
                                     Map<String,​Object> parameters)
                              throws Exception
        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:
        Exception - If an error occurs. The caller is responsible for rolling back the transaction to avoid contaminating the database.
      • 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
      • 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 ServiceConnection 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:
        object - ImportAction containing action performed (required)
        Since:
        17.10.2