On Friday 15 August 2008 21:54, batosai at freenetproject.org wrote:
> Author: batosai
> Date: 2008-08-15 20:54:27 +0000 (Fri, 15 Aug 2008)
> New Revision: 21922
>
> Modified:
> trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
> Log:
> Handle context choice on FCP requests.
>
> Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
> ===================================================================
> --- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-15 20:54:01 UTC
(rev 21921)
> +++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-15 20:54:27 UTC
(rev 21922)
> @@ -345,16 +345,17 @@
>
> SimpleFieldSet sfs = new SimpleFieldSet(false);
>
> - if(params.get("TreeOwner") == null || params.get("Select") ==
> null) throw
new InvalidParameterException("Missing mandatory parameter");
> + if(params.get("TreeOwner") == null || params.get("Select") ==
> null ||
params.get("Context") == null) throw new InvalidParameterException("Missing
mandatory parameter");
>
> sfs.putAppend("Message", "Identities");
> -
> - // TODO Add context selection
>
> ObjectSet<Score> result =
wot.getIdentitiesByScore(params.get("TreeOwner"),
params.get("Select").trim());
> - for(int i = 1 ; result.hasNext() ; i++)
> - sfs.putAppend("Identity"+i,
result.next().getTarget().getRequestURI().toString());
> -
> + for(int i = 1 ; result.hasNext() ; i++) {
> + Score score = result.next();
> + // Maybe there is a way to do this through SODA
> + if(score.getTarget().hasContext(params.get("Context"))
> ||
params.get("Context").equals("all"))
> + sfs.putAppend("Identity"+i,
score.getTarget().getRequestURI().toString());
> + }
> return sfs;
> }
Yes. There is an example in section 5.2.3 of the tutorial (doc/tutorial in the
source). However, that's assuming you're using an array. If you have to look
for it in a list, it may be more difficult. You might try with Native Queries
but I doubt that it would be any more efficient than the above.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080822/d6824b9e/attachment.pgp>