* @param queue the <code>RequestQueue</code> to add agents to.
* @param agents a comma-delimited list of agents.
*/
public static void addAgents(RequestQueue queue, String agents) {
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
AgentManager agentManager = workgroupManager.getAgentManager();
// loop thru all params
StringTokenizer tokenizer = new StringTokenizer(agents, ", \t\n\r\f");
while (tokenizer.hasMoreTokens()) {
String usernameToken = tokenizer.nextToken();
if (usernameToken.indexOf('@') != -1) {
usernameToken = JID.escapeNode(usernameToken);
}
try {
// See if they are a user in the system.
UserManager.getInstance().getUser(usernameToken);
usernameToken += ("@" + ComponentManagerFactory.getComponentManager().getServerName());
JID address = new JID(usernameToken.trim());
Agent agent;
if (agentManager.hasAgent(address)) {
agent = agentManager.getAgent(address);
}
else {
agent = agentManager.createAgent(address);
}
queue.addMember(agent);
}
catch (Exception e) {
Log.error(e.getMessage(), e);