Search in sources :

Example 71 with JsonObject

use of com.google.gson.JsonObject in project disunity by ata4.

the class JsonTablePrinter method print.

@Override
public void print(Collection<TableModel> models) {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    JsonObject jsonRoot = new JsonObject();
    if (file != null) {
        jsonRoot.add("file", new JsonPrimitive(file.toString()));
    }
    models.forEach(model -> {
        jsonRoot.add(model.name().toLowerCase(), tableToJson(model.table(), gson));
    });
    gson.toJson(jsonRoot, out);
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JsonPrimitive(com.google.gson.JsonPrimitive) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject)

Example 72 with JsonObject

use of com.google.gson.JsonObject in project disunity by ata4.

the class AssetTypes method printJson.

private void printJson(Path file, TypeTree<? extends Type> typeTree) {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    JsonObject jsonTypeTree = new JsonObject();
    jsonTypeTree.addProperty("file", file.toString());
    if (typeTree.embedded()) {
        JsonArray jsonTypes = new JsonArray();
        typeTree.typeMap().forEach((path, typeRoot) -> {
            JsonObject jsonTypeNode = new JsonObject();
            jsonTypeNode.addProperty("pathID", path);
            jsonTypeNode.addProperty("classID", typeRoot.classID());
            if (typeRoot.scriptID() != null) {
                jsonTypeNode.addProperty("scriptID", typeRoot.scriptID().toString());
            }
            if (typeRoot.oldTypeHash() != null) {
                jsonTypeNode.addProperty("oldTypeHash", typeRoot.oldTypeHash().toString());
            }
            jsonTypeNode.add("nodes", typeNodeToJson(typeRoot.nodes(), gson));
            jsonTypes.add(jsonTypeNode);
        });
        jsonTypeTree.add("types", jsonTypes);
    }
    gson.toJson(jsonTypeTree, output());
}
Also used : JsonArray(com.google.gson.JsonArray) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject)

Example 73 with JsonObject

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

the class UserClientMessageSender method handleUsersMessage.

public void handleUsersMessage(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");
        if (header.has("name")) {
            // Used for JSON unmarshalling
            Gson gson = new Gson();
            String messageName = header.get("name").getAsString();
            switch(messageName) {
                case ValidateAuthTokenReplyMessage.VALIDATE_AUTH_TOKEN_REPLY:
                    ValidateAuthTokenReplyMessage m = ValidateAuthTokenReplyMessage.fromJson(message);
                    if (m != null) {
                        processValidateAuthTokenReply(m);
                    }
                    break;
                case ValidateAuthTokenTimeoutMessage.VALIDATE_AUTH_TOKEN_TIMEOUT:
                    ValidateAuthTokenTimeoutMessage vattm = ValidateAuthTokenTimeoutMessage.fromJson(message);
                    if (vattm != null) {
                        processValidateAuthTokenTimeoutMessage(vattm);
                    }
                    break;
                case UserLeftMessage.USER_LEFT:
                    UserLeftMessage ulm = UserLeftMessage.fromJson(message);
                    if (ulm != null) {
                        processUserLeftMessage(ulm);
                    }
                    break;
                case UserJoinedMessage.USER_JOINED:
                    UserJoinedMessage ujm = UserJoinedMessage.fromJson(message);
                    if (ujm != null) {
                        processUserJoinedMessage(ujm);
                    }
                    break;
                case PresenterAssignedMessage.PRESENTER_ASSIGNED:
                    PresenterAssignedMessage pam = PresenterAssignedMessage.fromJson(message);
                    if (pam != null) {
                        processPresenterAssignedMessage(pam);
                    }
                    break;
                case UserStatusChangedMessage.USER_STATUS_CHANGED:
                    UserStatusChangedMessage usm = UserStatusChangedMessage.fromJson(message);
                    if (usm != null) {
                        processUserStatusChangedMessage(usm);
                    }
                    break;
                case UserEmojiStatusMessage.USER_EMOJI_STATUS:
                    UserEmojiStatusMessage urhm = UserEmojiStatusMessage.fromJson(message);
                    if (urhm != null) {
                        processUserEmojiStatusMessage(urhm);
                    }
                    break;
                case UserListeningOnlyMessage.USER_LISTENING_ONLY:
                    UserListeningOnlyMessage ulom = UserListeningOnlyMessage.fromJson(message);
                    if (ulom != null) {
                        processUserListeningOnlyMessage(ulom);
                    }
                    break;
                case UserSharedWebcamMessage.USER_SHARED_WEBCAM:
                    UserSharedWebcamMessage uswm = UserSharedWebcamMessage.fromJson(message);
                    if (uswm != null) {
                        processUserSharedWebcamMessage(uswm);
                    }
                    break;
                case UserUnsharedWebcamMessage.USER_UNSHARED_WEBCAM:
                    UserUnsharedWebcamMessage uuwm = UserUnsharedWebcamMessage.fromJson(message);
                    if (uuwm != null) {
                        processUserUnsharedWebcamMessage(uuwm);
                    }
                    break;
                case UserJoinedVoiceMessage.USER_JOINED_VOICE:
                    UserJoinedVoiceMessage ujvm = UserJoinedVoiceMessage.fromJson(message);
                    if (ujvm != null) {
                        processUserJoinedVoiceMessage(ujvm);
                    }
                    break;
                case UserLeftVoiceMessage.USER_LEFT_VOICE:
                    UserLeftVoiceMessage ulvm = UserLeftVoiceMessage.fromJson(message);
                    if (ulvm != null) {
                        processUserLeftVoiceMessage(ulvm);
                    }
                    break;
                case UserVoiceMutedMessage.USER_VOICE_MUTED:
                    UserVoiceMutedMessage uvmm = UserVoiceMutedMessage.fromJson(message);
                    if (uvmm != null) {
                        processUserVoiceMutedMessage(uvmm);
                    }
                    break;
                case UserVoiceTalkingMessage.USER_VOICE_TALKING:
                    UserVoiceTalkingMessage uvtm = UserVoiceTalkingMessage.fromJson(message);
                    if (uvtm != null) {
                        processUserVoiceTalkingMessage(uvtm);
                    }
                    break;
                case RecordingStatusChangedMessage.RECORDING_STATUS_CHANGED:
                    RecordingStatusChangedMessage rscm = RecordingStatusChangedMessage.fromJson(message);
                    if (rscm != null) {
                        processRecordingStatusChangedMessage(rscm);
                    }
                    break;
                case GetRecordingStatusReplyMessage.Get_RECORDING_STATUS_REPLY:
                    GetRecordingStatusReplyMessage grsrm = GetRecordingStatusReplyMessage.fromJson(message);
                    if (grsrm != null) {
                        processGetRecordingStatusReplyMessage(grsrm);
                    }
                    break;
                case GetUsersReplyMessage.GET_USERS_REPLY:
                    GetUsersReplyMessage gurm = GetUsersReplyMessage.fromJson(message);
                    if (gurm != null) {
                        processGetUsersReplyMessage(gurm);
                    }
                    break;
                case GetCurrentLayoutReplyMessage.GET_CURRENT_LAYOUT_REPLY:
                    processGetCurrentLayoutReplyMessage(message);
                    break;
                case BroadcastLayoutMessage.BROADCAST_LAYOUT:
                    processBroadcastLayoutMessage(message);
                    break;
                case LockLayoutMessage.LOCK_LAYOUT:
                    processLockLayoutMessage(message);
                    break;
                case UserEjectedFromMeetingMessage.USER_EJECTED_FROM_MEETING:
                    processUserEjectedFromMeetingMessage(message);
                    break;
                case BreakoutRoomsList.NAME:
                    BreakoutRoomsList brl = gson.fromJson(message, BreakoutRoomsList.class);
                    if (brl != null) {
                        processBreakoutRoomsList(brl);
                    }
                    break;
                case BreakoutRoomJoinURL.NAME:
                    BreakoutRoomJoinURL brjum = gson.fromJson(message, BreakoutRoomJoinURL.class);
                    if (brjum != null) {
                        processBreakoutRoomJoinURL(brjum);
                    }
                    break;
                case TimeRemainingUpdate.NAME:
                    TimeRemainingUpdate trum = gson.fromJson(message, TimeRemainingUpdate.class);
                    if (trum != null) {
                        processTimeRemainingUpdate(trum);
                    }
                    break;
                case BreakoutRoomsTimeRemainingUpdate.NAME:
                    BreakoutRoomsTimeRemainingUpdate brtru = gson.fromJson(message, BreakoutRoomsTimeRemainingUpdate.class);
                    if (brtru != null) {
                        processBreakoutRoomsTimeRemainingUpdate(brtru);
                    }
                    break;
                case UpdateBreakoutUsers.NAME:
                    UpdateBreakoutUsers ubum = gson.fromJson(message, UpdateBreakoutUsers.class);
                    if (ubum != null) {
                        processUpdateBreakoutUsers(ubum);
                    }
                    break;
                case BreakoutRoomStarted.NAME:
                    BreakoutRoomStarted brsm = gson.fromJson(message, BreakoutRoomStarted.class);
                    if (brsm != null) {
                        processBreakoutRoomStarted(brsm);
                    }
                    break;
                case BreakoutRoomClosed.NAME:
                    BreakoutRoomClosed brcm = gson.fromJson(message, BreakoutRoomClosed.class);
                    if (brcm != null) {
                        processBreakoutRoomClosed(brcm);
                    }
                    break;
            }
        }
    }
}
Also used : UserLeftMessage(org.bigbluebutton.common.messages.UserLeftMessage) UserSharedWebcamMessage(org.bigbluebutton.common.messages.UserSharedWebcamMessage) UserStatusChangedMessage(org.bigbluebutton.common.messages.UserStatusChangedMessage) UserVoiceMutedMessage(org.bigbluebutton.common.messages.UserVoiceMutedMessage) UserUnsharedWebcamMessage(org.bigbluebutton.common.messages.UserUnsharedWebcamMessage) TimeRemainingUpdate(org.bigbluebutton.messages.TimeRemainingUpdate) BreakoutRoomsTimeRemainingUpdate(org.bigbluebutton.messages.BreakoutRoomsTimeRemainingUpdate) UserVoiceTalkingMessage(org.bigbluebutton.common.messages.UserVoiceTalkingMessage) GetUsersReplyMessage(org.bigbluebutton.common.messages.GetUsersReplyMessage) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) BreakoutRoomClosed(org.bigbluebutton.messages.BreakoutRoomClosed) UserJoinedMessage(org.bigbluebutton.common.messages.UserJoinedMessage) BreakoutRoomsTimeRemainingUpdate(org.bigbluebutton.messages.BreakoutRoomsTimeRemainingUpdate) PresenterAssignedMessage(org.bigbluebutton.common.messages.PresenterAssignedMessage) UserLeftVoiceMessage(org.bigbluebutton.common.messages.UserLeftVoiceMessage) UserEmojiStatusMessage(org.bigbluebutton.common.messages.UserEmojiStatusMessage) JsonParser(com.google.gson.JsonParser) UpdateBreakoutUsers(org.bigbluebutton.messages.UpdateBreakoutUsers) BreakoutRoomStarted(org.bigbluebutton.messages.BreakoutRoomStarted) ValidateAuthTokenTimeoutMessage(org.bigbluebutton.common.messages.ValidateAuthTokenTimeoutMessage) BreakoutRoomsList(org.bigbluebutton.messages.BreakoutRoomsList) GetRecordingStatusReplyMessage(org.bigbluebutton.common.messages.GetRecordingStatusReplyMessage) ValidateAuthTokenReplyMessage(org.bigbluebutton.common.messages.ValidateAuthTokenReplyMessage) UserJoinedVoiceMessage(org.bigbluebutton.common.messages.UserJoinedVoiceMessage) UserListeningOnlyMessage(org.bigbluebutton.common.messages.UserListeningOnlyMessage) RecordingStatusChangedMessage(org.bigbluebutton.common.messages.RecordingStatusChangedMessage) BreakoutRoomJoinURL(org.bigbluebutton.messages.BreakoutRoomJoinURL)

Example 74 with JsonObject

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

the class MeetingClientMessageSender method handleMeetingMessage.

public void handleMeetingMessage(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");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            switch(messageName) {
                case DisconnectUserMessage.DISCONNECT_USER:
                    DisconnectUserMessage m = DisconnectUserMessage.fromJson(message);
                    if (m != null) {
                        processDisconnectUserMessage(m);
                    }
                    break;
                case DisconnectAllUsersMessage.DISCONNECT_All_USERS:
                    DisconnectAllUsersMessage daum = DisconnectAllUsersMessage.fromJson(message);
                    if (daum != null) {
                        processDisconnectAllUsersMessage(daum);
                    }
                    break;
                case MeetingEndedMessage.MEETING_ENDED:
                    MeetingEndedMessage mem = MeetingEndedMessage.fromJson(message);
                    if (mem != null) {
                        processMeetingEndedMessage(mem);
                    }
                    break;
                case MeetingEndingMessage.MEETING_ENDING:
                    MeetingEndingMessage me = MeetingEndingMessage.fromJson(message);
                    if (me != null) {
                        processMeetingEndingMessage(me);
                    }
                    break;
                case MeetingHasEndedMessage.MEETING_HAS_ENDED:
                    MeetingHasEndedMessage mhem = MeetingHasEndedMessage.fromJson(message);
                    if (mhem != null) {
                        processMeetingHasEndedMessage(mhem);
                    }
                    break;
                case MeetingStateMessage.MEETING_STATE:
                    MeetingStateMessage msm = MeetingStateMessage.fromJson(message);
                    if (msm != null) {
                        processMeetingStateMessage(msm);
                    }
                    break;
                case NewPermissionsSettingMessage.NEW_PERMISSIONS_SETTING:
                    NewPermissionsSettingMessage npsm = NewPermissionsSettingMessage.fromJson(message);
                    if (npsm != null) {
                        processNewPermissionsSettingMessage(npsm);
                    }
                    break;
                case MeetingMutedMessage.MEETING_MUTED:
                    MeetingMutedMessage mmm = MeetingMutedMessage.fromJson(message);
                    if (mmm != null) {
                        processMeetingMutedMessage(mmm);
                    }
                    break;
                case UserLockedMessage.USER_LOCKED:
                    UserLockedMessage ulm = UserLockedMessage.fromJson(message);
                    if (ulm != null) {
                        processUserLockedMessage(ulm);
                    }
                    break;
            }
        }
    }
}
Also used : DisconnectAllUsersMessage(org.bigbluebutton.common.messages.DisconnectAllUsersMessage) MeetingEndingMessage(org.bigbluebutton.common.messages.MeetingEndingMessage) MeetingHasEndedMessage(org.bigbluebutton.common.messages.MeetingHasEndedMessage) DisconnectUserMessage(org.bigbluebutton.common.messages.DisconnectUserMessage) MeetingEndedMessage(org.bigbluebutton.common.messages.MeetingEndedMessage) MeetingMutedMessage(org.bigbluebutton.common.messages.MeetingMutedMessage) MeetingStateMessage(org.bigbluebutton.common.messages.MeetingStateMessage) JsonObject(com.google.gson.JsonObject) UserLockedMessage(org.bigbluebutton.common.messages.UserLockedMessage) NewPermissionsSettingMessage(org.bigbluebutton.common.messages.NewPermissionsSettingMessage) JsonParser(com.google.gson.JsonParser)

Example 75 with JsonObject

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

the class PollingClientMessageSender method handlePollMessage.

public void handlePollMessage(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");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            switch(messageName) {
                case PollStartedMessage.POLL_STARTED:
                    processPollStartedMessage(message);
                    break;
                case PollStoppedMessage.POLL_STOPPED:
                    processPollStoppedMessage(message);
                    break;
                case PollShowResultMessage.POLL_SHOW_RESULT:
                    processPollShowResultMessage(message);
                    break;
                case UserVotedPollMessage.USER_VOTED_POLL:
                    processUserVotedPollMessage(message);
                    break;
            }
        }
    }
}
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