3 Replies Latest reply on Aug 31, 2010 7:05 PM by Art Munro

    How can i register user with my own portlet?

    Bertram Beyer Newbie

      Hello,

       

      i want to write my own user management portlets but i don't know how to add, edit or delete portal users.

      Is there a service api or something like that which i can use?

       

      regards

        • 1. Re: How can i register user with my own portlet?
          JCE Developer Newbie

          Hi, Bertram. Here is example from my registration portlet. I've just started to learn this problem too.

           

          1. OrganizationService service = (OrganizationService) PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class);
          2. .................
          3. String userid = request.getParameter(FIELD_ID);
          4. if (service.getUserProfileHandler().findUserProfileByName(userid) != null)
          5.   throw new SFMException(1, userid + " exists!");
          6. UserImpl newuser = new UserImpl(userid);
          7. newuser.setFirstName(request.getParameter(FIELD_NAME));
          8. newuser.setLastName(request.getParameter(FIELD_LASTNAME));
          9. newuser.setEmail(request.getParameter(FIELD_EMAIL));
          10. newuser.setPassword(request.getParameter(FIELD_PASSWORD));
          11. Group group = service.getGroupHandler().findGroupById("/platform/users");
          12. MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType("member");
          13. service.getUserHandler().createUser(newuser, false);
          14. service.getMembershipHandler().linkMembership(newuser, group, membershipType, false);
          15. UserProfile profile = service.getUserProfileHandler().createUserProfileInstance(userid);
          16. profile.setAttribute("position", request.getParameter(FIELD_POSITION));
          17. profile.setAttribute("phone", request.getParameter(FIELD_PHONE));
          18. service.getUserProfileHandler().saveUserProfile(profile, false);
          • 2. Re: How can i register user with my own portlet?
            Bertram Beyer Newbie

            Hi Aslan,

            that's a good start.

            Thanks a lot.

            • 3. Re: How can i register user with my own portlet?
              Art Munro Novice

              Folks

               

              Was wondering if you were able to complete your quest with setting profile?

               

              specifically do you know were I can find list of Attributes?

              example ... profile.setAttribute("position",

               

              please see my posting at .. http://community.jboss.org/message/559907

               

              thanks,

              Art