Skip to Content.
Sympa Menu

grouper-users - RE: [grouper-users] identifierAttributes in sources.xml

Subject: Grouper Users - Open Discussion List

List archive

RE: [grouper-users] identifierAttributes in sources.xml


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Scott Koranda <>, "" <>
  • Subject: RE: [grouper-users] identifierAttributes in sources.xml
  • Date: Mon, 10 Sep 2012 17:43:01 +0000
  • Accept-language: en-US

Yes, I am back now, and yes, I spaced this request, sorry :).

https://bugs.internet2.edu/jira/browse/GRP-844

I was able to reproduce your problem, and committed a fix in grouper 2.1
branch. This is a problem for people using the JDBC1 source adapter, with
more than 1 identifier, when searching by the non-first identifier. There is
a tweak required in the subject API (I can send you a jar if you want), move
a close curly bracket:

JDBCSourceAdapter.java

FROM:

}

//if we made it this far there is a problem
throw new InvalidQueryException("Why is this subject not able
to be " +
"referenced by id or identifier (do you need to add " +
"identifierAttributes to your sources.xml???) " +
SubjectUtils.subjectToString(subject) );
}

}

}
} catch (SQLException ex) {
throw new SourceUnavailableException("SQLException occurred: " +
ex.getMessage() + ": " + sql, ex);
}

TO:

}

}

//if we made it this far there is a problem
throw new InvalidQueryException("Why is this subject not able to
be " +
"referenced by id or identifier (do you need to add " +
"identifierAttributes to your sources.xml???) " +
SubjectUtils.subjectToString(subject) );

}

}
} catch (SQLException ex) {
throw new SourceUnavailableException("SQLException occurred: " +
ex.getMessage() + ": " + sql, ex);
}


Here is what I did to reproduce:

I took grouper 2.1 (generally 2.1.2), and changed the sources.xml to add
another identifier col (in this case the name, but it doesn't really matter)

<init-param>
<param-name>identifierAttributes</param-name>
<param-value>LOGINID,LFNAME</param-value>
</init-param>


<search>
<searchType>searchSubjectByIdentifier</searchType>
<param>
<param-name>sql</param-name>
<param-value>
select
s.subjectid as id, s.name as name,
(select sa2.value from subjectattribute sa2 where name='name' and
sa2.SUBJECTID = s.subjectid) as lfname,
(select sa3.value from subjectattribute sa3 where name='loginid' and
sa3.SUBJECTID = s.subjectid) as loginid,
(select sa4.value from subjectattribute sa4 where name='description' and
sa4.SUBJECTID = s.subjectid) as description,
(select sa5.value from subjectattribute sa5 where name='email' and
sa5.SUBJECTID = s.subjectid) as email
from
subject s, subjectattribute a, subjectattribute b
where
a.name='loginid' and s.subjectid = a.subjectid and b.name='name' and
s.subjectid = b.subjectid and {inclause}
</param-value>
</param>
<param>
<param-name>inclause</param-name>
<param-value>
a.value = ? or b.value = ?
</param-value>
</param>
</search>

Then I did some searches by one identifier or the other:

Subject subject =
SubjectFinder.findByIdentifierAndSource("id.test.subject.0", "jdbc", true);
System.out.println(GrouperUtil.subjectToString(subject));

subject = SubjectFinder.findByIdentifierAndSource("name.test.subject.0",
"jdbc", true);
System.out.println(GrouperUtil.subjectToString(subject));

It worked fine, here is the query from p6spy:

select
s.subjectid as id, s.name as name,
(select sa2.value from subjectattribute sa2 where name='name' and
sa2.SUBJECTID = s.subjectid) as lfname,
(select sa3.value from subjectattribute sa3 where name='loginid' and
sa3.SUBJECTID = s.subjectid) as loginid,
(select sa4.value from subjectattribute sa4 where name='description' and
sa4.SUBJECTID = s.subjectid) as description,
(select sa5.value from subjectattribute sa5 where name='email' and
sa5.SUBJECTID = s.subjectid) as email
from
subject s, subjectattribute a, subjectattribute b
where
a.name='loginid' and s.subjectid = a.subjectid and b.name='name' and
s.subjectid = b.subjectid and ( ( a.value = 'id.test.subject.0' or b.value
= 'id.test.subject.0' ) )


-----Original Message-----
From: Scott Koranda
[mailto:]

Sent: Monday, September 10, 2012 11:03 AM
To: Chris Hyzer
Subject: Fwd: [grouper-users] identifierAttributes in sources.xml

Hi,

If you are still on vacation, please disregard....

If not, have you had a chance to look at this?

Cheers,

Scott


---------- Forwarded message ----------
From: Scott Koranda
<>
Date: Sat, Sep 1, 2012 at 8:13 PM
Subject: Re: [grouper-users] identifierAttributes in sources.xml
To: Chris Hyzer
<>
Cc: grouper-users
<>


Hi,

> So, you configure your attributes based on columns. Some of
> the attributes need to be used as "identifiers" in the
> findByIdentifier queries. e.g. your netId, or eppn would be
> identifiers. Generally everything except the opaque ID. So
> you comma separate those attributes which are identifiers in
> the value of the XML element. ok? :)
>

Thanks. I understand but I am having trouble getting it
working.

I am using the Grouper API 2.1.2.

I have identifierAttributes defined in sources.xml as

<init-param>
<param-name>identifierAttributes</param-name>
<param-value>loginid1,loginid2,loginid3,loginid4,loginid5</param-value>
</init-param>

and I have this search defined:

<searchType>searchSubjectByIdentifier</searchType>
<param>
<param-name>sql</param-name>
<param-value>
SELECT

id,name,lfname,description,loginid1,loginid2,loginid3,loginid4,loginid5,email1,email2,email3,email4,email5
FROM
cm_grouper_subjects
WHERE
{inclause}
</param-value>
</param>
<param>
<param-name>inclause</param-name>
<param-value>
((loginid1 = ?) OR (loginid2 = ?) OR (loginid3 = ?) OR (loginid4 = ?)
OR (loginid5 = ?))
</param-value>
</param>
</search>
<search>

Consider the subject with id = 3:

gsh 1% s = findSubject("3")
subject: id='3' type='person' source='jdbc' name='Albert Lazzarini'
gsh 2% s.getAttributes()
edu.internet2.middleware.subject.SubjectCaseInsensitiveMapImpl:
{lfname=[Lazzarini,Albert],
loginid1=[],
loginid2=[],
loginid3=[],
loginid4=[], loginid5=[],
email1=[],
email2=[],
email3=[],
email4=[], email5=[]}

I can find the subject using loginid1:

gsh 3%
findSubject("")
subject: id='3' type='person' source='jdbc' name='Albert Lazzarini'

I cannot, however, find the subject using loginid2:

gsh 4%
findSubject("")
// Error: unable to evaluate command: Sourced file: inline
evaluation of:

``findSubject("");''
: Error
invoking compiled command: : Error in compiled command:
edu.internet2.middleware.subject.InvalidQueryException: Why
is this subject not able to be referenced by id or
identifier (do you need to add identifierAttributes to your
sources.xml???) Subject id: 3, sourceId: jdbc

What have I done wrong?

Thanks,

Scott



Archive powered by MHonArc 2.6.16.

Top of Page