Commit d52458f7 authored by Roman S's avatar Roman S

REST API Plugin update to version 1.2.2

parent d8980554
......@@ -44,6 +44,12 @@
REST API Plugin Changelog
</h1>
<p><b>1.2.2</b> -- January 20th, 2015</p>
<ul>
<li>Added: Presence status to the Session Enitity. E.g. Online, Away etc.</li>
<li>Fixed: Node parameter in the Session Enitity. E.g. Local or Remote</li>
</ul>
<p><b>1.2.1</b> -- November 24th, 2015</p>
<ul>
<li>Fixed: Cluster issue by creating a new chat room</li>
......
......@@ -5,8 +5,8 @@
<name>REST API</name>
<description>Allows administration over a RESTful API.</description>
<author>Roman Soldatow</author>
<version>1.2.1</version>
<date>11/24/2015</date>
<version>1.2.2</version>
<date>01/20/2016</date>
<minServerVersion>4.0.0</minServerVersion>
<adminconsole>
<tab id="tab-server">
......
......@@ -13,10 +13,12 @@ import org.jivesoftware.openfire.plugin.rest.entity.SessionEntity;
import org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.Presence;
import org.xmpp.packet.StreamError;
/**
......@@ -104,7 +106,12 @@ public class SessionController {
}
session.setRessource(clientSession.getAddress().getResource());
session.setNode(session.getNode());
if (clientSession instanceof LocalClientSession) {
session.setNode("Local");
} else {
session.setNode("Remote");
}
String status = "";
if (clientSession.getStatus() == Session.STATUS_CLOSED) {
......@@ -119,9 +126,25 @@ public class SessionController {
session.setSessionStatus(status);
if (clientSession.getPresence() != null) {
session.setPresenceStatus(clientSession.getPresence().getStatus());
session.setPresenceMessage(clientSession.getPresence().getStatus());
Presence.Show show = clientSession.getPresence().getShow();
if(show == Presence.Show.away) {
session.setPresenceStatus("Away");
} else if(show == Presence.Show.chat) {
session.setPresenceStatus("Available to Chat");
} else if(show == Presence.Show.dnd) {
session.setPresenceStatus("Do Not Disturb");
} else if(show == Presence.Show.xa) {
session.setPresenceStatus("Extended Away");
} else if(show == null) {
session.setPresenceStatus("Online");
} else {
session.setPresenceStatus("Unknown/Not Recognized");
}
session.setPriority(clientSession.getPresence().getPriority());
}
try {
session.setHostAddress(clientSession.getHostAddress());
session.setHostName(clientSession.getHostName());
......
......@@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "session")
@XmlType(propOrder = { "sessionId", "username", "ressource", "node", "sessionStatus", "presenceStatus", "priority",
@XmlType(propOrder = { "sessionId", "username", "ressource", "node", "sessionStatus", "presenceStatus", "presenceMessage", "priority",
"hostAddress", "hostName", "creationDate", "lastActionDate", "secure" })
public class SessionEntity {
......@@ -17,6 +17,7 @@ public class SessionEntity {
private String node;
private String sessionStatus;
private String presenceStatus;
private String presenceMessage;
private int priority;
private String hostAddress;
private String hostName;
......@@ -83,6 +84,14 @@ public class SessionEntity {
this.presenceStatus = presenceStatus;
}
public String getPresenceMessage() {
return presenceMessage;
}
public void setPresenceMessage(String presenceMessage) {
this.presenceMessage = presenceMessage;
}
@XmlElement
public int getPriority() {
return priority;
......
......@@ -16,7 +16,6 @@ import org.jivesoftware.openfire.group.GroupJID;
import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.xmpp.packet.JID;
// TODO: Auto-generated Javadoc
/**
* The Class UserUtils.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment