[Building Sakai] How to enable a user MyWorkspace from code?

Matthew Buckett matthew.buckett at oucs.ox.ac.uk
Mon Jan 18 02:35:14 PST 2010


2010/1/15 Manuel Pérez <manuelpg07 at gmail.com>:
> Hi Steve, thanks for your reply,
>
> What I need is that once I created the user, as next step create MyWorkspace
> for that user. The problem is that I don´t know that statement used to make
> the initial login. I need a set of instructions that generate the user
> MyWorkspace once it is created.
>
> UserEdit ue = UserDirectoryService.addUser("
> teststudent1", "teststudent1");
>             ue.setEmail("test at student1.es");
>             ue.setFirstName("test1");
>             ue.setLastName("student1");
>             ue.setPassword("sakai");
>             ue.setType("user");
>             UserDirectoryService.commitEdit(ue);

You just need to switch to be acting as the newly created user and the
attempt to get the new users MyWorkspace. Somthing like this:

 Session sakaiSession = SessionManager.getCurrentSession();
 sakaiSession.setUserId(ue.getId());
 sakaiSession.setUserEid(ue.getEid());
 String userSiteId = SiteService.getUserSiteId(ue.getId());
 // This should create the new user site and return it.
 Site userSite = SiteService.getSite(userSiteId);


-- 
  Matthew Buckett
  VLE Developer, LTG, Oxford University Computing Services


More information about the sakai-dev mailing list