[Building Sakai] Retrieving current user from session
Steve Swinsburg
steve.swinsburg at gmail.com
Wed Jul 23 16:19:12 PDT 2014
The issue is your dependency injection. Either use spring to inject the
dependency or use the component manager to pull the dependency in.
What is your code for setting the saki api's?
Cheers
Steve
sent from my mobile device
On 23/07/2014 9:01 AM, "Sergio Muriel" <sergioame at hotmail.com> wrote:
> Dear Sam,
> I'm having a org.sakaiproject.user.api.User object, but when I fetch it
> into, like this:
>
> User currentUser = userDirectoryService.getCurrentUser();
> System.out.println("*** User.getFirstName(): " +
> currentUser.getFirstName());
> System.out.println("*** User.getDisplayId(): " +
> currentUser.getDisplayId());
> System.out.println("*** User.getDisplayName(): " +
> currentUser.getDisplayName());
> System.out.println("*** User.getEid(): " + currentUser.getEid());
> System.out.println("*** User.getEmail(): " + currentUser.getEmail());
> System.out.println("*** User.getFirstName(): " +
> currentUser.getFirstName());
> System.out.println("*** User.getId(): " + currentUser.getId());
> System.out.println("*** User.getLastName(): " + currentUser.getLastName());
> System.out.println("*** User.getSortName(): " + currentUser.getSortName());
> System.out.println("*** User.getType(): " + currentUser.getType());
> System.out.println("*** User.getUrl(): " + currentUser.getUrl());
>
> I get:
>
> *** User.getFirstName():
> *** User.getDisplayId(): null
> *** User.getDisplayName(): null
> *** User.getEid(): null
> *** User.getEmail():
> *** User.getFirstName():
> *** User.getId():
> *** User.getLastName():
> *** User.getSortName(): null
> *** User.getType(): null
> *** User.getUrl(): http://localhost:8080/access/user
>
> And this is actually the information that I have in the database:
>
>
> USER_ID;EMAIL;EMAIL_LC;FIRST_NAME;LAST_NAME;TYPE;PW;CREATEDBY;MODIFIEDBY;CREATEDON;MODIFIEDON
> 849c5404-47ea-418e-bb6e-3a7ca8d760b6;sergioame at hotmail dot
> com;sergioame at hotmail dot com;Sergio;Muriel;Web Services
> Accessor;cceylQ==:hNIh42AwPO6m39+Ucnp+BvJgBhEm/jt1hf9OWUiOBoU=;admin;admin;2014-05-06
> 16:42:38;2014-05-06 16:42:38
>
> And this is actually what Sakai shows me:
> My Account DetailsUserUser Idsergioame at hotmail dot comFirst NameSergioLast
> NameMurielEmailsergioame at hotmail dot comTypeWeb Services AccessorCreated
> BySakai AdministratorCreatedMay 6, 2014 4:42 pmModified BySakai
> AdministratorModifiedMay 6, 2014 4:42 pm
>
> Do you have any clue about what could be going on with that object? I'm
> testing it using the same browser but different tabs: One for logging into
> Sakai, and the other for calls the web service. Am I doing it right?
>
> I appreciate any help.
>
>
>
> Best Regards,
> Sergio Muriel
>
>
>
> ------------------------------
> From: ottenhoff at longsight.com
> Date: Tue, 22 Jul 2014 16:51:16 -0400
> Subject: Re: [Building Sakai] Retrieving current user from session
> To: sergioame at hotmail.com
> CC: sakai-dev at collab.sakaiproject.org
>
> /**
> * Get a user's email address based on their session id
> *
> * @param sessionid the session id of the user who's email address
> you wish to retrieve
> * @return the email address for the user
> * @throws AxisFault
> *
> */
> public String getUserEmailForSession( String sessionid ) throws AxisFault
> {
> Session session = establishSession(sessionid);
> User user = userDirectoryService.getCurrentUser();
> return user.getEmail();
> }
>
>
>
> On Tue, Jul 22, 2014 at 4:44 PM, Sergio Muriel <sergioame at hotmail.com>
> wrote:
>
> Dear All,
> Does anyone have a good working example of a web service in which the
> current user is retrieved from the current session?
> Please note that what I need to retrieve is an object of the class:
> org.sakaiproject.user.api.User
>
> Best Regards,
> Sergio Muriel
>
>
> _______________________________________________
> 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"
>
>
>
> _______________________________________________
> 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/20140724/a35617f2/attachment.html
More information about the sakai-dev
mailing list