Source Code Cross Referenced for ABModifyTag.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.List;
016:        import java.util.ArrayList;
017:        import java.util.StringTokenizer;
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 ABModifyTag class executes the address book add command. 
026:         * 
027:         * Attributes needed: name, entryid
028:         *
029:         * @author Mihir Sambhus
030:         * @version 1.0
031:         */
032:        public class ABModifyTag extends ABBaseCommandTag {
033:
034:            // Create a logger for this class
035:            private static Logger debugLogger = PortalLogger
036:                    .getLogger(ABModifyTag.class);
037:
038:            /**
039:             * Execute the Modify Element from the address book command. 
040:             * Returns the command status.
041:             * If the command fails then the tag body is included,
042:             * Else if the command succeeds then the tag body is skipped.
043:             * 
044:             * @return true if the command succeeds.
045:             *         false if the command fails.
046:             * @exception JspException
047:             */
048:            public boolean execute() throws JspException {
049:
050:                // entryid attribute must be present for delete .. if not jsp
051:                //  exception is throw
052:                verifyEntryid();
053:
054:                // Get the new element bean that the user entered via <entry> tag to
055:                // replace the previous 
056:                Element elementNew = getElement();
057:
058:                if (!requiredPropertiesExist(elementNew)) {
059:                    return false;
060:                }
061:
062:                // Get the element object corresponsing to the entryid, from context
063:                Element elementOld = getEntry(Integer.parseInt(entryid));
064:
065:                // Get the contactDB object interacting with the Backend LDAP server
066:                ContactDB contactDB = getContactDB();
067:
068:                // perform modify command
069:                if (!contactDB.modifyElementFromABook(elementOld, elementNew)) {
070:                    debugLogger.fine("PSMA_CSPWTA0016");
071:                    getABContext().setErrorCode("");
072:                    return false;
073:                }
074:
075:                String addmembers = null;
076:                String members = null;
077:                // Get the group members if the element type is group
078:                if (elementNew.getElementType() == Element.GROUP) {
079:                    members = (String) elementNew.getProperty("members");
080:                    addmembers = (String) elementNew.getProperty("addmembers");
081:                }
082:
083:                // Either addmembers or members is present simultaneously .. If addmembers
084:                //  is present members list is ignored
085:                if ((addmembers != null) && (!addmembers.equals(""))) {
086:                    // Add all entries individually to the group using addGroupMember
087:                    StringTokenizer tok = new StringTokenizer(addmembers, ",");
088:                    while (tok.hasMoreTokens()) {
089:                        Element elemToAdd = getABContext().getMemberchoice(
090:                                Integer.parseInt(tok.nextToken()));
091:                        contactDB.addElementToGroup(elemToAdd,
092:                                (Group) elementOld);
093:                    }
094:                } else if ((members != null) && (!members.equals(""))) {
095:                    // Modify members list
096:                    // Figure out which entries are changed from the groupmembers collection
097:                    //  and delete members in the new list, and add new members found in 
098:                    //  the new list
099:
100:                    // Find out the intersection between the current groupmembers and the 
101:                    //  new members.. and separate it into delList and addList
102:                    ArrayList tmp = (ArrayList) getABContext()
103:                            .getGroupmembers();
104:                    List delList = (ArrayList) tmp.clone();
105:                    List addList = new ArrayList();
106:                    StringTokenizer tok = new StringTokenizer(members, ",");
107:                    while (tok.hasMoreTokens()) {
108:                        boolean found = false;
109:                        Element elemToChange = getABContext().getMemberchoice(
110:                                Integer.parseInt(tok.nextToken()));
111:                        // If element being changed is same as the current group being
112:                        //  changed .. then empty the delete list and dont add the element
113:                        //  being changed to the add list either
114:                        if (elemToChange.getUn().equals(elementOld.getUn())) {
115:                            found = true;
116:                            delList.removeAll(delList);
117:                        }
118:                        for (int i = 0; i < delList.size(); i++) {
119:                            Element e = (Element) delList.get(i);
120:                            if (elemToChange.getUn().equals(e.getUn())) {
121:                                // common element .. remove from the delList
122:                                delList.remove(i);
123:                                found = true;
124:                                break;
125:                            }
126:                        }
127:                        if (!found) {
128:                            // elemToChange is not found in the delList .. add it to the addList
129:                            addList.add(elemToChange);
130:                        }
131:                    }
132:
133:                    // Add all the elements from add list
134:                    for (int i = 0; i < addList.size(); i++) {
135:                        contactDB.addElementToGroup((Element) addList.get(i),
136:                                (Group) elementOld);
137:                    }
138:                    // Delete all elements from delete list
139:                    for (int i = 0; i < delList.size(); i++) {
140:                        contactDB.deleteElementFromGroup((Element) delList
141:                                .get(i), (Group) elementOld);
142:                    }
143:                }
144:                return true;
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.