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


001:        /*
002:         * %W% %G% Sun Microsystems
003:         *
004:         * Copyright 2000 Sun Microsystems, Inc.  All rights reserved.
005:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
006:         */
007:
008:        package com.sun.portal.wireless.taglibs.ab;
009:
010:        import javax.servlet.jsp.*;
011:        import javax.servlet.jsp.tagext.*;
012:        import com.sun.portal.wireless.taglibs.base.*;
013:        import com.sun.portal.log.common.PortalLogger;
014:
015:        import java.util.StringTokenizer;
016:        import java.util.List;
017:        import java.util.logging.Level;
018:        import java.util.logging.Logger;
019:
020:        import com.sun.addressbook.Entry;
021:        import com.sun.addressbook.Group;
022:        import com.sun.addressbook.Element;
023:
024:        /**
025:         * The ABAddTag class executes the address book add command. 
026:         * 
027:         * Attributes needed: name
028:         *
029:         * @author Mihir Sambhus
030:         * @version 1.0
031:         */
032:        public class ABAddTag extends ABBaseCommandTag {
033:
034:            /**
035:             * Execute the Add Element command on the Address Book. 
036:             * Returns the command status.
037:             * If the command fails then the tag body is included,
038:             * Else if the command succeeds then the tag body is skipped.
039:             * 
040:             * @return true if the command succeeds.
041:             *         false if the command fails.
042:             * @exception JspException
043:             */
044:
045:            // Create a logger for this class
046:            private static Logger debugLogger = PortalLogger
047:                    .getLogger(ABAddTag.class);
048:
049:            public boolean execute() throws JspException {
050:
051:                // Get the new element bean that the user entered via <entry> tag to add 
052:                Element element = getElement();
053:
054:                // The Entry bean has to have Last name property filled
055:                if (!requiredPropertiesExist(element)) {
056:                    return false;
057:                }
058:
059:                // Get the contactDB object interacting with the Backend LDAP server
060:                ContactDB contactDB = getContactDB();
061:
062:                // perform the add command
063:                // If group, do the uniqueness check based on the name of the group
064:                if (element.getElementType() == Element.GROUP) {
065:                    Entry searchEntry = new Entry();
066:                    searchEntry.setCn(element.getCn());
067:                    searchEntry.setElementType(Element.GROUP);
068:                    // Workaround for quirk in Lotus Notes .. doesnt refresh without folder
069:                    //  refresh in same session
070:                    contactDB.refreshAB();
071:                    List elements = contactDB.searchABook(searchEntry, null,
072:                            null, null, null, true);
073:
074:                    if ((elements == null) || (elements.size() > 0)) {
075:                        debugLogger.fine("PSMA_CSPWTA0004");
076:                        getABContext().setErrorCode("AB_003"); // AB_003 = Group name not uniq
077:                        return false;
078:                    }
079:                }
080:
081:                if (!contactDB.addElementToABook(element)) {
082:                    debugLogger.fine("PSMA_CSPWTA0005");
083:                    getABContext().setErrorCode("");
084:                    return false;
085:                }
086:
087:                String members = null;
088:                // Get the group members if the element type is group
089:                if (element.getElementType() == Element.GROUP) {
090:                    members = (String) element.getProperty("members");
091:                    if (members == null) {
092:                        members = (String) element.getProperty("addmembers");
093:                    }
094:                }
095:                if (members != null) {
096:                    // Search the address book to get the un for the group that just added. 
097:                    Entry searchEntry = new Entry();
098:                    searchEntry.setCn(element.getCn());
099:                    searchEntry.setElementType(Element.GROUP);
100:                    // Workaround for quirk in Lotus Notes .. doesnt refresh without folder
101:                    //  refresh
102:                    contactDB.refreshAB();
103:                    List elements = contactDB.searchABook(searchEntry, null,
104:                            null, null, null, true);
105:
106:                    if ((elements == null) || (elements.size() != 1)) {
107:                        debugLogger.fine("PSMA_CSPWTA0005");
108:                        getABContext().setErrorCode("");
109:                        return false;
110:                    }
111:                    Group group = (Group) elements.get(0);
112:                    if (group.getElementType() != Element.GROUP) {
113:                        debugLogger.fine("PSMA_CSPWTA0005");
114:                        getABContext().setErrorCode("");
115:                        return false;
116:                    }
117:
118:                    // Add all entries individually to the group using addGroupMember
119:                    StringTokenizer tok = new StringTokenizer(members, ",");
120:                    while (tok.hasMoreTokens()) {
121:                        Element elemToAdd = getABContext().getMemberchoice(
122:                                Integer.parseInt(tok.nextToken()));
123:                        contactDB.addElementToGroup(elemToAdd, group);
124:                    }
125:                }
126:                return true;
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.