Search in sources :

Example 61 with JsonObject

use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.

the class DeskShareStoppedEventMessage method fromJson.

public static DeskShareStoppedEventMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (DESK_SHARE_STOPPED_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(CALLER_ID) && payload.has(CALLER_ID_NAME)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String callerId = payload.get(CALLER_ID_NAME).getAsString();
                    String callerIdName = payload.get(CALLER_ID_NAME).getAsString();
                    return new DeskShareStoppedEventMessage(conferenceName, callerId, callerIdName);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 62 with JsonObject

use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.

the class DisconnectAllUsersMessage method fromJson.

public static DisconnectAllUsersMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (DISCONNECT_All_USERS.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    return new DisconnectAllUsersMessage(meetingId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 63 with JsonObject

use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.

the class ClearWhiteboardReplyMessage method fromJson.

public static ClearWhiteboardReplyMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (WHITEBOARD_CLEARED_MESSAGE.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.WHITEBOARD_ID) && payload.has(Constants.REQUESTER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    return new ClearWhiteboardReplyMessage(meetingId, requesterId, whiteboardId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 64 with JsonObject

use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.

the class ClearWhiteboardRequestMessage method fromJson.

public static ClearWhiteboardRequestMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (CLEAR_WHITEBOARD_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.WHITEBOARD_ID) && payload.has(Constants.REQUESTER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    return new ClearWhiteboardRequestMessage(meetingId, requesterId, whiteboardId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 65 with JsonObject

use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.

the class CreatePollRequestMessage method fromJson.

public static CreatePollRequestMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (CREATE_POLL_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(REQUESTER_ID) && payload.has(POLL_ID) && payload.has(POLL_TYPE)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(REQUESTER_ID).getAsString();
                    String pollId = payload.get(POLL_ID).getAsString();
                    String pollType = payload.get(POLL_TYPE).getAsString();
                    return new CreatePollRequestMessage(id, requesterId, pollId, pollType);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Aggregations

JsonObject (com.google.gson.JsonObject)1417 JsonElement (com.google.gson.JsonElement)389 JsonArray (com.google.gson.JsonArray)293 JsonParser (com.google.gson.JsonParser)285 JsonPrimitive (com.google.gson.JsonPrimitive)137 Gson (com.google.gson.Gson)91 Test (org.junit.Test)81 HashMap (java.util.HashMap)79 Map (java.util.Map)78 ArrayList (java.util.ArrayList)77 IOException (java.io.IOException)66 Test (org.testng.annotations.Test)61 InputStreamReader (java.io.InputStreamReader)38 JsonParseException (com.google.gson.JsonParseException)27 File (java.io.File)25 List (java.util.List)21 HttpResponse (org.apache.http.HttpResponse)21 JsonReader (com.google.gson.stream.JsonReader)19 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)19 InputStream (java.io.InputStream)19