Source Code Cross Referenced for DisklessResourceManager.java in  » Mail-Clients » pooka » net » suberic » pooka » resource » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » pooka » net.suberic.pooka.resource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.pooka.resource;
002:
003:        import net.suberic.util.*;
004:        import net.suberic.pooka.*;
005:        import net.suberic.pooka.ssl.*;
006:
007:        import javax.activation.*;
008:        import java.io.*;
009:        import java.util.*;
010:        import java.net.*;
011:
012:        /**
013:         * A PookaResourceManager which uses no files.
014:         */
015:        public class DisklessResourceManager extends ResourceManager {
016:
017:            /**
018:             * Creates a VariableBundle to be used.
019:             */
020:            public VariableBundle createVariableBundle(String fileName,
021:                    VariableBundle defaults) {
022:                return defaults;
023:            }
024:
025:            /**
026:             * Creates a MailcapCommandMap to be used.
027:             */
028:            public MailcapCommandMap createMailcap(String fileName) {
029:                return new FullMailcapCommandMap();
030:            }
031:
032:            /**
033:             * Creates a PookaTrustManager.
034:             */
035:            public PookaTrustManager createPookaTrustManager(
036:                    javax.net.ssl.TrustManager[] pTrustManagers, String fileName) {
037:                return new PookaTrustManager(pTrustManagers, null, false);
038:            }
039:
040:            /**
041:             * Creates an output file which includes only resources that are appropriate
042:             * to a Diskless client.
043:             */
044:            public static void exportResources(File pOutputFile,
045:                    boolean pIncludePasswords) throws IOException {
046:                VariableBundle sourceBundle = Pooka.getResources();
047:
048:                pOutputFile.createNewFile();
049:                VariableBundle newWritableProperties = new VariableBundle(
050:                        pOutputFile, null);
051:
052:                // first go through and edit out the inappropriate stores.
053:
054:                List allStores = Pooka.getStoreManager().getStoreList();
055:                List toRemoveList = new ArrayList();
056:                List keepList = new ArrayList();
057:
058:                Iterator iter = allStores.iterator();
059:                while (iter.hasNext()) {
060:                    // if they're not imap, exclude them.  if they are imap, set them not
061:                    // to cache.
062:                    StoreInfo current = (StoreInfo) iter.next();
063:
064:                    if (current.getProtocol() != null
065:                            && current.getProtocol().toLowerCase().startsWith(
066:                                    "imap")) {
067:                        newWritableProperties.setProperty(current
068:                                .getStoreProperty()
069:                                + ".cachingEnabled", "false");
070:                        keepList.add(current.getStoreID());
071:                    } else {
072:                        toRemoveList.add(current.getStoreID());
073:                    }
074:                }
075:
076:                //Enumeration names = newWritableProperties.propertyNames();
077:                //Enumeration names = sourceBundle.getWritableProperties().propertyNames();
078:                Enumeration names = sourceBundle.getProperties()
079:                        .propertyNames();
080:
081:                while (names.hasMoreElements()) {
082:                    String current = (String) names.nextElement();
083:
084:                    boolean keep = true;
085:                    if (current.startsWith("Store")) {
086:                        if ((!pIncludePasswords)
087:                                && current.endsWith("password")) {
088:                            keep = false;
089:                        } else if (current.endsWith("cachingEnabled")) {
090:                            keep = false;
091:                        }
092:
093:                        for (int i = 0; keep && i < toRemoveList.size(); i++) {
094:                            if (current.startsWith("Store."
095:                                    + (String) toRemoveList.get(i))) {
096:                                keep = false;
097:                            }
098:                        }
099:                    }
100:
101:                    if (keep) {
102:                        newWritableProperties.setProperty(current, sourceBundle
103:                                .getProperty(current));
104:                    }
105:
106:                }
107:
108:                // don't use local files.
109:                newWritableProperties.setProperty("Pooka.useLocalFiles",
110:                        "false");
111:
112:                // put only the kept stores in the store list.
113:                newWritableProperties.setProperty("Store", VariableBundle
114:                        .convertToString(keepList));
115:
116:                //FileOutputStream outStream = new FileOutputStream(pOutputFile);
117:
118:                //newWritableProperties.setSaveFile(pOutputFile);
119:                newWritableProperties.saveProperties();
120:
121:                //outStream.close();
122:
123:            }
124:
125:            /**
126:             * Gets a resource for reading.  pFileName could be a URL or a file name
127:             * or some similar identifier that the 
128:             */
129:            public java.io.InputStream getInputStream(String pFileName)
130:                    throws java.io.IOException {
131:                try {
132:                    URL url = new URL(pFileName);
133:                    return url.openStream();
134:                } catch (MalformedURLException mue) {
135:                    throw new IOException("Error opening URL:  "
136:                            + mue.getMessage());
137:                }
138:            }
139:
140:            public java.io.OutputStream getOutputStream(String pFileName)
141:                    throws java.io.IOException {
142:                // no writing to streams in this one.
143:                throw new IOException(
144:                        "Diskless mode:  no file modification available.");
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.