Search in sources :

Example 36 with JsonObject

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

the class LockLayoutRequestMessage method fromJson.

public static LockLayoutRequestMessage 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 (LOCK_LAYOUT_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.USER_ID) && payload.has(LOCK) && payload.has(VIEWERS_ONLY) && payload.has(LAYOUT)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String userid = payload.get(Constants.USER_ID).getAsString();
                    Boolean lock = payload.get(LOCK).getAsBoolean();
                    Boolean viewersOnly = payload.get(VIEWERS_ONLY).getAsBoolean();
                    String layout = payload.get(LAYOUT).getAsString();
                    return new LockLayoutRequestMessage(id, userid, lock, viewersOnly, layout);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 37 with JsonObject

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

the class LockUserMessage method fromJson.

public static LockUserMessage 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 (LOCK_USER.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.REQUESTER_ID) && payload.has(Constants.LOCK) && payload.has(Constants.INTERNAL_USER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    boolean lock = payload.get(Constants.LOCK).getAsBoolean();
                    String internalUserId = payload.get(Constants.INTERNAL_USER_ID).getAsString();
                    return new LockUserMessage(meetingId, requesterId, lock, internalUserId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 38 with JsonObject

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

the class StartPollRequestMessage method fromJson.

public static StartPollRequestMessage 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 (START_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 StartPollRequestMessage(id, requesterId, pollId, pollType);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 39 with JsonObject

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

the class StopPollRequestMessage method fromJson.

public static StopPollRequestMessage 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 (STOP_POLL_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(REQUESTER_ID) && payload.has(POLL_ID)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(REQUESTER_ID).getAsString();
                    String pollId = payload.get(POLL_ID).getAsString();
                    return new StopPollRequestMessage(id, requesterId, pollId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 40 with JsonObject

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

the class TransferUserToVoiceConfRequestMessage method fromJson.

public static TransferUserToVoiceConfRequestMessage 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 (TRANSFER_USER_TO_VOICE_CONF_REQUEST.equals(messageName)) {
                if (payload.has(VOICE_CONF_ID) && payload.has(TARGET_VOICE_CONF_ID) && payload.has(VOICE_USER_ID)) {
                    String id = payload.get(VOICE_CONF_ID).getAsString();
                    String targetVoiceConfId = payload.get(TARGET_VOICE_CONF_ID).getAsString();
                    String voiceUserId = payload.get(VOICE_USER_ID).getAsString();
                    return new TransferUserToVoiceConfRequestMessage(id, targetVoiceConfId, voiceUserId);
                }
            }
        }
    }
    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