Skip to Content.
Sympa Menu

grouper-users - RE: [grouper-users] composite value for the description attribute of person subjects?

Subject: Grouper Users - Open Discussion List

List archive

RE: [grouper-users] composite value for the description attribute of person subjects?

Chronological Thread 
  • From: Chris Hyzer <>
  • To: "" <>, "" <>
  • Subject: RE: [grouper-users] composite value for the description attribute of person subjects?
  • Date: Tue, 16 Feb 2010 11:49:26 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

I agree it sounds like an interesting idea of something we could add to
Grouper. In the meantime, here is an alternative to Gary's solution. Here
is a way to extend your source to add the attribute. Just compile this
class, and refer to it in the sources.xml instead of the one you have (if the
one you have in sources.xml isn't GrouperJndiSourceAdapter, you can extend
that one instead). If you need help compiling this or whatnot, let me know.
Note, I think the JNDI source doesn't get the attributes unless they are
needed, this one would get them with each Subject returned. Also, if you are
using WS, it would be available.

(btw, I didn't test this :) ).


* @author mchyzer
* $Id$
package edu.internet2.middleware.grouper.poc;

import java.util.Set;

import org.apache.commons.lang.StringUtils;

import edu.internet2.middleware.grouper.subj.GrouperJndiSourceAdapter;
import edu.internet2.middleware.grouper.util.GrouperUtil;
import edu.internet2.middleware.subject.Subject;
import edu.internet2.middleware.subject.SubjectNotFoundException;
import edu.internet2.middleware.subject.SubjectNotUniqueException;

public class MyJndiSource extends GrouperJndiSourceAdapter {

public MyJndiSource() {

* @param id
* @param name
public MyJndiSource(String id, String name) {
super(id, name);


* @param subject
private static void initSubject(Subject subject) {
if (subject != null) {
if (StringUtils.isBlank(subject.getAttributeValue("somethingNew"))) {
String newAttribute = subject.getAttributeValue("this") + ","
+ subject.getAttributeValue("that") + ", " +

* @see
public Subject getSubject(String id1, boolean exceptionIfNull)
throws SubjectNotFoundException, SubjectNotUniqueException {
Subject subject = super.getSubject(id1, exceptionIfNull);
return subject;

* @see
public Subject getSubjectByIdentifier(String id1, boolean exceptionIfNull)
throws SubjectNotFoundException, SubjectNotUniqueException {
Subject subject = super.getSubjectByIdentifier(id1, exceptionIfNull);
return subject;

* @see
public Set<Subject> search(String searchValue) {
Set<Subject> subjects =;
for (Subject subject : GrouperUtil.nonNull(subjects)) {
return subjects;


-----Original Message-----
From: Dominique Petitpierre

Sent: Tuesday, February 16, 2010 10:30 AM

Subject: [grouper-users] composite value for the description attribute of
person subjects?


On the Grouper Wiki I noticed that some sites display a composite
value for each person subject members of a group, e.g.

Michael Christopher Hyzer (chyzer, 12345678) Pennpay, Staff

This is very informative and helps group managers to avoid confusion
between homonyms.

It is possible to construct a "description" attribute from many source
fields with a SQL query when the JDBC source adapter is used, but I
did not find a simple way to configure Grouper to do this when using
the JNDI source adapter, and adding a new attribute on the LDAP side
is not a practical option.

This was discussed on grouper-users some time ago in the following
thread (item 3.):

Chris Hyzer <

| Or we could make a change request to allow multiple fields in this
| config or the one...

and "GW Brown, Information Systems and Computing" <

| Rather than add UI configuration through, having
| 'virtual attributes' in the Subject API may be preferable so that
| any Subject API client can use the same mechanism to combine
| attributes.

It would be a useful feature for sites that use the JNDI source
adapter for the Subject API.

- Has this been done? I.e. is there a way to specify a composite value
for the description attribute when using the JNDI source adapter?

Not finding a way to configure it I followed the advice to modify the
JSP code for the Admin UI (and the java code for the new Lite UI), to
display the "name" and "subjectId" Grouper attributes in addition to
the "description" attribute:

diff grouper-ui-1.5.1/webapp/WEB-INF/jsp/subjectView.jsp{.01,}
< /></c:if><c:if test="${empty inLink}"><span class="<c:out
value="${viewObject[mediaMap[attrKey]]}" /><c:if test="${empty
> /></c:if><c:if test="${empty inLink}"><span class="<c:out
> value="${viewObject.subjectType}"/>Subject"></c:if><c:if
> test="${viewObject.subjectType=='person'}"><c:out
> value="${viewObject['description']} (${viewObject['name']},
> ${viewObject['subjectId']})" /></c:if><c:if
> test="${viewObject.subjectType!='person'}"><c:out
> value="${viewObject[mediaMap[attrKey]]}" /></c:if><c:if test="${empty
> inLink}"></span></c:if>

This displays the person subjects in the Admin UI as
description (name, subjectId)
Michael Christopher Hyzer (chyzer, 12345678)

< label = subject.getDescription();
> if ("person".equals(subject.getType().getName())) {
> label = subject.getDescription() + " (" + subject.getName() + ")";
> } else {
> label = subject.getDescription();
> }

and this displays the person subjects in the Lite UI as
description (name)
Michael Christopher Hyzer (chyzer)

- Is this workaround reasonable? (i.e. will it work in all cases and
not break anything)?

- Should "webapp/WEB-INF/jsp/subjectSearchResultView.jsp" also be
modified? (It does not seem to be used anywhere.)

Currently this workaround is limited to use only the three Grouper
attributes defined in the subject API source.xml configuration file
(SubjectID_AttributeType, Name_AttributeType,

- Is there a way to use the other attributes declared in source.xml
(e.g <attribute>employeeType</attribute>) in this JSP or java code?

In any case, modifying source code instead of configuring in
properties or xml files might not be very stable across releases and I
hope that the feature discussed above will be available!

Best regards,
Mr Dominique Petitpierre, Dominique.Petitpierre(at)
Division Informatique, University of Geneva, Switzerland

Archive powered by MHonArc 2.6.16.

Top of Page