[security-dev] Picketlink 3 IDM - Counting of query results

Darran Lofthouse darran.lofthouse at jboss.com
Thu Dec 6 04:25:25 EST 2012


Just a +1 from me to say we need this kind of thing - especially as this 
is not just user accounts we could quite easily find ourselves in a 
situation where we have huge numbers of accounts to display.

On 12/05/2012 10:21 PM, Shane Bryzak wrote:
> On 12/06/2012 08:09 AM, Marek Posolda wrote:
>> Hi all,
>>
>> I have possible request for API change and hope it's not too late for
>> first IDM iteration.
>>
>> My suggestion is to have method on class IdentityStore with signature like:
>>
>> int countQueryResults(Map<QueryParameter,Object> parameters);
>>
>> in addition to current:
>>
>> List<IdentityType> fetchQueryResults(Map<QueryParameter,Object> parameters);
>>
>>
>> Example use-case could be: give me count of all users with first name "John"
>>
>> My motivation is, that for proper pagination support (searching
>> use-cases), you usually need to know total number of pages (records) and
>> then show searching results only from first page. Then user can browse
>> between pages (if more than one page is available). Something like
>> www.google.com is doing :-) Also we need to support this in GateIn portal.
>>
>> Note that having this method is redundant at first look, as you can
>> always obtain same results with: fetchQueryResults(queryParams).size()
>> But then we are obviously losing performance. For example in JPA (DB)
>> it's way more performant to call DB query like: select count(id) from
>> users;
>> instead of: select * from users;
>>
>> Also to properly support this, we may also need additional method on
>> IdentityQuery with signature like:
>>
>> int getResultCount();
>
> I have no problem adding this.
>
>>
>>
>>
>> Also with respect to IdentityQuery, I am not sure how are information
>> about offset and limit propagated to IdentityStore? For example I have:
>> IdentityQuery query = IdentityManager().<User> createQuery(User.class);
>> query.setParameter(User.FIRST_NAME, "John");
>> query.setOffset(0);
>> query.setLimit(10);
>> query.getResultList();
>>
>> Calling of "getResultList" on last line will invoke
>> "fetchQueryResults(queryParams)" of configured IdentityStore. But how is
>> ensured that result from IdentityStore will return only first 10 records
>> as requested? So I think we can either:
>>
>> a) Change signature of method on IdentityStore to be:
>>
>> List<IdentityType> fetchQueryResults(Map<QueryParameter,Object>
>> parameters, int offset, int limit);
>
> We should probably just support this:
>
> List<IdentityType> fetchQueryResults(IdentityQuery query);
>
>
>
>>
>>
>> b) Add QueryParameters for pagination support, which will be sent to
>> IdentityStore. Maybe we can have something like this on IdentityQuery
>> class:
>>
>> QueryParameter OFFSET = new QueryParameter() {};
>>
>> QueryParameter LIMIT = new QueryParameter() {};
>>
>> And something like this on DefaultIdentityQuery class:
>>
>>        @Override
>>        public IdentityQuery<T> setOffset(int offset) {
>>            parameters.put(IdentityQuery.OFFSET, offset);
>>            return this;
>>        }
>>
>>        @Override
>>        public IdentityQuery<T> setLimit(int limit) {
>>            parameters.put(IdentityQuery.LIMIT, limit);
>>            return this;
>>        }
>>
>> Currently I am not seeing any query parameters for pagination in codebase.
>>
>> WDYT?
>> Marek
>>
>> _______________________________________________
>> security-dev mailing list
>> security-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/security-dev
>
> _______________________________________________
> security-dev mailing list
> security-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/security-dev
>


More information about the security-dev mailing list