Source Code Cross Referenced for JPimABStore.java in  » Portal » Open-Portal » com » sun » ssoadapter » ab » pim » 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 » Portal » Open Portal » com.sun.ssoadapter.ab.pim 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: JPimABStore.java,v 1.4 2005/03/09 23:10:41 rakeshn Exp $
003:         * Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use of this
004:         * product is subject to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users Subject to Standard License Terms
006:         * and Conditions.
007:         *
008:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE are trademarks or 
009:         * registered trademarks of Sun Microsystems, Inc. in the United States
010:         * and other countries.
011:         */package com.sun.ssoadapter.ab.pim;
012:
013:        import java.lang.reflect.Method;
014:
015:        import com.sun.addressbook.ABSession;
016:        import com.sun.addressbook.ABSearchTerm;
017:        import com.sun.addressbook.ABStore;
018:        import com.sun.addressbook.AddressBook;
019:        import com.sun.addressbook.ABFilter;
020:        import com.sun.addressbook.Entry;
021:        import com.sun.addressbook.Group;
022:
023:        import com.sun.addressbook.ABStoreException;
024:        import com.sun.addressbook.MissingPropertiesException;
025:        import com.sun.addressbook.OperationNotSupportedException;
026:
027:        import com.aligo.pim.PimFactory;
028:        import com.aligo.pim.PimContainerType;
029:        import com.aligo.pim.PimFolderType;
030:        import com.aligo.pim.PimSortType;
031:        import com.aligo.pim.interfaces.PimFolders;
032:        import com.aligo.pim.interfaces.PimContainer;
033:        import com.aligo.pim.interfaces.PimUserInfo;
034:        import com.aligo.pim.interfaces.PimAddressBook;
035:        import com.aligo.pim.interfaces.PimAddressEntryItem;
036:        import com.aligo.pim.interfaces.PimAddressEntryItems;
037:        import com.aligo.pim.interfaces.PimAddressEntryItemFilter;
038:
039:        import com.aligo.pim.exceptions.PimException;
040:
041:        /**
042:         * The JABAPI ABStore implementation for Pim objects
043:         */
044:        public class JPimABStore extends ABStore implements  JPimABConstants {
045:            private PimContainer pimContainer = null;
046:            private boolean isConnected = false;
047:
048:            //
049:            // The TopLevel AddBook. Points to "Contacts" folder in Exchange/Notes
050:            //
051:            protected PimAddressBook topLevelPimAB = null;
052:
053:            //
054:            // Store the JABAPI Entry & Aligo AddressBook names
055:            //
056:            private SchemaElements schemaElements = new SchemaElements();
057:
058:            public SchemaElements getSchemaElements() {
059:                return schemaElements;
060:            }
061:
062:            /**
063:             * Returns the Container Type corresponding to the backend
064:             * default == Exchange
065:             */
066:            protected PimContainerType getPimContainerType(ABSession session) {
067:                return PimContainerType.EXCHANGE;
068:            }
069:
070:            public void init(ABSession session) throws ABStoreException,
071:                    MissingPropertiesException {
072:                if (schemaElements.getAllCommonPropertyNames() == null) {
073:                    throw new MissingPropertiesException(
074:                            "Cannot find PropertiesMap: "
075:                                    + ENTRY_PIM_ELEMENTS_FILE);
076:                }
077:
078:                PimContainerType containerType = getPimContainerType(session);
079:                try {
080:                    pimContainer = PimFactory.getContainer(containerType);
081:                } catch (Exception e) {
082:                    throw new ABStoreException(e.toString());
083:                }
084:
085:                this .session = session; // store session
086:
087:                //
088:                // Create PimUserInfo
089:                //
090:                try {
091:                    PimUserInfo pimUserInfo = pimContainer.addUserInfo();
092:                    init(session, pimUserInfo);
093:                } catch (PimException pe) {
094:                    throw new ABStoreException("PimUserInfo set failed: " + pe);
095:                }
096:            }
097:
098:            public void init(ABSession session, PimUserInfo pimC)
099:                    throws MissingPropertiesException {
100:                //
101:                // All creds init is done in Notes/ExchangeABStore - nothing here
102:                //
103:            }
104:
105:            public void connect() throws ABStoreException {
106:                if (pimContainer == null) {
107:                    throw new ABStoreException("PimContainer == null");
108:                }
109:
110:                String abType = session.getProperty(AB_TYPE);
111:                PimFolderType type = getFolderType(abType);
112:
113:                try {
114:                    pimContainer.logon();
115:                    postConnect(pimContainer);
116:                    topLevelPimAB = (PimAddressBook) pimContainer
117:                            .getFolder(type);
118:                    isConnected = true;
119:                } catch (PimException pe) {
120:                    pe.printStackTrace();
121:                    throw new ABStoreException("Connect failed: " + pe);
122:                }
123:            }
124:
125:            /**
126:             *  This postConnect gets the CurrentUser info from the pimContainer
127:             *  used for Notes in case of SSO
128:             */
129:
130:            protected void postConnect(PimContainer pimContainer)
131:                    throws ABStoreException {
132:                //Nothing to do here
133:                //NotesABStore will implement the details.
134:
135:            }
136:
137:            public void disconnect() throws ABStoreException {
138:                if (pimContainer == null) {
139:                    throw new ABStoreException("PimContainer == null");
140:                }
141:
142:                try {
143:                    pimContainer.logoff();
144:                } catch (PimException pe) {
145:                    throw new ABStoreException("Disconnect failed: " + pe);
146:                }
147:            }
148:
149:            public boolean isConnected() throws ABStoreException {
150:                //TODO - Alligo - Equivalent ??
151:                return isConnected;
152:            }
153:
154:            /**
155:             * Get the list of address books id's of the user. With JABAPI every
156:             * folder is an AddressBook.
157:             *
158:             * @return          array of user's address book ids
159:             */
160:            public String[] getAddressBooks() throws ABStoreException,
161:                    OperationNotSupportedException {
162:                String[] list = null;
163:
164:                try {
165:                    PimFolders folders = topLevelPimAB.getFolders();
166:                    int count = folders.getCount();
167:
168:                    list = new String[count];
169:
170:                    for (int i = 0; i < count; i++) {
171:                        String id = folders.getFolder(i).getID();
172:                        list[i] = id;
173:                    }
174:
175:                } catch (PimException pe) {
176:                    pe.printStackTrace();
177:                    throw new ABStoreException("getAddressBooks() failed: "
178:                            + pe);
179:                }
180:
181:                return list;
182:            }
183:
184:            /**
185:             * Method to get this user's default address book id.
186:             *
187:             * @return The address book id corresponding to the authenticated user. 
188:             */
189:            protected String getDefaultAbID() throws ABStoreException {
190:                return "";
191:            }
192:
193:            /**
194:             * Map id to Address Book Type. default is PERSONAL_ADDRESS_BOOK. overridden
195:             * by the backend specific implementations.
196:             */
197:            protected PimFolderType getFolderType(String id) {
198:                PimFolderType type = PimFolderType.PERSONAL_ADDRESS_BOOK;
199:
200:                if (id != null) {
201:                    if (id.equalsIgnoreCase(PERSONAL_ADDRESS_BOOK)) {
202:                        type = PimFolderType.PERSONAL_ADDRESS_BOOK;
203:                    } else if (id.equalsIgnoreCase(GLOBAL_ADDRESS_BOOK)) {
204:                        type = PimFolderType.GLOBAL_ADDRESS_BOOK;
205:                    }
206:                }
207:
208:                return type;
209:            }
210:
211:            /**
212:             * Method to retrieve a address book from the backend service.
213:             *
214:             * @param abID    A specific address book ID. (Its not the same as name).
215:             * @return         The specified address book 
216:             *
217:             * @exception ABStoreException if unable to load the specified calendar
218:             */
219:            public AddressBook openAddressBook(String abID)
220:                    throws ABStoreException {
221:
222:                String abType = session.getProperty(AB_TYPE);
223:                PimFolderType type = getFolderType(abType);
224:
225:                try {
226:                    topLevelPimAB = (PimAddressBook) pimContainer
227:                            .getFolder(type);
228:                } catch (PimException pie) {
229:                    pie.printStackTrace();
230:                    throw new ABStoreException("open address book getFolder() "
231:                            + "failed: " + pie);
232:                }
233:
234:                PimAddressBook pBook = topLevelPimAB;
235:
236:                if ((abID != null) && (!abID.trim().equals(""))) {
237:                    try {
238:                        PimFolders pimFolders = pBook.getFolders();
239:                        pBook = (PimAddressBook) pimFolders.getFolder(abID);
240:                    } catch (PimException pe) {
241:                        pe.printStackTrace();
242:                        throw new ABStoreException("getFolder() failed: " + pe);
243:                    }
244:                }
245:
246:                AddressBook aBook = new JPimAddressBook(this , pBook, abID);
247:                return aBook;
248:            }
249:
250:            /**
251:             * Method to close a currently opened address book.
252:             *
253:             * @param ab    A specific address book.
254:             *
255:             * @exception ABStoreException if unable to close the specified calendar
256:             */
257:            public void closeAddressBook(AddressBook ab)
258:                    throws ABStoreException {
259:                ab = null;
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.