use of com.github.openjson.JSONObject in project openmeetings by apache.
the class Client method streamJson.
public JSONObject streamJson(String _sid, boolean self, IStreamClientManager mgr) {
JSONArray _streams = new JSONArray();
boolean avFound = false;
for (String _uid : streams) {
StreamClient rc = mgr.get(_uid);
if (rc == null) {
continue;
}
Type t = rc.getType();
if (Type.room == t) {
avFound = true;
}
_streams.put(RoomHelper.addScreenActivities(new JSONObject().put("type", t.name()).put("uid", self && Type.room == t ? uid : rc.getUid()).put("broadcastId", rc.getBroadcastId()).put("width", rc.getWidth()).put("height", rc.getHeight()), rc));
}
if (self && !avFound && hasAnyActivity(Activity.broadcastA, Activity.broadcastV)) {
_streams.put(new JSONObject().put("type", Type.room.name()).put("uid", uid).put("width", width).put("height", height));
}
return toJson(self).put("sid", _sid).put("streams", _streams);
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class RoomOptionsDTO method fromString.
public static RoomOptionsDTO fromString(String s) {
JSONObject o = new JSONObject(s);
RoomOptionsDTO ro = new RoomOptionsDTO();
ro.allowRecording = o.optBoolean("allowRecording", false);
ro.allowSameURLMultipleTimes = o.optBoolean("allowSameURLMultipleTimes", false);
ro.moderator = o.optBoolean("moderator", false);
ro.recordingId = optLong(o, "recordingId");
ro.roomId = optLong(o, "roomId");
ro.showAudioVideoTest = o.optBoolean("showAudioVideoTest", false);
return ro;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class Whiteboard method toJson.
public JSONObject toJson() {
// deep-copy
JSONObject json = new JSONObject(new JSONObject(this).toString(new NullStringer()));
// filtering
json.remove("id");
// filtering
json.remove("empty");
JSONObject items = new JSONObject();
for (Entry<String, String> e : roomItems.entrySet()) {
JSONObject o = new JSONObject(e.getValue());
// filtering
if ("Clipart".equals(o.opt("omType"))) {
if (o.has(PARAM__SRC)) {
o.put(PARAM_SRC, o.get(PARAM__SRC));
}
} else {
o.remove(PARAM_SRC);
}
o.remove(PARAM__SRC);
items.put(e.getKey(), o);
}
json.put(ITEMS_KEY, items);
return json;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class AtomReader method load.
public static void load(String url, JSONArray feed) {
HttpURLConnection con = null;
try {
con = getFeedConnection(url);
try (InputStream is = con.getInputStream()) {
XMLEventReader reader = inputFactory.createXMLEventReader(is);
int i = 0;
JSONObject obj = null;
StringBuilder val = null;
Spec spec = null;
Field f = null;
while (reader.hasNext()) {
XMLEvent evt = reader.nextEvent();
if (obj == null && evt.isStartElement()) {
StartElement start = (StartElement) evt;
String name = start.getName().getLocalPart();
if (specs.containsKey(name)) {
spec = specs.get(name);
obj = new JSONObject();
i++;
}
} else if (obj != null) {
if (evt.isStartElement()) {
StartElement start = (StartElement) evt;
String name = start.getName().getLocalPart();
if (spec.contains(name)) {
f = spec.get(name);
val = new StringBuilder();
if (f.getAttr() != null) {
Attribute a = start.getAttributeByName(new QName(f.getAttr()));
if (a != null) {
val.append(a.getValue());
}
}
}
} else if (f != null && evt.isCharacters()) {
val.append(((Characters) evt).getData());
} else if (f != null && evt.isEndElement() && f.getName().equals(((EndElement) evt).getName().getLocalPart())) {
if (!obj.has(f.getAlias())) {
obj.put(f.getAlias(), val.toString());
}
f = null;
} else if (evt.isEndElement() && spec.getName().equals(((EndElement) evt).getName().getLocalPart())) {
feed.put(obj);
obj = null;
}
}
if (i > MAX_ITEM_COUNT) {
break;
}
}
}
} catch (IOException | XMLStreamException e) {
log.error("Unexpected error while getting RSS", e);
} finally {
if (con != null) {
con.disconnect();
}
}
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class QuickPollManager method toJson.
public JSONObject toJson(Long roomId) {
boolean started = isStarted(roomId);
JSONObject o = new JSONObject().put("started", started);
if (started) {
Map<Long, Boolean> votes = map().get(roomId);
o.put("voted", votes.containsKey(getUserId()));
o.put("pros", votes.entrySet().stream().filter(e -> e.getValue()).count()).put("cons", votes.entrySet().stream().filter(e -> !e.getValue()).count());
}
return o;
}
Aggregations