1 package net.suberic.pooka.resource; 2 3 import net.suberic.util.*; 4 import net.suberic.pooka.ssl.*; 5 import net.suberic.pooka.*; 6 import javax.activation.*; 7 8 import java.net.*; 9 import java.io.*; 10 11 14 public class FileResourceManager extends ResourceManager { 15 16 19 public VariableBundle createVariableBundle(String fileName, VariableBundle defaults) { 20 try { 21 java.io.File f = new java.io.File (fileName); 22 if (! f.exists()) 23 f.createNewFile(); 24 return new net.suberic.util.VariableBundle(f, defaults); 25 } catch (java.io.IOException ioe) { 26 return defaults; 28 } 29 30 } 31 32 35 public MailcapCommandMap createMailcap(String fileName) throws java.io.IOException { 36 return new FullMailcapCommandMap(fileName); 37 } 38 39 42 public PookaTrustManager createPookaTrustManager(javax.net.ssl.TrustManager[] pTrustManagers, String fileName) { 43 return new PookaTrustManager(pTrustManagers, fileName); 44 } 45 46 public java.io.InputStream getInputStream(String pFileName) 47 throws java.io.IOException { 48 try { 49 URL url = new URL(pFileName); 50 return url.openStream(); 51 } catch (MalformedURLException mue) { 52 return new FileInputStream(new File(pFileName)); 53 } 54 } 55 56 57 public java.io.OutputStream getOutputStream(String pFileName) 58 throws java.io.IOException { 59 return new FileOutputStream(new File(pFileName)); 60 } 61 62 65 public FolderInfo createFolderInfo(StoreInfo pStore, String pName) { 66 String storeProperty = pStore.getStoreProperty(); 67 if (pStore.isPopStore() && pName.equalsIgnoreCase("INBOX")) { 68 return new PopInboxFolderInfo(pStore, pName); 69 } else if (Pooka.getProperty(storeProperty + ".protocol", "mbox").equalsIgnoreCase("imap")) { 70 if (Pooka.getProperty(storeProperty + ".cachingEnabled", Pooka.getProperty(storeProperty + "." + pName + ".cachingEnabled", "false")).equalsIgnoreCase("true") || Pooka.getProperty(storeProperty + ".cacheHeadersOnly", Pooka.getProperty(storeProperty + "." + pName + ".cacheHeadersOnly", "false")).equalsIgnoreCase("true")) { 71 return new net.suberic.pooka.cache.CachingFolderInfo(pStore, pName); 72 } else { 73 return new UIDFolderInfo(pStore, pName); 74 } 75 } else { 76 return new FolderInfo(pStore, pName); 77 } 78 } 79 80 } 81 82 83 | Popular Tags |