Class TPacArchiveService


  • public class TPacArchiveService
    extends BaseArchiveService
    Provides a service archive export and import service.
    • Constructor Detail

      • TPacArchiveService

        public TPacArchiveService()
    • Method Detail

      • 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)
      • getImportMetadata

        public Map<String,​String> getImportMetadata​(byte[] importData)
                                                   throws Exception
        Description copied from class: BaseArchiveService
        Retrieve the set of metadata values describing an 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:
        Exception - if an error occurs while the metadata is being loaded
      • getImportMetadata

        public Map<String,​Object> getImportMetadata​(byte[] importData,
                                                          String newClientCode)
                                                   throws Exception
        Retrieve metadata describing the archive contents and expected import outcome.
        Parameters:
        importData - the archive byte data (required)
        newClientCode - the client code that the new services shall be imported to (optional)
        Returns:
        a map of import metadata
        Throws:
        Exception - if an error occurs
      • 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
      • preparedImport

        public ImportAction preparedImport​(String fileName,
                                           byte[] importData,
                                           String creatorLoginName)
                                    throws IOException,
                                           ImportValidationException
        prepare import and generate import action
        Parameters:
        fileName - file name to import
        importData - file data to import
        creatorLoginName - creator login name
        Returns:
        ImportAction object that could be used in the following call like performImport()
        Throws:
        IOException - if any IO error happens
        ImportValidationException - if import validation fails
      • performImport

        public void performImport​(String clientCode,
                                  ImportAction importAction,
                                  boolean override,
                                  boolean checkConflict)
                           throws Exception
        perform a TPac Import. Typically it needs preparedImport() to be called first to generate ImportAction passing in as parameter. if checkConflict is true, it will throw error if existing global services have same name as importing one, or has existing service in same org but override is false.
        Parameters:
        clientCode - the client code that TPac goes into
        importAction - ImportAction from preparedImport() method call earlier
        override - override existing assets
        checkConflict - check conflict and throw exception when - there is global service name with same name in importing TPac - there is service with same name in same org and override is false
        Throws:
        Exception - if an error occurs
      • exportAuditLogger

        protected void exportAuditLogger​(Object object)
        Implement abstract method from BaseArchiveService however no action is performed as we do not export Tpacs This method should not be called as Tpacs are not exported
        Specified by:
        exportAuditLogger in class BaseArchiveService
        Parameters:
        object - Object 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 This is called before the postImport method
        Specified by:
        importAuditLogger in class BaseArchiveService
        Parameters:
        object - ImportAction containing action performed (required)
        Since:
        17.10.2