Source Code Cross Referenced for StoreManager.java in  » Mail-Clients » pooka » net » suberic » pooka » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.pooka;
002:
003:        import javax.mail.*;
004:        import java.util.*;
005:        import net.suberic.util.*;
006:
007:        /**
008:         * This class manages the a list of StoreInfos.  It also provides some
009:         * convenience methods for accessing FolderInfos within the StoreInfos,
010:         * and for adding and removing StoreInfos.
011:         */
012:
013:        public class StoreManager implements  ItemCreator,
014:                ItemListChangeListener {
015:
016:            private ItemManager manager;
017:            private LinkedList listenerList = new LinkedList();
018:
019:            public StoreManager() {
020:                createStoreList();
021:            }
022:
023:            //-----------------------
024:            // public interface.
025:
026:            /**
027:             * As defined in net.suberic.util.ValueChangeListener.
028:             * 
029:             * This listens for ItemListChangeEvents, which result from changes to the 
030:             * "Store" property.  The result is that refrestStoreInfos() is called,
031:             * and then the event is passed to listeners to this object.
032:             */
033:            public void itemListChanged(ItemListChangeEvent e) {
034:                fireItemListChanged(e);
035:                refreshStoreInfos(e);
036:            }
037:
038:            /**
039:             * This returns a Vector with all the currently registered StoreInfo
040:             * objects.
041:             */
042:            public java.util.Vector getStoreList() {
043:                return manager.getItems();
044:            }
045:
046:            /**
047:             * This adds the store with the given storeName to the allStores list.
048:             */
049:            public void addStore(String storeName) {
050:                manager.addItem(storeName);
051:            }
052:
053:            /**
054:             * This adds the stores with the given storeNames to the allStores list.
055:             */
056:            public void addStore(String[] storeName) {
057:                manager.addItem(storeName);
058:            }
059:
060:            /**
061:             * This removes the store with the given storeName.
062:             */
063:            public void removeStore(String storeName) {
064:                manager.removeItem(storeName);
065:            }
066:
067:            /**
068:             * This removes the stores with the given storeNames.
069:             */
070:            public void removeStore(String[] storeNames) {
071:                manager.removeItem(storeNames);
072:            }
073:
074:            /**
075:             * This removes the given StoreInfo.
076:             */
077:            public void removeStore(StoreInfo store) {
078:                manager.removeItem(store);
079:            }
080:
081:            /**
082:             * This removes the given StoreInfos.
083:             */
084:            public void removeStore(StoreInfo[] stores) {
085:                manager.removeItem(stores);
086:            }
087:
088:            /**
089:             * This compares the storeList object with the Store property, and
090:             * updates the storeList appropriately.
091:             */
092:            public void refreshStoreInfos(ItemListChangeEvent e) {
093:                Item[] removedStores = e.getRemoved();
094:                for (int i = 0; removedStores != null
095:                        && i < removedStores.length; i++) {
096:                    ((StoreInfo) removedStores[i]).remove();
097:                }
098:            }
099:
100:            /**
101:             * This returns the FolderInfo which corresponds to the given folderName.
102:             * The folderName should be in the form "/storename/folder/subfolder".
103:             */
104:            public FolderInfo getFolder(String folderName) {
105:                if (folderName != null && folderName.length() >= 1) {
106:                    int divider = folderName.indexOf('/', 1);
107:                    while (divider == 0) {
108:                        folderName = folderName.substring(1);
109:                        divider = folderName.indexOf('/');
110:                    }
111:
112:                    if (divider > 0) {
113:                        String storeName = folderName.substring(0, divider);
114:                        StoreInfo store = getStoreInfo(storeName);
115:                        if (store != null) {
116:                            return store.getChild(folderName
117:                                    .substring(divider + 1));
118:                        }
119:                    }
120:                }
121:
122:                return null;
123:            }
124:
125:            /**
126:             * This returns the FolderInfo which corresponds to the given folderID.
127:             * The folderName should be in the form "storename.folderID.folderID".
128:             */
129:            public FolderInfo getFolderById(String folderID) {
130:                // hurm.  the problem here is that '.' is a legal value in a name...
131:
132:                java.util.Vector allStores = getStoreList();
133:
134:                for (int i = 0; i < allStores.size(); i++) {
135:                    StoreInfo currentStore = (StoreInfo) allStores.elementAt(i);
136:                    if (folderID.startsWith(currentStore.getStoreID())) {
137:                        FolderInfo possibleMatch = currentStore
138:                                .getFolderById(folderID);
139:                        if (possibleMatch != null) {
140:                            return possibleMatch;
141:                        }
142:                    }
143:                }
144:
145:                return null;
146:            }
147:
148:            /**
149:             * Gets all of the open and available folders known by the system.
150:             */
151:            public Vector getAllOpenFolders() {
152:                Vector returnValue = new Vector();
153:                Vector currentStores = getStoreList();
154:                for (int i = 0; i < currentStores.size(); i++) {
155:                    returnValue.addAll(((StoreInfo) currentStores.elementAt(i))
156:                            .getAllFolders());
157:                }
158:
159:                return returnValue;
160:            }
161:
162:            /**
163:             * This returns the StoreInfo with the given storeName if it exists
164:             * in the allStores Vector; otherwise, returns null.
165:             */
166:            public StoreInfo getStoreInfo(String storeID) {
167:                return (StoreInfo) manager.getItem(storeID);
168:            }
169:
170:            /**
171:             * This loads all the Sent Folders on the UserProfile object.  This must
172:             * be called separately because UserProfiles have references to StoreInfos
173:             * and StoreInfos have references to UserProfiles.
174:             */
175:            public void loadAllSentFolders() {
176:                List profileList = Pooka.getPookaManager()
177:                        .getUserProfileManager().getUserProfileList();
178:
179:                for (int i = 0; i < profileList.size(); i++) {
180:                    ((UserProfile) profileList.get(i)).loadSentFolder();
181:                }
182:            }
183:
184:            /**
185:             * This adds a ItemListChangeListener to the local listener list.
186:             */
187:            public void addItemListChangeListener(ItemListChangeListener ilcl) {
188:                if (!listenerList.contains(ilcl))
189:                    listenerList.add(ilcl);
190:            }
191:
192:            /**
193:             * This removes a ItemListChangeListener from the local listener list.
194:             */
195:            public void removeItemListChangeListener(ItemListChangeListener ilcl) {
196:                listenerList.remove(ilcl);
197:            }
198:
199:            /**
200:             * This notifies all listeners that the StoreList has changed.
201:             */
202:            public void fireItemListChanged(ItemListChangeEvent e) {
203:                for (int i = 0; i < listenerList.size(); i++)
204:                    ((ItemListChangeListener) listenerList.get(i))
205:                            .itemListChanged(e);
206:            }
207:
208:            /**
209:             * This creates a new StoreInfo.
210:             * 
211:             * As defined by interface net.suberic.util.ItemCreator.
212:             */
213:            public Item createItem(VariableBundle sourceBundle,
214:                    String resourceString, String itemID) {
215:                return new StoreInfo(itemID);
216:            }
217:
218:            //---------------------------
219:            // the background stuff.
220:
221:            /**
222:             * This loads and creates all the Stores using the "Store" property
223:             * of the main Pooka VariableBundle.
224:             */
225:            private void createStoreList() {
226:                manager = new ItemManager("Store", Pooka.getResources(), this );
227:                manager.addItemListChangeListener(this );
228:            }
229:
230:            /**
231:             * Sets up SSL connections.
232:             */
233:            public static void setupSSL() {
234:                // set up the SSL socket factory.
235:
236:                // we have to configure this or the sun jdks will fail.  however, this
237:                // also will make ibm jdks fail since they don't have the com.sun
238:                // classes.  so we have to be sneaky.
239:
240:                try {
241:                    Object provider = Class.forName(
242:                            "com.sun.net.ssl.internal.ssl.Provider")
243:                            .newInstance();
244:
245:                    java.security.Security
246:                            .addProvider((java.security.Provider) provider);
247:
248:                    //java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
249:                } catch (Exception e) {
250:                    // if we catch an exception for this then we're probably running with
251:                    // a non-sun jdk, in which case we shouldn't need to add a provider
252:                    // explicitly
253:                }
254:                java.security.Security.setProperty(
255:                        "ssl.SocketFactory.provider",
256:                        "net.suberic.pooka.ssl.PookaSSLSocketFactory");
257:
258:            }
259:
260:            /**
261:             * Cleans up the StoreManager.
262:             */
263:            public void cleanup() {
264:                Pooka.getResources().removeValueChangeListener(manager);
265:            }
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.