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


001:        /*
002:         * Copyright 2005 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */
013:        package com.sun.portal.community.mc.test.impl.file.dynamic;
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.ConfigTable;
019:        import com.sun.portal.community.mc.ConfigTable.ConfigKey;
020:        import com.sun.portal.community.mc.CMCRolePrincipal;
021:        import com.sun.portal.community.mc.impl.Debug;
022:        import java.io.File;
023:        import java.util.HashSet;
024:        import java.util.Iterator;
025:
026:        import java.util.Properties;
027:        import java.util.Set;
028:        import java.util.Collections;
029:
030:        public class CMCUserImpl extends CMCImpl implements  CMCUser {
031:            private String userId = null;
032:
033:            public static String getStaticType() {
034:                return "filedynamic";
035:            }
036:
037:            public String getType() {
038:                return getStaticType();
039:            }
040:
041:            public void init(Properties p, String userId) throws CMCException {
042:                this .userId = userId;
043:                super .init(p);
044:            }
045:
046:            public String getUserId() {
047:                return userId;
048:            }
049:
050:            public Set getMembership() throws CMCException {
051:                return getMembership(CMCRolePrincipal.ALL_ROLES);
052:            }
053:
054:            public Set getMembership(Set rolePrincipals) throws CMCException {
055:                Set byName = getMembershipByName(rolePrincipals);
056:                //System.out.println("byName=" + byName);
057:                Set byRole = getMembershipByRole(rolePrincipals);
058:                //System.out.println("byRole=" + byRole);
059:
060:                Set all = byName;
061:                all.addAll(byRole);
062:
063:                return all;
064:            }
065:
066:            public Set getMembershipByName() throws CMCException {
067:                return getMembershipByName(CMCRolePrincipal.ALL_ROLES);
068:            }
069:
070:            public Set getMembershipByName(Set rolePrincipals)
071:                    throws CMCException {
072:                Set principals = new HashSet();
073:                File[] files = new File(getBaseDir())
074:                        .listFiles(propertiesFilter);
075:                for (int i = 0; i < files.length; i++) {
076:                    Properties p = getCommunityProperties(files[i]);
077:                    // get roles for user
078:                    Set roles = getRolesFromProperties(p,
079:                            getUserKey(getUserId()));
080:                    // filter out unspecified roles
081:                    roles.retainAll(rolePrincipals);
082:
083:                    for (Iterator j = roles.iterator(); j.hasNext();) {
084:                        CMCPrincipal cp = getCommunityPrincipalFromFile(files[i]);
085:                        CMCRolePrincipal rp = (CMCRolePrincipal) j.next();
086:                        ConfigKey ck = new ConfigKey(cp, rp);
087:                        principals.add(ck);
088:                    }
089:                }
090:
091:                return principals;
092:            }
093:
094:            public Set getMembershipByRole() throws CMCException {
095:                return getMembershipByRole(CMCRolePrincipal.ALL_ROLES);
096:            }
097:
098:            public Set getMembershipByRole(Set rolePrincipals)
099:                    throws CMCException {
100:                Set principals = new HashSet();
101:                File[] files = new File(getBaseDir())
102:                        .listFiles(propertiesFilter);
103:                for (int i = 0; i < files.length; i++) {
104:                    Properties p = getCommunityProperties(files[i]);
105:                    // get roles for user
106:                    Set roles = getRolesFromProperties(p, getRoleKey());
107:                    // filter out unspecified roles
108:                    roles.retainAll(rolePrincipals);
109:
110:                    for (Iterator j = roles.iterator(); j.hasNext();) {
111:                        CMCPrincipal cp = getCommunityPrincipalFromFile(files[i]);
112:                        CMCRolePrincipal rp = (CMCRolePrincipal) j.next();
113:                        ConfigKey ck = new ConfigKey(cp, rp);
114:                        principals.add(ck);
115:                    }
116:                }
117:
118:                principals = filterMembership(principals, getMembershipByName());
119:                return principals;
120:            }
121:
122:            private Set filterMembership(Set m1, Set m2) throws CMCException {
123:                Set f = new HashSet();
124:                for (Iterator i = m1.iterator(); i.hasNext();) {
125:                    ConfigKey ck1 = (ConfigKey) i.next();
126:                    for (Iterator j = m2.iterator(); j.hasNext();) {
127:                        ConfigKey ck2 = (ConfigKey) j.next();
128:                        if (ck1.getCommunityPrincipal().equals(
129:                                ck2.getCommunityPrincipal())) {
130:                            f.add(ck1);
131:                        }
132:                    }
133:                }
134:
135:                return f;
136:            }
137:
138:            public Set getAvailable() throws CMCException {
139:                //
140:                // 1. loop through all *.properties files
141:                // 2. get names, chop off .properties. those are cty names
142:                // 3. for each name, add type to construct a cty principal
143:
144:                Set available = new HashSet();
145:
146:                File[] files = new File(getBaseDir())
147:                        .listFiles(propertiesFilter);
148:                for (int i = 0; i < files.length; i++) {
149:                    System.out.println("files[" + i + "]=" + files[i]);
150:                    CMCPrincipal cp = getCommunityPrincipalFromFile(files[i]);
151:                    available.add(cp);
152:                }
153:
154:                return available;
155:
156:            }
157:
158:            public boolean hasRole(CMCPrincipal cp, CMCRolePrincipal rp)
159:                    throws CMCException {
160:                Properties p = getCommunityProperties(cp);
161:                Set roles = getRolesFromProperties(p, getUserKey(getUserId()));
162:                roles.addAll(getRolesFromProperties(p, getRoleKey()));
163:                if (roles.contains(rp)) {
164:                    return true;
165:                }
166:
167:                return false;
168:            }
169:
170:            public ConfigTable getDPDocuments(ConfigTable lastReadTimes,
171:                    Set membership) throws CMCException {
172:                ConfigTable ct = new ConfigTable();
173:                for (Iterator i = membership.iterator(); i.hasNext();) {
174:                    ConfigKey ck = (ConfigKey) i.next();
175:                    File dpFile = getDPFile(ck);
176:                    if (dpFile.exists()
177:                            && dpFileModified(lastReadTimes, ck, dpFile)) {
178:                        byte[] dp = readDP(dpFile);
179:                        ct.put(ck, dp);
180:                        updateLastRead(lastReadTimes, ck);
181:                    }
182:                }
183:
184:                return ct;
185:            }
186:
187:            public ConfigTable getDPDocuments(ConfigTable lastReadTimes)
188:                    throws CMCException {
189:                Set membership = getMembership();
190:                return getDPDocuments(lastReadTimes, membership);
191:            }
192:
193:            public long getRoleCreationTime(CMCPrincipal cp,
194:                    CMCRolePrincipal rolePrincipal)
195:                    throws UnsupportedOperationException {
196:                throw new UnsupportedOperationException(
197:                        "not supported: RoleCreationTime");
198:            }
199:
200:        }
ww___w___.___jav___a___2s.c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.