use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class WorkgroupFormProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
FormManager formManager = FormManager.getInstance();
DataForm dataForm = formManager.getDataForm(workgroup);
if (dataForm == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element iq = packet.getChildElement();
if (iq.elements().isEmpty()) {
reply.setChildElement(iq.createCopy());
// Send the data form to the requestor
reply.addExtension(dataForm.createCopy());
workgroup.send(reply);
}
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class SparkVersionManager method handleSparkIQ.
private void handleSparkIQ(IQ packet) {
IQ reply;
Element iq = packet.getChildElement();
// Define default values
String os = iq.element("os").getText();
reply = IQ.createResultIQ(packet);
// Handle Invalid Requests
if (os == null || (!os.equals("windows") && !os.equals("mac") && !os.equals("linux"))) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.not_acceptable));
sendPacket(reply);
return;
}
Element sparkElement = reply.setChildElement("query", "jabber:iq:spark");
String client = null;
// Handle Windows clients
if (os.equals("windows")) {
client = JiveGlobals.getProperty("spark.windows.client");
} else // Handle Mac clients.
if (os.equals("mac")) {
client = JiveGlobals.getProperty("spark.mac.client");
} else // Handle Linux Client.
if (os.equals("linux")) {
client = JiveGlobals.getProperty("spark.linux.client");
}
if (client != null) {
int index = client.indexOf("_");
// Add version number
String versionNumber = client.substring(index + 1);
int indexOfPeriod = versionNumber.indexOf(".");
versionNumber = versionNumber.substring(0, indexOfPeriod);
versionNumber = versionNumber.replaceAll("_", ".");
sparkElement.addElement("version").setText(versionNumber);
// Add updated time.
File clientFile = new File(JiveGlobals.getHomeDirectory(), "enterprise/spark/" + client);
if (!clientFile.exists()) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
sendPacket(reply);
return;
}
long updatedTime = clientFile.lastModified();
sparkElement.addElement("updatedTime").setText(Long.toString(updatedTime));
// Add download url
String downloadURL = JiveGlobals.getProperty("spark.client.downloadURL");
String server = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
downloadURL = downloadURL.replace("127.0.0.1", server);
sparkElement.addElement("downloadURL").setText(downloadURL + "?client=" + client);
String displayMessage = JiveGlobals.getProperty("spark.client.displayMessage");
if (displayMessage != null && displayMessage.trim().length() > 0) {
sparkElement.addElement("displayMessage").setText(displayMessage);
}
} else {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
sendPacket(reply);
return;
}
sendPacket(reply);
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class Workgroup method processInvitation.
public void processInvitation(InvitationRequest invitation, IQ packet) {
IQ reply = IQ.createResultIQ(packet);
reply.setFrom(getJID());
// Verify that requester is a valid agent
AgentSession agentSession = null;
try {
agentSession = agentManager.getAgentSession(packet.getFrom());
} catch (AgentNotFoundException e) {
// Ignore
}
if (agentSession == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
send(reply);
Log.debug("Agent not found while accepting offer");
return;
}
// Answer that the invitation was received and that it is being processed
send(reply);
// Execute the invitation
invitation.execute();
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class Workgroup method processTransfer.
public void processTransfer(TransferRequest transfer, IQ packet) {
IQ reply = IQ.createResultIQ(packet);
reply.setFrom(getJID());
// Verify that requester is a valid agent
AgentSession agentSession = null;
try {
agentSession = agentManager.getAgentSession(packet.getFrom());
} catch (AgentNotFoundException e) {
// Ignore
}
if (agentSession == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
send(reply);
Log.debug("Agent not found while accepting offer");
return;
}
// Answer that the transfer was received and that it is being processed
send(reply);
// Execute the transfer
transfer.execute();
}
use of org.xmpp.packet.PacketError in project Openfire by igniterealtime.
the class OfflineSettingsProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
OfflineSettingsManager offlineSettingsManager = new OfflineSettingsManager();
OfflineSettings settings;
try {
settings = offlineSettingsManager.getOfflineSettings(workgroup);
} catch (OfflineSettingsNotFound offlineSettingsNotFound) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element offline = reply.setChildElement("offline-settings", "http://jivesoftware.com/protocol/workgroup");
if (ModelUtil.hasLength(settings.getRedirectURL())) {
offline.addElement("redirectPage").setText(settings.getRedirectURL());
} else {
offline.addElement("emailAddress").setText(settings.getEmailAddress());
offline.addElement("offlineText").setText(settings.getOfflineText());
offline.addElement("subject").setText(settings.getSubject());
}
workgroup.send(reply);
}
Aggregations