Source Code Cross Referenced for PersonDirectory.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » services » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001, 2004 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.services;
007:
008:        import java.util.ArrayList;
009:        import java.util.HashSet;
010:        import java.util.Hashtable;
011:        import java.util.Iterator;
012:        import java.util.Map;
013:        import java.util.Set;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:        import org.jasig.portal.security.IPerson;
018:        import org.jasig.portal.security.PersonFactory;
019:        import org.jasig.portal.security.provider.RestrictedPerson;
020:        import org.jasig.portal.services.persondir.IPersonAttributeDao;
021:        import org.jasig.portal.spring.PortalApplicationContextFacade;
022:        import org.springframework.beans.factory.BeanFactory;
023:
024:        /**
025:         * PersonDirectory is a static lookup mechanism for a singleton instance of 
026:         * IPersonAttributeDao.  It is configurable via a
027:         * Spring beans.dtd compliant configuration file in the properties directory
028:         * called personDirectory.xml (as referenced by applicationContext.xml -
029:         * that is, you could choose to declare the underlying IPersonAttributesDao
030:         * backing your PersonDirectory directly in applicationContext.xml, 
031:         * or elsewhere. PersonDirectory looks for an IPersonAttributeDao instance 
032:         * named 'personAttributeDao'.
033:         * 
034:         * This class serves as the lookup mechanism for clients to obtain a reference
035:         * to the singleton IPersonAttributeDao instance.  Via legacy methods, 
036:         * PersonDirectory also serves as the interface by which client
037:         * code accesses user attributes.  These deprecated legacy methods are a facade
038:         * to the PersonAttributeDao.
039:         * 
040:         * The default configuration of that file implements the legacy behavior of using
041:         * the PersonDirs.xml file for configuration.  It is expected that PersonDirs.xml
042:         * offers the flexibility necessary to support most uPortal installations.
043:         * 
044:         * @author Howard Gilbert
045:         * @author andrew.petro@yale.edu
046:         * @author Eric Dalquist <a href="mailto:edalquist@unicon.net">edalquist@unicon.net</a>
047:         * @version $Revision: 35513 $ $Date: 2005-04-06 08:19:32 -0700 (Wed, 06 Apr 2005) $
048:         */
049:        public class PersonDirectory {
050:
051:            private static final String PADAO_BEAN_NAME = "personAttributeDao";
052:            private static final Log log = LogFactory
053:                    .getLog(PersonDirectory.class);
054:
055:            /**
056:             * This instance variable used to contain the set of attributes mapped in
057:             * PersonDir.xml.  It now is merely an empty Set.  It is no longer used by
058:             * PersonDirectory and should be removed in a future release.
059:             * 
060:             * @deprecated you cannot get the list of attributes in the abstract, only
061:             * for a particular user.
062:             */
063:            public static HashSet propertynames = new HashSet();
064:
065:            /** Singleton reference to PersonDirectory */
066:            private static PersonDirectory instance;
067:
068:            /** Wrapped class which provides the functionality */
069:            private IPersonAttributeDao impl;
070:
071:            /**
072:             * Private constructor to allow for singleton behavior.
073:             * 
074:             * @param impl The {@link IPersonAttributeDao} instance to wrap.
075:             */
076:            private PersonDirectory(IPersonAttributeDao impl) {
077:                this .impl = impl;
078:            }
079:
080:            /**
081:             * Static lookup for a the configured {@link IPersonAttributeDao}
082:             * implementation available from PortalApplicationContextFacade.
083:             * 
084:             * @return The PortalApplicationContextFacade configured {@link IPersonAttributeDao} implementation.
085:             * @throws IllegalStateException - if PortalApplicationContextFacade does not
086:             * supply the IPersonAttributeDao instance.
087:             */
088:            public static IPersonAttributeDao getPersonAttributeDao() {
089:                final BeanFactory factory = PortalApplicationContextFacade
090:                        .getPortalApplicationContext();
091:
092:                final IPersonAttributeDao delegate = (IPersonAttributeDao) factory
093:                        .getBean(PADAO_BEAN_NAME, IPersonAttributeDao.class);
094:
095:                if (delegate == null)
096:                    throw new IllegalStateException(
097:                            "PortalAppicationContextFacade "
098:                                    + "config did not declare a bean named '"
099:                                    + PADAO_BEAN_NAME + "'.");
100:
101:                return delegate;
102:            }
103:
104:            /**
105:             * Obtain the singleton instance of PersonDirectory.
106:             * 
107:             * @return the singleton instance of PersonDirectory.
108:             * @deprecated Use {@link #getPersonAttributeDao()}
109:             */
110:            public static synchronized PersonDirectory instance() {
111:                if (instance == null) {
112:                    try {
113:                        instance = new PersonDirectory(getPersonAttributeDao());
114:                    } catch (Throwable t) {
115:                        log.error("Error instantiating PersonDirectory", t);
116:                    }
117:                }
118:
119:                return instance;
120:            }
121:
122:            /**
123:             * This method returns an iterator over the names of attributes. The
124:             * method behavior is not well defined because attribute sources may choose
125:             * to return different attributes depending upon about whom they are asked.
126:             * Therefore, you can only know the attributes for particular users, not the
127:             * namespace of all possible attributes.
128:             * 
129:             * @return an iterator over the attribute names declared by the underlying
130:             * IPersonAttributeDao instance, if any.
131:             * @deprecated Use {@link IPersonAttributeDao#getPossibleUserAttributeNames()}
132:             */
133:            public static Iterator getPropertyNamesIterator() {
134:                final Set attrNames = getPersonAttributeDao()
135:                        .getPossibleUserAttributeNames();
136:
137:                if (attrNames != null)
138:                    return attrNames.iterator();
139:                else
140:                    return (new ArrayList()).iterator();
141:            }
142:
143:            /**
144:             * Returns a reference to a restricted IPerson represented by the supplied
145:             * user ID. The restricted IPerson allows access to person attributes, but
146:             * not the security context.
147:             * 
148:             * @param uid the user ID
149:             * @return the corresponding person, restricted so that its security context is inaccessible
150:             * @deprecated Use {@link PersonFactory#createRestrictedPerson()} and
151:             * {@link IPersonAttributeDao#getUserAttributes(String)} and
152:             * {@link RestrictedPerson#setAttributes(Map)}
153:             */
154:            public static RestrictedPerson getRestrictedPerson(final String uid) {
155:                final RestrictedPerson rp = PersonFactory
156:                        .createRestrictedPerson();
157:                final Map attributes = instance().impl.getUserAttributes(uid);
158:
159:                rp.setAttributes(attributes);
160:
161:                return rp;
162:            }
163:
164:            /**
165:             * Obtain a HashTable of attributes for the given user.
166:             * 
167:             * @param username the name of the user
168:             * @return a Hashtable from user names to attributes.
169:             * @deprecated Use {@link IPersonAttributeDao#getUserAttributes(String)}
170:             */
171:            public Hashtable getUserDirectoryInformation(String username) {
172:                final Map attrs = this .impl.getUserAttributes(username);
173:                return new Hashtable(attrs);
174:            }
175:
176:            /**
177:             * Populate an IPerson with the attributes from the user directory for the
178:             * given uid.
179:             * 
180:             * @param uid person for whom we are obtaining attributes
181:             * @param person person object into which to store the attributes
182:             * @deprecated Use {@link IPersonAttributeDao#getUserAttributes(String)} and
183:             * {@link IPerson#setAttributes(Map)}
184:             */
185:            public void getUserDirectoryInformation(String uid, IPerson person) {
186:                final Map attrs = this.impl.getUserAttributes(uid);
187:                person.setAttributes(attrs);
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.