Class AttachmentDirectoryFactory
- java.lang.Object
-
- com.levigo.jadice.server.mail.worker.AttachmentDirectoryFactory
-
public final class AttachmentDirectoryFactory extends Object
Utility class to create anAttachmentDirectory
from a bunch of email attachments. If these attachments are PDFs (or converted to PDF) page counting will be performed in order to generate a proper TOC.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COVER_FOR
Add anotherStreamDescriptor
with this key in the givenStreamDescriptor.getContext()
s, so that that one will be taken as information to appear in the resultingAttachmentDirectory
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static int
countPages(com.levigo.jadice.document.io.SeekableInputStream documentStream, QualifiedLogEventReceiver logEventReceiver)
protected static int
createAttachment(StreamDescriptor sd, StreamDescriptor rootDescriptor, int nmbPages, int pageOffset, AttachmentDirectory rootDirectory)
Insert aStreamDescriptor
into the given attachment directory that represents the root of the mailstatic AttachmentDirectory
createAttachmentDirectory(StreamDescriptor rootDescriptor, List<Stream> streams, QualifiedLogEventReceiver controller)
Create anAttachmentDirectory
that characterizes the given attachments.protected static BundledStream
createStream(com.levigo.jadice.document.io.SeekableInputStream sis, StreamDescriptor sd)
static void
exportToXML(XMLStreamWriter xsw, AttachmentDirectory dir, int pageIndexOffset)
protected static StreamDescriptor
getAttachmentDescriptor(StreamDescriptor sd)
Find theStreamDescriptor
that contains the attachment information for the given Stream (identified by the givenStreamDescriptor
).protected static byte[]
toByteArray(InputStream stream)
-
-
-
Field Detail
-
COVER_FOR
public static final String COVER_FOR
Add anotherStreamDescriptor
with this key in the givenStreamDescriptor.getContext()
s, so that that one will be taken as information to appear in the resultingAttachmentDirectory
.- See Also:
- Constant Field Values
-
-
Method Detail
-
createAttachmentDirectory
public static AttachmentDirectory createAttachmentDirectory(StreamDescriptor rootDescriptor, List<Stream> streams, QualifiedLogEventReceiver controller) throws Throwable
Create anAttachmentDirectory
that characterizes the given attachments.- Parameters:
rootDescriptor
- theStreamDescriptor
of the mail bodycontroller
- theWorkerController
associated with the current executionstreams
- The pre-converted attachments as PDF. If the attachment has another MIME type, page counting will be disabled- Returns:
- An
AttachmentDirectory
that shows how the given attachments are placed within the email that contains them - Throws:
Throwable
- if the creation fails
-
createAttachment
protected static int createAttachment(StreamDescriptor sd, StreamDescriptor rootDescriptor, int nmbPages, int pageOffset, AttachmentDirectory rootDirectory) throws Throwable
Insert aStreamDescriptor
into the given attachment directory that represents the root of the mail- Parameters:
sd
- The Descriptor to insertrootDescriptor
- theStreamDescriptor
of the mail bodynmbPages
- how many pages the PDF / TIFF associated with the descriptor haspageOffset
- the number of pages that were handled beforerootDirectory
- the directory that contains all of the attachments of the mail- Returns:
- the new total number of pages that are stored in the
AttachmentDirectory
- Throws:
Throwable
- if the attachment creation fails
-
getAttachmentDescriptor
protected static StreamDescriptor getAttachmentDescriptor(StreamDescriptor sd)
Find theStreamDescriptor
that contains the attachment information for the given Stream (identified by the givenStreamDescriptor
).- Parameters:
sd
-StreamDescriptor
to search in- Returns:
- a
StreamDescriptor
ornull
-
toByteArray
protected static byte[] toByteArray(InputStream stream) throws IOException
- Throws:
IOException
-
createStream
protected static BundledStream createStream(com.levigo.jadice.document.io.SeekableInputStream sis, StreamDescriptor sd) throws IOException
- Throws:
IOException
-
countPages
protected static int countPages(com.levigo.jadice.document.io.SeekableInputStream documentStream, QualifiedLogEventReceiver logEventReceiver) throws IOException
- Throws:
IOException
-
exportToXML
public static void exportToXML(XMLStreamWriter xsw, AttachmentDirectory dir, int pageIndexOffset) throws XMLStreamException
- Throws:
XMLStreamException
-
-