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


001:        package com.sun.addressbook.wabp;
002:
003:        import com.sun.addressbook.ABStoreException;
004:        import com.sun.addressbook.ABSession;
005:        import com.sun.addressbook.ABStore;
006:        import com.sun.addressbook.AddressBook;
007:        import com.sun.addressbook.MissingPropertiesException;
008:        import com.sun.addressbook.OperationNotSupportedException;
009:        import com.sun.addressbook.ABLogger;
010:
011:        import com.iplanet.iabs.wabpc.WABPClientPStore;
012:        import com.iplanet.iabs.iabsapi.Book;
013:        import com.iplanet.iabs.iabsapi.PStoreException;
014:
015:        import java.util.logging.Logger;
016:        import java.util.logging.Level;
017:
018:        public class WabpABStore extends ABStore {
019:
020:            // wabp address book server store
021:            private WABPClientPStore wabpStore = null;
022:
023:            // wabp address book connection settings
024:            private String host = null;
025:            private String port = null;
026:            private String protocol = null;
027:            private String user = null;
028:            private String password = null;
029:            private String contextURI = null;
030:            private String serverURL = null;
031:            private String enableProxyAuth = null;
032:            private String proxyAdminUid = null;
033:            private String proxyAdminPassword = null;
034:
035:            // used for debugging
036:            private static final String CLASSNAME = "WabpABStore";
037:
038:            // Create a Logger for this class
039:            private static Logger debugLogger = ABLogger
040:                    .getLogger("com.sun.portal.addressbook.wabp");
041:
042:            /*
043:             * Initializes and assigns ABStore properties.  In addition,
044:             * checks for missing properties, verifies property types,
045:             * and constructs the <code>serverURL</code>
046:             *
047:             * @throws MissingPropertiesException, ABStoreException
048:             */
049:            public void init(ABSession session)
050:                    throws MissingPropertiesException, ABStoreException {
051:
052:                // store session
053:                this .session = session;
054:
055:                // check for missing properties in the session
056:                host = session.getProperty("ab.host");
057:                checkForMissingProperty(session, "ab.host");
058:
059:                port = session.getProperty("ab.port");
060:                checkForMissingProperty(session, "ab.port");
061:                checkForIntegerProperty(port);
062:
063:                protocol = session.getProperty("ab.protocol");
064:                checkForMissingProperty(session, "ab.protocol");
065:
066:                user = session.getProperty("ab.userName");
067:                checkForMissingProperty(session, "ab.userName");
068:
069:                contextURI = session.getProperty("ab.contextURI");
070:                checkForMissingProperty(session, "ab.contextURI");
071:
072:                enableProxyAuth = session.getProperty("ab.enableProxyAuth");
073:
074:                //serverURL = protocol + "://" + host + ":" + port + "/" + contextURI;
075:                if (enableProxyAuth != null
076:                        && enableProxyAuth.equalsIgnoreCase("true")) {
077:                    proxyAdminUid = session.getProperty("ab.proxyAdminUid");
078:                    checkForMissingProperty(session, "ab.proxyAdminUid");
079:                    proxyAdminPassword = session
080:                            .getProperty("ab.proxyAdminPassword");
081:                    checkForMissingProperty(session, "ab.proxyAdminPassword");
082:                } else {
083:                    password = session.getProperty("ab.userPassword");
084:                    checkForMissingProperty(session, "ab.userPassword");
085:                }
086:                serverURL = protocol + "://" + host + ":" + port + "/"
087:                        + contextURI;
088:                debugLogger.log(Level.FINER, "PSJA_CSAW0003", user);
089:
090:            }
091:
092:            /*
093:             * Establishes a connection to the Address Book server.
094:             *
095:             * @throws ABStoreException
096:             */
097:            public void connect() throws ABStoreException {
098:
099:                try {
100:                    debugLogger.log(Level.FINER, "PSJA_CSAW0004", new String[] {
101:                            user, serverURL });
102:                    if (enableProxyAuth != null
103:                            && enableProxyAuth.equalsIgnoreCase("true")) {
104:                        wabpStore = new WABPClientPStore(serverURL,
105:                                proxyAdminUid, proxyAdminPassword, user);
106:                    } else {
107:                        wabpStore = new WABPClientPStore(serverURL, user,
108:                                password);
109:                    }
110:                } catch (PStoreException pe) {
111:                    throw new ABStoreException(CLASSNAME
112:                            + " connection failed for " + user + " at "
113:                            + serverURL + " : " + pe);
114:                }
115:                debugLogger.log(Level.FINER, "PSJA_CSAW0005", user);
116:            }
117:
118:            /*
119:             * Terminates the Address Book Server connection.
120:             *
121:             * @throws ABStoreException
122:             */
123:            public void disconnect() throws ABStoreException {
124:
125:                try {
126:                    debugLogger.log(Level.FINER, "PSJA_CSAW0006", user);
127:                    wabpStore.disconnect();
128:                    wabpStore = null;
129:                    debugLogger.log(Level.FINER, "PSJA_CSAW0007", user);
130:                } catch (PStoreException pe) {
131:                    throw new ABStoreException(CLASSNAME
132:                            + " connection termination " + "failed : " + pe);
133:                }
134:
135:            }
136:
137:            /*
138:             * Checks if the connection to the store object is still valid.
139:             *
140:             * @throws ABStoreException
141:             */
142:            public boolean isConnected() throws ABStoreException {
143:                // TODO.  no equivalent in Address Book Server Client API
144:                debugLogger.log(Level.FINER, "PSJA_CSAW0008", user);
145:                if (wabpStore == null) {
146:                    return false;
147:                }
148:                return true;
149:            }
150:
151:            /*
152:             * Retrieve a list of all the user's address book id's.
153:             *
154:             * @return array of user's address book ids
155:             */
156:            public String[] getAddressBooks() throws ABStoreException,
157:                    OperationNotSupportedException {
158:
159:                String[] list = null;
160:
161:                try {
162:                    Book[] books = wabpStore.listBooks(Book.BOOKTYPE_ABOOK);
163:
164:                    int count = books.length;
165:                    list = new String[count];
166:
167:                    for (int i = 0; i < count; i++) {
168:                        String id = books[i].getEntryID();
169:
170:                        if (id != null) {
171:                            list[i] = id;
172:                            debugLogger.log(Level.FINER, "PSJA_CSAW0009",
173:                                    new String[] { user, id });
174:                        }
175:                    }
176:
177:                } catch (PStoreException pe) {
178:                    throw new ABStoreException(CLASSNAME
179:                            + " getAddressBooks() failed: " + pe);
180:                }
181:
182:                return list;
183:            }
184:
185:            /*
186:             * Retrieve the user's default address book id.
187:             *
188:             * @return the user's default address book id.
189:             */
190:            protected String getDefaultAbID() throws ABStoreException {
191:                String id = null;
192:
193:                try {
194:                    Book book = wabpStore.getDefaultBook(Book.BOOKTYPE_ABOOK);
195:                    id = book.getEntryID();
196:                } catch (PStoreException pe) {
197:                    throw new ABStoreException(CLASSNAME
198:                            + " getDefaultAbID() failed: " + pe);
199:                }
200:
201:                debugLogger.log(Level.FINER, "PSJA_CSAW0010", new String[] {
202:                        user, id });
203:                return id;
204:            }
205:
206:            /*
207:             * Retrieve an address book 
208:             *
209:             * @return the address book specified by abID
210:             */
211:            public AddressBook openAddressBook(String abID)
212:                    throws ABStoreException {
213:                debugLogger.log(Level.FINER, "PSJA_CSAW0011", new String[] {
214:                        user, abID });
215:                return new WabpAddressBook(this , abID);
216:
217:            }
218:
219:            // TODO: NEED TO IMPLEMENT
220:            public void closeAddressBook(AddressBook ab)
221:                    throws ABStoreException {
222:                debugLogger.log(Level.FINER, "PSJA_CSAW0009", new String[] {
223:                        user, ab.getAbID() });
224:            }
225:
226:            /*
227:             * This method checks to see if the property is null, if it is
228:             * then it throws a MissingPropertiesException 
229:             * 
230:             * @throws MissingPropertiesException
231:             */
232:            protected void checkForMissingProperty(ABSession session,
233:                    String propertyName) throws MissingPropertiesException {
234:
235:                String property = session.getProperty(propertyName);
236:
237:                if (property == null) {
238:                    String msg = CLASSNAME
239:                            + " setup failed, missing property: "
240:                            + propertyName;
241:                    throw new MissingPropertiesException(msg);
242:                }
243:            }
244:
245:            /*
246:             * This method checks to see if the property is an Integer, if it
247:             * is not then it throws a MissingPropertiesException 
248:             * 
249:             * @throws MissingPropertiesException
250:             */
251:            protected void checkForIntegerProperty(String property)
252:                    throws MissingPropertiesException {
253:
254:                try {
255:                    Integer.parseInt(property);
256:
257:                } catch (Exception e) {
258:                    String msg = CLASSNAME
259:                            + " setup failed, property is not an integer: "
260:                            + property;
261:                    throw new MissingPropertiesException(msg);
262:                }
263:            }
264:
265:            /*
266:             * Get the WABPPClientPStore object
267:             */
268:            protected WABPClientPStore getWABPClientPStore() {
269:                return wabpStore;
270:            }
271:
272:            /*
273:             * Get the WabpABStore user
274:             */
275:            protected String getStoreUser() {
276:                return user;
277:            }
278:
279:            /*
280:             * Test method for junit
281:             *  @return userid string for comparison to verify login
282:             */
283:            String getUserString() throws PStoreException {
284:                return getWABPClientPStore().getUserPrefs()
285:                        .getElementsByTagName("userid").item(0).getFirstChild()
286:                        .getNodeValue();
287:            }
288:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.