use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class UndoWhiteboardRequest method fromJson.
public static UndoWhiteboardRequest 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 (UNDO_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 UndoWhiteboardRequest(meetingId, requesterId, whiteboardId);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class PresentationPageGeneratedReplyMessage method fromJson.
public static PresentationPageGeneratedReplyMessage 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 (PRESENTATION_PAGE_GENERATED.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.CODE) && payload.has(Constants.MESSAGE_KEY) && payload.has(Constants.PRESENTATION_NAME) && payload.has(Constants.NUM_PAGES) && payload.has(Constants.PAGES_COMPLETED) && payload.has(Constants.PRESENTATION_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String presentationId = payload.get(Constants.PRESENTATION_ID).getAsString();
String presentationName = payload.get(Constants.PRESENTATION_NAME).getAsString();
String code = payload.get(Constants.CODE).getAsString();
String messageKey = payload.get(Constants.MESSAGE_KEY).getAsString();
int numPages = payload.get(Constants.NUM_PAGES).getAsInt();
int pagesCompleted = payload.get(Constants.PAGES_COMPLETED).getAsInt();
return new PresentationPageGeneratedReplyMessage(meetingId, presentationId, numPages, code, messageKey, presentationName, pagesCompleted);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class PresentationSharedMessage method fromJson.
public static PresentationSharedMessage 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 (PRESENTATION_SHARED_MESSAGE.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.PRESENTATION)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
JsonObject presentationObject = (JsonObject) payload.get(Constants.PRESENTATION).getAsJsonObject();
Util util = new Util();
Map<String, Object> presentation = util.extractPresentation(presentationObject);
return new PresentationSharedMessage(meetingId, presentation);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project ion by koush.
the class GsonTests method testParserCastingCallbackError.
public void testParserCastingCallbackError() throws Exception {
ByteBufferList b = new ByteBufferList(ByteBuffer.wrap("[]".getBytes()));
FilteredDataEmitter emitter = new FilteredDataEmitter() {
@Override
public boolean isPaused() {
return false;
}
};
GsonObjectParser g = new GsonObjectParser();
Future<JsonObject> ret = g.parse(emitter);
emitter.onDataAvailable(emitter, b);
emitter.getEndCallback().onCompleted(null);
final Semaphore s = new Semaphore(0);
ret.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
assertNull(result);
assertNotNull(e);
assertTrue(e instanceof ClassCastException);
s.release();
}
});
s.acquire();
}
use of com.google.gson.JsonObject in project ion by koush.
the class GsonTests method testParserCastingError.
public void testParserCastingError() throws Exception {
ByteBufferList b = new ByteBufferList(ByteBuffer.wrap("[]".getBytes()));
FilteredDataEmitter emitter = new FilteredDataEmitter() {
@Override
public boolean isPaused() {
return false;
}
};
GsonObjectParser g = new GsonObjectParser();
Future<JsonObject> ret = g.parse(emitter);
emitter.onDataAvailable(emitter, b);
emitter.getEndCallback().onCompleted(null);
try {
JsonObject j = ret.get();
fail(j.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations