public InputStream getInputStream() { try { if (cache != null) { return cache.getInputStream(); } if (delegate == null) { delegate = new DelegatingInputStream(ins); } return delegate; } catch (IOException e) { return null; } }
private void cache(DelegatingInputStream input) throws IOException { if (loaded.contains(input)) { return; } loaded.add(input); InputStream origIn = input.getInputStream(); try (CachedOutputStream out = new CachedOutputStream()) { AttachmentUtil.setStreamedAttachmentProperties(message, out); IOUtils.copy(input, out); input.setInputStream(out.getInputStream()); origIn.close(); } }
private void cacheStreamedAttachments() throws IOException { if (body instanceof DelegatingInputStream && !((DelegatingInputStream) body).isClosed()) { cache((DelegatingInputStream) body); } List<Attachment> atts = new ArrayList<>(attachments.getLoadedAttachments()); for (Attachment a : atts) { DataSource s = a.getDataHandler().getDataSource(); if (s instanceof AttachmentDataSource) { AttachmentDataSource ads = (AttachmentDataSource)s; if (!ads.isCached()) { ads.cache(message); } } else if (s.getInputStream() instanceof DelegatingInputStream) { cache((DelegatingInputStream) s.getInputStream()); } else { //assume a normal stream that is already cached } } }
public void cache(Message message) throws IOException { if (cache == null) { cache = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); try { IOUtils.copy(ins, cache); cache.lockOutputStream(); if (delegate != null) { delegate.setInputStream(cache.getInputStream()); } } catch (CacheSizeExceededException | IOException cee) { cache.close(); cache = null; throw cee; } finally { try { ins.close(); } catch (Exception ex) { //ignore } ins = null; } } } public void hold(Message message) throws IOException {
private void cacheStreamedAttachments() throws IOException { if (body instanceof DelegatingInputStream && !((DelegatingInputStream) body).isClosed()) { cache((DelegatingInputStream) body); } List<Attachment> atts = new ArrayList<>(attachments.getLoadedAttachments()); for (Attachment a : atts) { DataSource s = a.getDataHandler().getDataSource(); if (s instanceof AttachmentDataSource) { AttachmentDataSource ads = (AttachmentDataSource)s; if (!ads.isCached()) { ads.cache(message); } } else if (s.getInputStream() instanceof DelegatingInputStream) { cache((DelegatingInputStream) s.getInputStream()); } else { //assume a normal stream that is already cached } } }
public void cache(Message message) throws IOException { if (cache == null) { cache = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); try { IOUtils.copy(ins, cache); cache.lockOutputStream(); if (delegate != null) { delegate.setInputStream(cache.getInputStream()); } } catch (CacheSizeExceededException | IOException cee) { cache.close(); cache = null; throw cee; } finally { try { ins.close(); } catch (Exception ex) { //ignore } ins = null; } } } public void hold(Message message) throws IOException {
private void cache(DelegatingInputStream input) throws IOException { if (loaded.contains(input)) { return; } loaded.add(input); InputStream origIn = input.getInputStream(); try (CachedOutputStream out = new CachedOutputStream()) { AttachmentUtil.setStreamedAttachmentProperties(message, out); IOUtils.copy(input, out); input.setInputStream(out.getInputStream()); origIn.close(); } }
public InputStream getInputStream() { try { if (cache != null) { return cache.getInputStream(); } if (delegate == null) { delegate = new DelegatingInputStream(ins); } return delegate; } catch (IOException e) { return null; } }
private void cacheStreamedAttachments() throws IOException { if (body instanceof DelegatingInputStream && !((DelegatingInputStream) body).isClosed()) { cache((DelegatingInputStream) body, true); } List<Attachment> atts = new ArrayList<Attachment>(attachments.getLoadedAttachments()); for (Attachment a : atts) { DataSource s = a.getDataHandler().getDataSource(); if (s instanceof AttachmentDataSource) { AttachmentDataSource ads = (AttachmentDataSource)s; if (!ads.isCached()) { ads.cache(message); } } else if (s.getInputStream() instanceof DelegatingInputStream) { cache((DelegatingInputStream) s.getInputStream(), false); } else { //assume a normal stream that is already cached } } }
public void cache(Message message) throws IOException { if (cache == null) { cache = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); try { IOUtils.copy(ins, cache); cache.lockOutputStream(); if (delegate != null) { delegate.setInputStream(cache.getInputStream()); } } catch (CacheSizeExceededException cee) { cache.close(); cache = null; throw cee; } catch (IOException cee) { cache.close(); cache = null; throw cee; } finally { try { ins.close(); } catch (Exception ex) { //ignore } ins = null; } } } public void hold(Message message) throws IOException {
private void cache(DelegatingInputStream input, boolean deleteOnClose) throws IOException { if (loaded.contains(input)) { return; } loaded.add(input); CachedOutputStream out = null; InputStream origIn = input.getInputStream(); try { out = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, out); IOUtils.copy(input, out); input.setInputStream(out.getInputStream()); origIn.close(); } finally { if (out != null) { out.close(); } } }
public InputStream getInputStream() { try { if (cache != null) { return cache.getInputStream(); } if (delegate == null) { delegate = new DelegatingInputStream(ins); } return delegate; } catch (IOException e) { return null; } }
private void cacheStreamedAttachments() throws IOException { if (body instanceof DelegatingInputStream && !((DelegatingInputStream) body).isClosed()) { cache((DelegatingInputStream) body, true); } List<Attachment> atts = new ArrayList<Attachment>(attachments.getLoadedAttachments()); for (Attachment a : atts) { DataSource s = a.getDataHandler().getDataSource(); if (s instanceof AttachmentDataSource) { AttachmentDataSource ads = (AttachmentDataSource)s; if (!ads.isCached()) { ads.cache(message); } } else if (s.getInputStream() instanceof DelegatingInputStream) { cache((DelegatingInputStream) s.getInputStream(), false); } else { //assume a normal stream that is already cached } } }
public void cache(Message message) throws IOException { if (cache == null) { cache = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); try { IOUtils.copy(ins, cache); cache.lockOutputStream(); if (delegate != null) { delegate.setInputStream(cache.getInputStream()); } } catch (CacheSizeExceededException cee) { cache.close(); cache = null; throw cee; } catch (IOException cee) { cache.close(); cache = null; throw cee; } finally { try { ins.close(); } catch (Exception ex) { //ignore } ins = null; } } } public void hold(Message message) throws IOException {
private void cache(DelegatingInputStream input, boolean deleteOnClose) throws IOException { if (loaded.contains(input)) { return; } loaded.add(input); CachedOutputStream out = null; InputStream origIn = input.getInputStream(); try { out = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, out); IOUtils.copy(input, out); input.setInputStream(out.getInputStream()); origIn.close(); } finally { if (out != null) { out.close(); } } }
public InputStream getInputStream() { try { if (cache != null) { return cache.getInputStream(); } if (delegate == null) { delegate = new DelegatingInputStream(ins); } return delegate; } catch (IOException e) { return null; } }
/** * Create an Attachment from the MIME stream. If there is a previous attachment * that is not read, cache that attachment. * * @throws IOException */ private Attachment createAttachment(Map<String, List<String>> headers) throws IOException { InputStream partStream = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, PUSHBACK_AMOUNT), this); createCount++; return AttachmentUtil.createAttachment(partStream, headers); }
/** * Create an Attachment from the MIME stream. If there is a previous attachment * that is not read, cache that attachment. * * @throws IOException */ private Attachment createAttachment(Map<String, List<String>> headers) throws IOException { InputStream partStream = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, PUSHBACK_AMOUNT), this); createCount++; return AttachmentUtil.createAttachment(partStream, headers); }
/** * Create an Attachment from the MIME stream. If there is a previous attachment * that is not read, cache that attachment. * * @return * @throws IOException */ private Attachment createAttachment(InternetHeaders headers) throws IOException { InputStream partStream = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, pbAmount), this); createCount++; return AttachmentUtil.createAttachment(partStream, headers); }
/** * Create an Attachment from the MIME stream. If there is a previous attachment * that is not read, cache that attachment. * * @return * @throws IOException */ private Attachment createAttachment(InternetHeaders headers) throws IOException { InputStream partStream = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, pbAmount), this); createCount++; return AttachmentUtil.createAttachment(partStream, headers); }