@Nonnull public static MimeBodyPart compressMimeBodyPart (@Nonnull final MimeBodyPart aData, @Nonnull final ECompressionType eCompressionType, @Nonnull final EContentTransferEncoding eCTE) throws SMIMEException { ValueEnforcer.notNull (aData, "Data"); ValueEnforcer.notNull (eCompressionType, "CompressionType"); ValueEnforcer.notNull (eCTE, "ContentTransferEncoding"); final SMIMECompressedGenerator aCompressedGenerator = new SMIMECompressedGenerator (); // Content-Transfer-Encoding to use aCompressedGenerator.setContentTransferEncoding (eCTE.getID ()); // This call might modify the original mime part and add "Content-Type" and // "Content-Transfer-Encoding" header final MimeBodyPart aCompressedBodyPart = aCompressedGenerator.generate (aData, eCompressionType.createOutputCompressor ()); return aCompressedBodyPart; }
public MimeBodyPart compress(Message msg, MimeBodyPart mbp, String compressionType, String contentTxfrEncoding) throws SMIMEException, OpenAS2Exception { OutputCompressor compressor = null; if (compressionType != null) { if (compressionType.equalsIgnoreCase(ICryptoHelper.COMPRESSION_ZLIB)) { compressor = new ZlibCompressor(); } else { throw new OpenAS2Exception("Unsupported compression type: " + compressionType); } } SMIMECompressedGenerator sCompGen = new SMIMECompressedGenerator(); sCompGen.setContentTransferEncoding(getEncoding(contentTxfrEncoding)); MimeBodyPart smime = sCompGen.generate(mbp, compressor); if (logger.isTraceEnabled()) { try { logger.trace("Compressed MIME msg AFTER COMPRESSION Content-Type:" + smime.getContentType()); logger.trace("Compressed MIME msg AFTER COMPRESSION Content-Disposition:" + smime.getDisposition()); } catch (MessagingException e) { } } return smime; }