[Building Sakai] how to add user property into table sakai_user_property

Diego del Blanco Orobitg diego.delblanco at samoo.es
Thu Oct 6 00:05:53 PDT 2011


You can use the PreferencesEdit, PreferencesService and
ResourcePropertiesEdit

 

This is a way. To do it.

 

 

               PreferencesEdit preferences = null;

               try {

                       preferences = preferencesService.edit(userId);

               } catch (Exception e1) {

                       preferences = preferencesService.add(userId);

               }

               ResourcePropertiesEdit props =
preferences.getPropertiesEdit();

               props.addProperty(key, value);

               preferencesService.commit(preferences);               

 

 

you will need these imports:

 

import org.sakaiproject.entity.api.ResourcePropertiesEdit;
import org.sakaiproject.user.api.PreferencesService;
import org.sakaiproject.user.api.PreferencesEdit;
import org.sakaiproject.component.cover.ComponentManager;

 

 

and create this before in your class

 

private PreferencesService preferencesService = null;
preferencesService = (PreferencesService)
ComponentManager.get(PreferencesService.class.getName());
 
“Saludos” from Spain
 

Diego del Blanco Orobitg

Director de operaciones

diego.delblanco at samoo.es

Tlf: 963 936 915 - 653 683 489

www.samoo.es

 

 

 

 

 

De: sakai-dev-bounces at collab.sakaiproject.org
[mailto:sakai-dev-bounces at collab.sakaiproject.org] En nombre de
swwangl at tsmc.com
Enviado el: jueves, 06 de octubre de 2011 6:10
Para: sakai-dev at collab.sakaiproject.org
Asunto: [Building Sakai] how to add user property into table
sakai_user_property

 

Anyone could tell me how to insert a record into sakai_user_property?

This code can not write into table..
user.getProperties().addPropertyToList(id, "Y");

Thanks a lot


TSMC PROPERTY This email communication (and any attachments) is proprietary
information for the sole use of its intended recipient. Any unauthorized
review, use or distribution by anyone other than the intended recipient is
strictly prohibited. If you are not the intended recipient, please notify
the sender by replying to this email, and then delete this email and any
copies of it immediately. Thank you.

  _____  

No se encontraron virus en este mensaje.
Comprobado por AVG - www.avg.com
Versión: 10.0.1410 / Base de datos de virus: 1520/3939 - Fecha de
publicación: 10/05/11

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111006/9bf4ad51/attachment.html 


More information about the sakai-dev mailing list