[Building Sakai] Site Participants

Aaron Zeckoski aaronz at vt.edu
Sat Jun 13 00:11:37 PDT 2009


You should use the site service rather than trying to write into the
tables yourself.
http://bugs.sakaiproject.org/confluence/display/BOOT/Using+the+SiteService

If you want to add memeberships you should do something like this:
String userId = getCurrentUserId(); // or some other way of getting the userId
Site site;
try {
    site = siteService.getSite(siteId);
} catch (IdUnusedException e) {
    throw new IllegalArgumentException("Cannot find site by siteId: "
+ siteId +":"+e, e);
}
String roleId = site.getJoinerRole(); // or some other role
site.addMember(userId, roleId, true, false);
try {
    siteService.saveSiteMembership(site);
} catch (IdUnusedException e) {
    throw new IllegalArgumentException("Invalid site: " + site.getId()
+ ":" + e, e);
} catch (PermissionException e) {
    throw new SecurityException("Current user not allowed to update
site memberships in site: " + site.getId() + " :"+e, e);
}

Hope this helps.
-AZ


On Sat, Jun 13, 2009 at 7:50 AM, Nil Nitin<nil.nitin.sakai at gmail.com> wrote:
>
> hi,
>
>   I have created one scheduler which add participants to site, depending on
> certain condition. It makes entries into two tables
> 1) `sakai_site_user` and
> 2) `sakai_realm_rl_gr`
>
>  It fires dao.create(....) to insert data as we have to send PK with data
> object. I can see new rows in both tables after scheduler's job is finished.
> But when i login as a user, I cant see the new site. Also entries from both
> tables get removed automatically.
>
>  Can anyone have idea, why this is happening ?
>  Is anyone already implemented such thing like adding participants to site
> using scheduler after given date, etc. ?
>
> cheers,
> Nil
>
> --
> View this message in context: http://www.nabble.com/Site-Participants-tp24009698p24009698.html
> Sent from the Sakai - Development mailing list archive at Nabble.com.
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>



-- 
Aaron Zeckoski (azeckoski (at) vt.edu)
Senior Research Engineer - CARET - Cambridge University
https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
http://aaronz-sakai.blogspot.com/ -
http://confluence.sakaiproject.org/confluence/display/~aaronz/


More information about the sakai-dev mailing list