Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 10

...

PersonDirectory is implemented using Spring. Currently a Spring beans.dtd-compliant XML file named personDirectoryContext.xml declares the configuration of an instance of IPersonAttributeDao. The class PersonDirectory delegates to this Spring-configured IPersonAttributeDao instance to actually implement the PersonDirectory behavior. PersonDirectory uses PortalApplicationContextFacade to access the the uPortal Spring application context.

JDBC Example

The default personDirectoryContext.xml includes JDBC beans to retrieve attributes for local uPortal usres such as fragment owners.  Below is an example of merging in additional attributes via the PersonDb DataSource.   Configuration supports mapping a column to multiple uPortal attribute names and using DataSources other than those configured in RDBMServices.

Code Block
xml
xml

<bean id="myunivCachingPersonDbJdbcAttributeSource">
        <property name="usernameAttributeProvider" ref="usernameAttributeProvider" />
        <property name="cacheNullResults" value="true" />
        <property name="userInfoCache">
            <bean>
                <property name="cacheFactory" ref="cacheFactory" />
                <property name="cacheName"
                    value="org.jasig.services.persondir.USER_INFO.myuniv_person_dir" />
            </bean>
        </property>
        <property name="cacheKeyGenerator" ref="userAttributeCacheKeyGenerator" />
        <property name="cachedPersonAttributesDao">
            <bean class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">   >
                <constructor-arg index="0" ref="PersonDB" />
                <constructor-arg>
                    <value>
                        SELECT DISTINCT first_name||' '||Last_name first_last, role,
                        contentGroup, person_type, first_name, last_name, middle_name,
                        email_alias, college, class_year, student_status, alias,
                        work_phone, netid
                        FROM person_directory_view where {0}
                    </value>
                </constructor-arg>
                <property name="usernameAttributeProvider" ref="usernameAttributeProvider" />    
                <!-- Map the table fields to P3P attribute names -->
                <property name="queryAttributeMapping">
                    <map>
                        <entry key="displayName" value="FIRST_LAST" />
                        <entry key="sn" value="LAST_NAME" />
                        <entry key="contentGroup" value="CONTENT_GROUP" />
                        <entry key="mail" value="EMAIL_ALIAS" />
                        <entry key="givenName" value="FIRST_NAME" />
                        <entry key="alias" value="ALIAS" />
                        <entry key="personType" value="PERSON_TYPE" />
                        <entry key="College" value="COLLEGE" />
                        <entry key="ClassYear" value="CLASS_YEAR" />
                        <entry key="StudentStatus" value="STUDENT_STATUS" />
                        <entry key="username" value="NETID" />
                        <entry key="WorkPhone" value="WORK_PHONE" />
                    </map>
                </property>
                <!-- Map the table fields to P3P attribute names -->
                <property name="resultAttributeMapping">
                    <map>
                        <entry key="FIRST_LAST">
                            <value>displayName</value>
                        </entry>
                        <entry key="LAST_NAME">
                            <set>
                                <value>sn</value>
                                <value>user.name.family</value>
                            </set>
                        </entry>
                        <entry key="ROLE">
                            <value>uPortalAffiliation</value>
                        </entry>
                        <entry key="CONTENTGROUP">
                            <set>
                                <value>contentGroup</value>
                            </set>
                        </entry>
                        <entry key="EMAIL_ALIAS">
                            <set>
                                <value>mail</value>
                                <value>user.home-info.online.email</value>
                            </set>
                        </entry>
                        <entry key="FIRST_NAME">
                            <value>givenName</value>
                        </entry>
                        <entry key="ALIAS">
                            <value>alias</value>
                        </entry>
                        <entry key="PERSON_TYPE">
                            <value>personType</value>
                        </entry>
                        <entry key="COLLEGE">
                            <value>College</value>
                        </entry>
                        <entry key="CLASS_YEAR">
                            <value>ClassYear</value>
                        </entry>
                        <entry key="STUDENT_STATUS">
                            <value>StudentStatus</value>
                        </entry>
                        <entry key="NETID">
                            <set>
                                <value>uid</value>
                                <value>netid</value>
                                <value>username</value>
                                <value>eduPersonPrincipalName</value>
                                <value>user.login.id</value>
                            </set>
                        </entry>
                        <entry key="WORK_PHONE">
                            <value>WorkPhone</value>
                        </entry>
                    </map>
                </property>
            </bean>
        </property>
    </bean>

For more examples, visit the page dedicated to JdbcPersonAttributeDaoImpl.

...

Warning
titleNot Recommended

Although not recommended it is possible to change the class name in the personDirectory.xml beans declaration to be a custom class of your choice, so long as it implements IPersonAttributeDao. You could then write a custom implementation that does exactly the queries, caching, and any other behavior you need.
<beans>
<!-- notice that the bean's class has changed - ->
<bean id="personAttributeDao">
<!-- if you're implementing all your configuration directly in the Java, you need not
add any properties here -->
</bean>
</beans>