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

Manuel Pérez manuelpg07 at gmail.com
Fri Jan 15 15:00:31 PST 2010


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);
//ADD SOME INSTRUCTION HERE TO DO THE INITIAL LOGIN AND BE ABLE TO GET THE
USER'S MYWORKSPACE

Regarding the gradebook, when I use the API to remove the gradebook I get
exceptions because the foreign keys and it won't let me delete the gradebook
.

greetings
Manuel Perez

El 15 de enero de 2010 23:33, Steve Swinsburg
<steve.swinsburg at gmail.com>escribió:

> Hi Manuel,
>
> Do you mean that you want to create the My Workspace site for the user you
> just created, or that you don't want one created at all? My Workspace sites
> are created/recreated when a user first log's in. I am not sure if its
> possible to stop this but there has been a similar discussion in the past.
> I'll find it for you if that is what you need.
>
> For the gradebook question, you can use the gradebook API's to remove a
> gradebook.
>
> cheers,
> Steve
>
> On 16/01/2010, at 6:41 AM, Manuel Pérez wrote:
>
> Hello everyone,
>
> will discuss with you the situation, first the code:
>
> // authenticate with the admin user to obtain the necessary permissions
>         // to create test data
>         UsageSessionService.startSession("admin", "127.0.0.1",
> "Voice-Agent");
>
>         // set the user information into the current session
>         Session sakaiSession = SessionManager.getCurrentSession();
>         sakaiSession.setUserId("admin");
>         sakaiSession.setUserEid("admin");
>
>         // update the user's externally provided realm definitions
>         AuthzGroupService.refreshUser("admin");
>
>         // create an student user
>         try {
>             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);
>         } catch (UserIdInvalidException e) {
>             throw new OSIDUnitTestException(e.getMessage());
>         } catch (UserAlreadyDefinedException e) {
>             // User already created
>         } catch (UserPermissionException e) {
>             throw new OSIDUnitTestException(e.getMessage());
>         }
>
>         // create one site and add the user.
>         try {
>             if (!SiteService.siteExists("testsite1")) {
>
>                 Site site1 = SiteService.addSite("testsite1", "course");
>
>                 // site information
>                 site1.setDescription("test description");
>                 site1.setPublished(true);
>                 site1.setPubView(false);
>                 site1.setShortDescription("test short description");
>                 site1.setTitle("Test Site 1");
>                 site1.setType("course");
>                 // add roles
>                 try {
>                     site1.addRole("Instructor");
>                 } catch (RoleAlreadyDefinedException ralde) {
>                 }
>                 try {
>                     site1.addRole("Student");
>                 } catch (RoleAlreadyDefinedException ralde) {
>                 }
>
>                 // add members to site
>                 site1.addMember("teststudent1", "Student", true, false);
>                 SiteService.saveSiteMembership(site1);
>
>                 SiteService.save(site1);
>             }
>         } catch (IdInvalidException e) {
>             throw new OSIDUnitTestException(e.getMessage());
>         } catch (IdUsedException e) {
>             // Site already created
>         } catch (PermissionException e) {
>             throw new OSIDUnitTestException(e.getMessage());
>         } catch (IdUnusedException e) {
>             throw new OSIDUnitTestException(e.getMessage());
>         }
>
>
> and the problem is this, that somehow need, from high code also give that
> user the MyWorkspace added, however with this code is not discharged until
> this fall, but I'm not okay, is that be from code and have tried to make
> the authentication from code or start a new session with
> UsageSessionService, but nothing, so if anyone has any ideas would be very
> grateful. This code is for some tests so having to do so.
>
> Another thing, if anyone knows, how do you do to delete a gradebook from
> code without modification of the database that you prevent this? FOREING
> kinds of KEYS.
>
> A greeting and thank you very much in advance for any response,
> Manuel Pérez
> Universidad de Oviedo
>
> _______________________________________________
> 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"
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100116/5fce737b/attachment.html 


More information about the sakai-dev mailing list