I am using jive messenger 2.1.4 as the messenger server and i am using the smack 1.5 libraries in my own system project.
I want to automatically create a user as well as add that user to a specific user group in jive messenger database when i create a user in my own system.
I have managed to create a user in the jive database by doing the following:
AccountManager accountManager = new AccountManager(Session.getInstance().getConnection());
String user = “testuser”;
Map<String, String> theMap = new HashMap<String, String>();
theMap.put(“name”, “Test User”);
accountManager.createAccount(user, “password”, theMap);
The above code creates a row in the jiveuser table successfully.
I am forced to now use the admin web application to add this user to a specific group and then once i have restarted the jive server i can then see the new user in my buddies listing in my own system view.
I have tried getting all entries as well as unfiled entries from the roster to get a RosterEntry object which i could put into the following line below:
Roster theRoster = Session.getInstance().getConnection().getRoster();
RosterGroup rosterGroup = theRoster.getGroup(“My Contacts”);
rosterEntry = * tried many different ways to get this object but have failed *
Ofcourse i cannot create a new RosterEntry object with my newly created user information as there is no constructor for it and i know that that cannot be the right way of doing it. My assumption was that if i create a user then it should at least be in the unfiled entries listing on the roster. I assumed then i could get that unfiled RosterEntry object by the newly created username and put that into the addEntry method as the object parameter but when i retrieve the unfiled entries listing it is empty.
I would really like an example or a link to documentation of the way to add this newly created user to a user group automatically from my java code and then without having to restart the jive server have the user reflected in the buddies list as well.
I have already added data to the user and usergroup tables and then restarted the jive server just as a test and it worked. So i am pretty confident that i only need 2 rows in the jive database for a user to be registered and filed under a usergroup. I also assume, once again, that if i call the reload method on the roster after doing whatever i have to do to add the user to the usergroup that i won’t have to restart the jive server. Is this correct?
Thanks and Regards