1 package net.suberic.pooka.cache; 2 import javax.mail.internet.*; 3 4 public class WrappedMimePartDataSource extends MimePartDataSource { 5 MessageCache cache; 6 long uid; 7 MimePart localPart; 8 9 public WrappedMimePartDataSource(MimePart mm, MessageCache newCache, long newUid) { 10 super(mm); 11 cache=newCache; 12 uid = newUid; 13 } 14 15 public java.io.InputStream getInputStream() throws java.io.IOException { 16 try { 17 return super.getInputStream(); 18 } catch (java.io.IOException ioe) { 19 if (localPart instanceof MimeMessage) { 20 try { 21 java.io.InputStream is = ((MimeMessage)localPart).getRawInputStream(); 23 return MimeUtility.decode(is, "7bit"); 24 } catch (Exception e) { 25 cache.invalidateCache(uid, MessageCache.CONTENT); 26 throw ioe; 27 } 28 } else { 29 cache.invalidateCache(uid, MessageCache.CONTENT); 30 throw ioe; 31 } 32 } 33 } 34 35 } 36 | Popular Tags |