Hi,

 Accept my apologies beforehand if this question had been asked before. I 
searched the forums but I did not find anything on this subject.

 I am using JBoss Portal 2.6.2-GA with MySQL backend. 
I have a portlet where the logged in user can add/delete and assign roles.

Code snippet from my ServiceBean:


  | private void addUser(){
  |   UserTransaction ut = (UserTransaction) (new 
InitialContext().lookup("java:comp/UserTransaction"));
  |   ut.begin();
  |   ((UserModule) (new 
InitialContext().lookup("java:/portal/UserModule")).createUser(userDetails.getUser(),
 userDetails.getConfirmPassword());
  |   ut.commit();
  | }
  | 
  | private void setUserProperties(){
  |   UserModule userModule = (UserModule) (new InitialContext())
  |     .lookup("java:/portal/UserModule");
  |   UserTransaction ut = (UserTransaction) (new InitialContext()
  |     .lookup("java:comp/UserTransaction"));
  |   ut.begin();
  |   User user = userModule.findUserByUserName(userDetails.getUser());
  |   ((MembershipModule)(new 
InitialContext()).lookup("java:portal/MembershipModule")).assignRoles(user, 
getRoleModule().findRolesByNames(new String[]{USERROLE_USER, USERROLE_LOUNGE}));
  |   if (userDetails.isInternalUser()){
  |     ((MembershipModule)(new 
InitialContext()).lookup("java:portal/MembershipModule")).assignRoles(user, 
getRoleModule().findRolesByNames(new String[]{USERROLE_INTERNAL}));
  |   }
  | 
  |   UserProfileModule profileModule = (UserProfileModule) (new 
InitialContext()).lookup("java:/portal/UserProfileModule");
  |   profileModule.setProperty(user, User.INFO_USER_ENABLED, true);
  |   profileModule.setProperty(user, User.INFO_USER_EMAIL_REAL, 
userDetails.getEmail());
  |   profileModule.setProperty(user, User.INFO_USER_NAME_FAMILY, 
userDetails.getFamilyName());
  |   profileModule.setProperty(user, User.INFO_USER_NAME_GIVEN, 
userDetails.getGivenName());
  |   ut.commit(); 
  | }
  | 
  | public RoleModule getRoleModule() {
  |     try {
  |       return (RoleModule) (new InitialContext())
  |     .lookup("java:/portal/RoleModule");
  | 
  |     } catch.....
  | }

UserDetails userDetails is just a custom POJO.

User is created, but neither the roles nor the properties are assigned to.

Anybody with some suggestions why the roles and properties are not saved?

Thanks in advance!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136594#4136594

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136594
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to