use of org.jivesoftware.xmpp.workgroup.UnauthorizedException in project Openfire by igniterealtime.
the class DbDispatcherInfoProvider method deleteDispatcherInfo.
/**
* Deletes the DispatcherInfo Object from the given RequestQueue.
* @param queueID the id of the RequestQueue.
* @throws UnauthorizedException thrown if the user is not allowed to delete from the db.
*/
public void deleteDispatcherInfo(long queueID) throws UnauthorizedException {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(DELETE_DISPATCHER);
pstmt.setLong(1, queueID);
pstmt.executeUpdate();
} catch (SQLException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
throw new UnauthorizedException();
} finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
use of org.jivesoftware.xmpp.workgroup.UnauthorizedException in project Openfire by igniterealtime.
the class FormManager method saveDataForm.
private void saveDataForm(Workgroup workgroup) {
DataForm dataForm = new DataForm(DataForm.Type.form);
WorkgroupForm form = getWebForm(workgroup);
if (form.getTitle() != null) {
dataForm.setTitle(form.getTitle());
}
if (form.getDescription() != null) {
dataForm.addInstruction(form.getDescription());
}
List<FormElement> elems = new ArrayList<FormElement>();
// Add normal elems
int size = form.getFormElements().size();
for (int j = 0; j < size; j++) {
elems.add(form.getFormElementAt(j));
}
size = form.getHiddenVars().size();
for (int k = 0; k < size; k++) {
elems.add(form.getHiddenVars().get(k));
}
size = elems.size();
for (int i = 0; i < size; i++) {
FormElement elem = elems.get(i);
FormField field = dataForm.addField();
field.setLabel(elem.getLabel());
field.setVariable(elem.getVariable());
field.setRequired(elem.isRequired());
if (elem.getDescription() != null) {
field.setDescription(elem.getDescription());
}
if (elem.getAnswerType() == WorkgroupForm.FormEnum.textarea) {
field.setType(FormField.Type.text_multi);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.textfield) {
field.setType(FormField.Type.text_single);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.checkbox) {
field.setType(FormField.Type.boolean_type);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.radio_button) {
field.setType(FormField.Type.list_multi);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.dropdown_box) {
field.setType(FormField.Type.list_single);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.hidden) {
field.setType(FormField.Type.hidden);
} else if (elem.getAnswerType() == WorkgroupForm.FormEnum.password) {
field.setType(FormField.Type.text_private);
}
if (elem.getAnswers().size() > 0 && elem.getAnswerType() != WorkgroupForm.FormEnum.hidden) {
for (String item : elem.getAnswers()) {
field.addOption(item, item);
}
} else if (elem.getAnswers().size() > 0) {
// Add hidden element values.
for (String item : elem.getAnswers()) {
field.addValue(item);
}
}
}
XStream xstream = new XStream();
String xmlToSave = xstream.toXML(dataForm);
DbProperties props = workgroup.getProperties();
String context = "jive.dataform.wg";
try {
props.deleteProperty(context);
props.setProperty(context, xmlToSave);
} catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
}
use of org.jivesoftware.xmpp.workgroup.UnauthorizedException 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.UnauthorizedException in project Openfire by igniterealtime.
the class FormManager method saveWorkgroupForm.
public void saveWorkgroupForm(Workgroup workgroup) {
// Save Web Form for editing
WorkgroupForm workgroupForm = getWebForm(workgroup);
if (workgroupForm != null) {
XStream xstream = new XStream();
String xmlToSave = xstream.toXML(workgroupForm);
DbProperties props = workgroup.getProperties();
String context = "jive.webform.wg";
try {
props.deleteProperty(context);
props.setProperty(context, xmlToSave);
} catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
}
// Save DataForm for usage
saveDataForm(workgroup);
}
use of org.jivesoftware.xmpp.workgroup.UnauthorizedException in project Openfire by igniterealtime.
the class MacroProvider method executeSet.
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
String personalMacro = iq.element("personalMacro").getTextTrim();
try {
// Verify that an agent is requesting this information.
Agent agent = workgroup.getAgentManager().getAgent(packet.getFrom());
DbProperties props = agent.getProperties();
XStream xstream = new XStream();
xstream.alias("macro", Macro.class);
xstream.alias("macrogroup", MacroGroup.class);
MacroGroup group = (MacroGroup) xstream.fromXML(personalMacro);
String saveString = xstream.toXML(group);
try {
props.deleteProperty("personal.macro");
props.setProperty("personal.macro", saveString);
} catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
reply = IQ.createResultIQ(packet);
} catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
workgroup.send(reply);
}
Aggregations