Source Code Cross Referenced for CMCUserImplBase.java in  » Portal » Open-Portal » com » sun » portal » community » mc » impl » am » 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.community.mc.impl.am 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: CMCUserImplBase.java,v 1.2 2007/01/26 03:47:48 portalbld Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.community.mc.impl.am;
014:
015:        import com.sun.portal.community.mc.CMCException;
016:        import com.sun.portal.community.mc.CMCPrincipal;
017:        import com.sun.portal.community.mc.CMCUser;
018:        import com.sun.portal.community.mc.CMCNode;
019:        import com.sun.portal.community.mc.ConfigTable;
020:        import com.sun.portal.community.mc.ConfigTable.ConfigKey;
021:        import com.sun.portal.community.mc.CMCRolePrincipal;
022:        import com.sun.portal.community.mc.impl.Debug;
023:        import com.sun.portal.community.mc.CMCFactory;
024:        import java.io.File;
025:        import java.util.HashSet;
026:        import java.util.Iterator;
027:        import java.util.Properties;
028:        import java.util.Set;
029:        import java.util.Collections;
030:        import com.iplanet.am.sdk.AMUser;
031:        import com.iplanet.am.sdk.AMRole;
032:        import com.iplanet.am.sdk.AMFilteredRole;
033:        import com.iplanet.am.sdk.AMOrganization;
034:        import com.iplanet.sso.SSOException;
035:        import com.iplanet.am.sdk.AMException;
036:        import com.iplanet.am.util.SystemProperties;
037:
038:        /**
039:         * AM community user contributor, base class
040:         *
041:         * This class is extended by all AM community user
042:         * contributors.
043:         */
044:        public abstract class CMCUserImplBase extends CMCImplBase implements 
045:                CMCUser {
046:            private String userId;
047:            private AMUser amUser;
048:
049:            public void init(Properties p, String userId) throws CMCException {
050:                this .userId = userId;
051:
052:                try {
053:                    amUser = adminConnection.getUser(getUserId());
054:                } catch (SSOException ssoe) {
055:                    throw new CMCException(ssoe);
056:                }
057:            }
058:
059:            protected AMUser getAMUser() {
060:                return amUser;
061:            }
062:
063:            public String getUserId() {
064:                return userId;
065:            }
066:
067:            public Set getMembership() throws CMCException {
068:                return getMembershipByName();
069:            }
070:
071:            public abstract Set getMembershipByName() throws CMCException;
072:
073:            public Set getMembershipByName(Set rolePrincipals)
074:                    throws CMCException {
075:                return getMembershipByName();
076:            }
077:
078:            public Set getMembershipByRole() throws CMCException {
079:                return Collections.EMPTY_SET;
080:            }
081:
082:            public Set getMembershipByRole(Set rolePrincipals)
083:                    throws CMCException {
084:                return getMembershipByRole();
085:            }
086:
087:            public abstract String getType();
088:
089:            public Set getMembership(Set rolePrincipals) throws CMCException {
090:                // one role
091:                return getMembership();
092:            }
093:
094:            public Set getAvailable() throws CMCException {
095:                // available is same as membership for AM
096:                Set available = new HashSet();
097:                for (Iterator i = getMembership().iterator(); i.hasNext();) {
098:                    ConfigKey ck = (ConfigKey) i.next();
099:                    available.add(ck.getCommunityPrincipal());
100:                }
101:
102:                return available;
103:            }
104:
105:            public boolean hasRole(CMCPrincipal cp, CMCRolePrincipal rp)
106:                    throws CMCException {
107:                ConfigKey ck = new ConfigKey(cp, rp);
108:                if (!getMembership().contains(ck)) {
109:                    return false;
110:                }
111:
112:                return true;
113:            }
114:
115:            public long getRoleCreationTime(CMCPrincipal cp,
116:                    CMCRolePrincipal rolePrincipal)
117:                    throws UnsupportedOperationException {
118:                throw new UnsupportedOperationException(
119:                        "not supported: RoleCreationTime");
120:            }
121:
122:            /**
123:             * Fill in the last read times for all values in the dps table.
124:             */
125:            protected static void fillLastReadTimes(ConfigTable lastReadTimes,
126:                    ConfigTable dps) {
127:                for (Iterator i = dps.getConfigKeys().iterator(); i.hasNext();) {
128:                    ConfigKey ck = (ConfigKey) i.next();
129:                    lastReadTimes.put(ck, new Long(System.currentTimeMillis()));
130:                }
131:            }
132:
133:            public ConfigTable getDPDocuments(ConfigTable lastReadTimes)
134:                    throws CMCException {
135:                Set membership = getMembership();
136:                return getDPDocuments(lastReadTimes, membership);
137:            }
138:
139:            public ConfigTable getDPDocuments(ConfigTable lastReadTimes,
140:                    Set membership) throws CMCException {
141:                ConfigTable dpDocuments = new ConfigTable();
142:
143:                for (Iterator i = membership.iterator(); i.hasNext();) {
144:                    ConfigKey ck = (ConfigKey) i.next();
145:                    CMCPrincipal cp = ck.getCommunityPrincipal();
146:                    if (!cp.getType().equals(getType())) {
147:                        // skip it if they pass something other than this type
148:                        continue;
149:                    }
150:                    CMCNode cn = CMCFactory.getInstance().getCMCNode(cp);
151:                    ConfigTable lastModifiedTimes = cn
152:                            .getDPDocumentsLastModified(Collections
153:                                    .singleton(CMCRolePrincipal.MEMBER_ROLE));
154:
155:                    //
156:                    // determine if we need to fetch the document
157:                    //
158:                    Long lastRead = (Long) lastReadTimes.get(ck);
159:                    if (lastRead != null && lastRead.longValue() != -1) {
160:                        //
161:                        // this means the client passed us a last read time
162:                        // if the last modified time is less than the
163:                        // last read time, the client already read the 
164:                        // most recent version, so do not return it to them
165:                        // again
166:                        //
167:                        Long lastModified = (Long) lastModifiedTimes.get(ck);
168:                        if (lastModified != null) {
169:                            long lm = lastModified.longValue();
170:                            long lr = lastRead.longValue();
171:                            if (lm <= lr) {
172:                                continue;
173:                            }
174:                        }
175:                    }
176:
177:                    ConfigTable ct = cn.getDPDocuments(Collections
178:                            .singleton(CMCRolePrincipal.MEMBER_ROLE));
179:                    dpDocuments.putAll(ct);
180:                }
181:
182:                fillLastReadTimes(lastReadTimes, dpDocuments);
183:                return dpDocuments;
184:            }
185:        }
w___ww_.__ja_v_a2__s___.___co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.