2 Replies Latest reply on Mar 14, 2008 8:40 AM by herqpapa

    UserProfileModule.setProperty() not saved

    herqpapa

      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!