[Building Sakai] user properties

Nkululeko Phakela nonkululeko.phakela at wits.ac.za
Mon Mar 26 06:48:18 PDT 2012


Hi Miguel,

I have used the userid instead of the eid, and it worked like a charm! 

Thank you very much.

Warm Regards,
Nguni


On Mon, 2012-03-26 at 12:18 +0200, Miguel Carro Pellicer wrote:
> Hi Nkululeko......................your code to save the preferences
> seems correct,  studentNumber may be the userId instead of externalId,
> maybe it works with Eid but i use ID, i can check this :)
> 
> To get the value use this example, its enough.
> 
> userid = userDirectoryService.getUserByEid(userid).getId(); //This can
> generate an exception, care :)
>             
>             Preferences preferences =
> preferencesService.getPreferences(userid);
>             ResourceProperties properties =
> preferences.getProperties();
> 
>             if( properties != null)
>                 ret = properties.getProperty(property);
> 
> 
> You don't need addUser method to save the property, commit method from
> preferencesService should do it.
> 
> Regards, Miguel. 
> 
> 
> 
> 
> El 26/03/2012 11:44, Nkululeko Phakela escribió: 
> > Hi All,
> > 
> > I want to save some properties for a user when adding them onto the
> > system. This is because I would like to know which slot and degree code
> > each student belongs to. This information has been required when
> > displaying student information to the lecturer. 
> > 
> > try {
> >     preferencesEdit = preferencesService.edit(studentNumber);
> > } catch (Exception ex) {
> >     preferencesEdit = preferencesService.add(studentNumber);
> > }
> > 
> > ResourcePropertiesEdit props = preferencesEdit.getPropertiesEdit();
> > props.addProperty("degreeCode", currentCalCode);
> > props.addProperty("slot", slot);
> > 
> > preferencesService.commit(preferencesEdit);
> > ResourceProperties properties =
> > preferencesService.getPreferences(studentNumber).getProperties(studentNumber);
> > 
> > 
> > To save the user, I am doing this:
> > userDirectoryService.addUser(null, userId, givenName, surname, email,
> > null, type, properties); 
> > 
> > 
> > What am I missing because now when I try to retrieve the properties, I
> > am getting null values. I am retrieving the values by doing this: 
> > 
> > ResourceProperties rp = user.getProperties();
> >                       
> > String slot = rp.getProperty("slot");
> > String degreeCode = rp.getProperty("degreeCode");
> > 
> > 
> > Kind Regards,
> 
> -- 
> cid:image001.jpg at 01C9F98A.71C74E60
> 
>  
> 
> Miguel Carro Pellicer
> 
> Technical Manager - Director técnico
> 
> miguel.carro at samoo.es
> 
> +34 - 673 80 32 69
> 
> www.samoo.es
> 
>  
> 
> Este  correo  y  sus archivos asociados son privados y confidenciales
> y va dirigido  exclusivamente  a su destinatario. Si recibe este
> correo sin ser el  destinatario del mismo, le rogamos proceda a su
> eliminación y lo ponga en  conocimiento del emisor. La difusión por
> cualquier medio del contenido de  este  correo podría ser sancionada
> conforme a lo previsto en las leyes españolas, Ley Orgánica 15/1999 de
> Protección de Datos de Carácter Personal.  No  se autoriza la
> utilización con fines comerciales o para su incorporación a ficheros
> automatizados de las direcciones del emisor o del destinatario.”
> 
>  
> 
> This mail and its attached files are confidential and are only and
> exclusively intended to their addressee. In case you may receive this
> mail not being its addressee, we beg you to let us know the error by
> reply and to proceed to destroy it. The circulation by any mean of
> this mail could be penalised in accordance with the Spanish
> legislation. Is not allowed the use of both, the transmitter and the
> addressee’s, address with a commercial aim, or in order to be
> incorporated to automated data process or to any kind of files. 
> 
>  
> 
> P Antes de imprimir este correo electrónico piense bien si es
> necesario hacerlo. El medioambiente es cosa de todos.
> 
>  
> 
>  
> 
> 
> _______________________________________________
> 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"

-- 
Nkululeko Phakela 
Software Developer 
011 717 7167 
eLearning Support and Innovation (eLSI) 
Witwatersrand University 
Braamfontein, Johannesburg
<html><p><font face = "verdana" size = "0.8" color = "navy">This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorized signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary.</font></p></html>



More information about the sakai-dev mailing list