fragment audience resolution
fragment audience resolution
the dlm.xml allows you create conditions used to resolve the target audience of a fragment. in other words, when to display the "tab". there are a number of factors to consider when creating these conditions, but one that came up during our implmentation required us to reconfigure uportal to reference an additional jndi datasource outside the typical ldap or rdbm default.
below are the steps that we took to create this configuration.
- added jndi datasource to uPortal55.xml
<Resource name="jdbc/ourNewAudResolutionDb" auth="Container" type="javax.sql.DataSource" username="@ourNewAud001jdbcUser@" password="@ourNewAud001jdbcPassword@" driverClassName="@ourNewAud001jdbcDriver@" url="@ourNewAud001jdbcUrl@" maxActive="100" maxIdle="30" maxWait="10000" poolPreparedStatements="@poolPreparedStatements@" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true" />
- added jndi attribute mappings to rdbm.properties
ourNewAud001jdbcDriver=oracle.jdbc.driver.OracleDriver ourNewAud001jdbcUrl=jdbc:oracle:thin:@ourNewHostDb:1521:ourNewHostSid ourNewAud001jdbcUser=ourNewDbUid ourNewAud001jdbcPassword=ourNewDbPsw
- changed personDirectory.xml to support merged attributes
<bean id="personAttributeDao" class="org.jasig.portal.services.persondir.support.CachingPersonAttributeDaoImpl"> <property name="cachedPersonAttributesDao"> <ref bean="mergedAttributes"/> </property> </bean> <bean id="mergedAttributes" class="org.jasig.portal.services.persondir.support.MergingPersonAttributeDaoImpl"> <property name="personAttributeDaos"> <list> <ref bean="uPortalLdapAttributeSource"/> <ref bean="ourNewAudJdbcAttributeSource"/> </list> </property> </bean>
- added our new audience datasource bean details to personDirectory.xml
<bean id="ourNewAudJdbcAttributeSource" class="org.jasig.portal.services.persondir.support.JdbcPersonAttributeDaoImpl"> <constructor-arg> <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="staticMethod"> <value>org.jasig.portal.RDBMServices.getDataSource</value> </property> <property name="arguments"> <list><value>ourNewAudResolutionDb</value></list> </property> </bean> </constructor-arg> <constructor-arg> <list> <value>username</value> </list> </constructor-arg> <constructor-arg> <value>select count(uid) as is_new_aud_user from ourNewAudTable where uid=?</value> </constructor-arg> <property name="columnsToAttributes"> <map> <entry key="is_new_aud_user"> <value>isNewAudUser</value> </entry> </map> </property> </bean>
- added audience resolution condition to dlm.xml (referencing the person attribute created above)
<dlm:fragment name='frg-our-new-fragment' ownerID='our-new-fragment-lo' precedence='10'> <dlm:audience evaluatorFactory='org.jasig.portal.layout.dlm.providers.PersonEvaluatorFactory'> <paren mode="AND"> <paren mode="NOT"> <attribute name="username" mode='equals' value='guest-usr'/> </paren> <paren mode="NOT"> <attribute name="isNewAudUser" mode='equals' value='0'/> </paren> </paren> </dlm:audience> </dlm:fragment>