use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class ChatSettingsCreator method createBotSettings.
/**
* Adds the default bot settings to the database.
*
* @param workgroupJID - the JID of the workgroup to setup.
*/
private void createBotSettings(JID workgroupJID) {
try {
// Enable the workgroup chatbot by default
Workgroup workgroup = WorkgroupManager.getInstance().getWorkgroup(workgroupJID);
workgroup.chatbotEnabled(true);
for (KeyEnum key : botMap.keySet()) {
String value = botMap.get(key);
createChatSetting(workgroupJID, key, ChatSettings.SettingType.bot_settings, value);
}
} catch (UserNotFoundException e) {
Log.error(e.getMessage(), e);
} catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class FastpathPlugin method workgroupManagerStart.
private void workgroupManagerStart() {
workgroupManager = WorkgroupManager.getInstance();
// Register Fastpath service
try {
ComponentManagerFactory.getComponentManager().addComponent("workgroup", workgroupManager);
} catch (ComponentException e) {
// Do nothing. Should never happen.
Log.error(e.getMessage(), e);
}
// Register the provider of workgroup names
UserNameManager.addUserNameProvider(workgroupManager.getAddress().toString(), new UserNameProvider() {
public String getUserName(JID entity) {
try {
Workgroup workgroup = workgroupManager.getWorkgroup(entity);
return workgroup.getDisplayName();
} catch (UserNotFoundException e) {
return entity.toString();
}
}
});
// Start the Fastpath module
workgroupManager.start();
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class SoundServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String workgroupName = request.getParameter("workgroup");
String action = request.getParameter("action");
Workgroup workgroup = null;
try {
workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName));
} catch (UserNotFoundException e) {
Log.error(e.getMessage(), e);
}
try {
response.setContentType("audio/wav");
if (action != null) {
if ("incoming".equals(action.trim())) {
String incomingMessage = workgroup.getProperties().getProperty("incomingSound");
byte[] incomingBytes = StringUtils.decodeBase64(incomingMessage);
response.getOutputStream().write(incomingBytes);
} else if ("outgoing".equals(action.trim())) {
String outgoingMessage = workgroup.getProperties().getProperty("outgoingSound");
String outgoingBytes = StringUtils.encodeBase64(outgoingMessage);
response.getOutputStream().write(outgoingBytes.getBytes("UTF-8"));
}
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
use of org.jivesoftware.xmpp.workgroup.Workgroup in project Openfire by igniterealtime.
the class FormManager method loadWebForms.
private void loadWebForms() {
final WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
for (Workgroup workgroup : workgroupManager.getWorkgroups()) {
DbProperties props = workgroup.getProperties();
String context = "jive.webform.wg";
String form = props.getProperty(context);
if (form != null) {
XStream xstream = new XStream();
xstream.setClassLoader(this.getClass().getClassLoader());
try {
Object object = xstream.fromXML(form);
WorkgroupForm workgroupForm = (WorkgroupForm) object;
if (workgroupForm != null) {
addWorkgroupForm(workgroup, workgroupForm);
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
} else {
// Create a default Web Form
createGenericForm(workgroup);
}
}
}
use of org.jivesoftware.xmpp.workgroup.Workgroup 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