Importing Roster from other Type of System

Hello All,

I am tring to import rosters from my exiting system to Openfire.

using following code:

public void importUserFromOldSystem(String username) throws UserNotFoundException {

XMPPServer server = XMPPServer.getInstance();

RosterManager rosterManager = server.getRosterManager();

Roster roster=rosterManager.getRoster(username)

List<String> friends = ServiceLocatorForMessenger.friendListService().friendResults(username));{color: #808000}// By this I get Friends name from other server

for (Iterator iter = friends.iterator(); iter.hasNext():wink: {

String friend = (String);

Roster recipientRoster = rosterManager.getRoster(friend);

try {

JID friendJid = server.createJID(friend, null);



RosterItem forFriend = roster.createRosterItem(friendJid, friend, Arrays.asList(“OldSystem Friends”), true, true);

RosterItem forUser = recipientRoster.createRosterItem(server.createJID(username, null), username, Arrays.asList(“OldSystem Friends”), true, true);



roster.broadcast(forFriend, false);

recipientRoster.broadcast(forUser, false);


catch (Exception e) {




System.out.println(“Roster imported…”);


private void updateRosterItem(RosterItem item) {





By using this code I am able to import friends. But after this method call I am able to see these friend in my friendlist but they are showed as Not authrized. But when I login again with this id. I can see online friend as online and offline as offline. What I can do in this code so that they can shown online and offline after this method calls.