Interface ZipAttachmentProvider


  • @ConsumerType
    public interface ZipAttachmentProvider
    This is an optional extension of the InventoryPrinter. If a inventory printer implements this interface, the printer can add additional attachments to the output of the configuration ZIP.

    A service implementing this method must register itself as a InventoryPrinter but not as a ZipAttachmentProvider service. When writing output to a ZIP file, this method is called if the InventoryPrinter service implements this interface.

    • Method Detail

      • addAttachments

        void addAttachments​(java.util.zip.ZipOutputStream zos,
                            java.lang.String namePrefix)
                     throws java.io.IOException
        Add attachments to the zip output stream. The attachment provider can add as many attachments in any format as it wants. However it should use the namePrefix to create unique names / paths inside the zip.

        The general pattern is to do for each entry to be added:

        1. Create ZipEntry with a name composed of namePrefix and a name unique to the attachement provider, e.g. namePrefix + "att1.txt".
        2. Add the ZipEntry to the ZIP file zos.
        3. Write the contents of the entry; for example copying a filesystem file to the ZIP file zos.
        4. Close the ZipEntry.
        Parameters:
        zos - The zip output stream.
        namePrefix - Name prefix to use for zip entries. Ends with a slash.
        Throws:
        java.io.IOException - If an error occurrs writing the ZIP entry. This may also be caused by reading some file system file to be added to the ZIP file.