KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > cache > WrappedMimePartDataSource


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 JavaDoc getInputStream() throws java.io.IOException JavaDoc {
16     try {
17       return super.getInputStream();
18     } catch (java.io.IOException JavaDoc ioe) {
19       if (localPart instanceof MimeMessage) {
20     try {
21       // pretend it's 7bit encoding.
22
java.io.InputStream JavaDoc is = ((MimeMessage)localPart).getRawInputStream();
23       return MimeUtility.decode(is, "7bit");
24     } catch (Exception JavaDoc 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