use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class SiteTracker method handleInvitation.
private void handleInvitation(IQ packet, Workgroup workgroup) {
Element iq = packet.getChildElement();
// Define default values
IQ update = new IQ();
Element elem = update.setChildElement("site-invite", "http://jivesoftware.com/protocol/workgroup");
String sessionID = iq.attribute("sessionID").getText();
elem.addAttribute("sessionID", sessionID);
SiteUser siteUser = siteUsers.get(sessionID);
IQ reply = IQ.createResultIQ(packet);
if (siteUser == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
} else {
// Send back reply
workgroup.send(reply);
}
String agent = iq.element("agent").getText();
String message = iq.element("message").getText();
elem.addElement("agent").setText(agent);
elem.addElement("message").setText(message);
update.setTo(siteUser.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class SoundProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
// Retrieve the sound settings.
String outgoingMessage = workgroup.getProperties().getProperty("outgoingSound");
String incomingMessage = workgroup.getProperties().getProperty("incomingSound");
Element soundSetting = reply.setChildElement("sound-settings", "http://jivesoftware.com/protocol/workgroup");
if (ModelUtil.hasLength(outgoingMessage) && ModelUtil.hasLength(incomingMessage)) {
soundSetting.addElement("outgoingSound").setText(outgoingMessage);
soundSetting.addElement("incomingSound").setText(incomingMessage);
} else {
// Throw error
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
workgroup.send(reply);
}
use of org.xmpp.packet.PacketError 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);
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class MacroProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
Element iq = packet.getChildElement();
String name = iq.getName();
boolean isPersonal = iq.element("personal") != null;
Agent agent;
try {
agent = workgroup.getAgentManager().getAgent(packet.getFrom());
} catch (AgentNotFoundException e) {
sendItemNotFound(packet, workgroup);
return;
}
if ("macros".equals(name) && !isPersonal) {
Element globalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = workgroup.getProperties();
String macroModel = props.getProperty("jive.macro" + workgroup.getID());
if (ModelUtil.hasLength(macroModel)) {
globalMacros.addElement("model").setText(macroModel);
} else {
sendItemNotFound(packet, workgroup);
return;
}
} else if (isPersonal) {
Element personalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = agent.getProperties();
String macroModel = props.getProperty("personal.macro");
if (ModelUtil.hasLength(macroModel)) {
personalMacros.addElement("model").setText(macroModel);
} else {
sendItemNotFound(packet, workgroup);
return;
}
} else {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
workgroup.send(reply);
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class ChatNotes method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
// Verify that an agent is requesting this information.
try {
AgentSession agentSession = workgroup.getAgentManager().getAgentSession(packet.getFrom());
if (agentSession != null) {
String sessionID = iq.element("sessionID").getTextTrim();
sendNotesPacket(packet, workgroup, sessionID);
} else {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
} 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