use of org.jivesoftware.openfire.fastpath.dataforms.FormManager in project Openfire by igniterealtime.
the class WorkgroupUtils method createWorkgroup.
/**
* Create a new Workgroup.
*
* @param workgroupName the name of the workgroup.
* @param description the description of the workgroup.
* @param agents the agents, in a comma delimited string.
* @return a map of errors (if any)
*/
public static Map<String, String> createWorkgroup(String workgroupName, String description, String agents) {
Map<String, String> errors = new HashMap<String, String>();
// Get a workgroup manager
WorkgroupManager wgManager = WorkgroupManager.getInstance();
if (wgManager == null) {
errors.put("general_error", "The server is down");
return errors;
}
String defaultQueueName = "Default Queue";
// Validate
if (workgroupName == null) {
errors.put("wgName", "");
} else {
try {
workgroupName = workgroupName.trim().toLowerCase();
workgroupName = Stringprep.nodeprep(workgroupName);
} catch (StringprepException se) {
errors.put("wgName", "");
}
}
// do a create if there were no errors
RequestQueue queue = null;
if (errors.size() == 0) {
try {
// Create new workgroup
Workgroup workgroup = wgManager.createWorkgroup(workgroupName);
workgroup.setDescription(description);
// Create a default workgroup queue
queue = workgroup.createRequestQueue(defaultQueueName);
//workgroup.setMaxChats(maxChats);
//workgroup.setMinChats(minChats);
// Make the workgroup ready by default:
workgroup.setStatus(Workgroup.Status.READY);
// Create default messages and images for the new workgroup
ChatSettingsCreator.getInstance().createDefaultSettings(workgroup.getJID());
// Add generic web form
FormManager formManager = FormManager.getInstance();
formManager.createGenericForm(workgroup);
} catch (UserAlreadyExistsException uaee) {
errors.put("exists", "");
} catch (Exception e) {
Log.error(e.getMessage(), e);
errors.put("general", "");
}
}
if (ModelUtil.hasLength(agents)) {
addAgents(queue, agents);
}
return errors;
}
Aggregations