use of com.github.openjson.JSONArray in project openmeetings by apache.
the class RoomDTO method get.
public static RoomDTO get(JSONObject o) {
if (o == null) {
return null;
}
RoomDTO r = new RoomDTO();
r.id = optLong(o, "id");
r.name = o.optString("name");
r.comment = o.optString("comment");
r.type = optEnum(Room.Type.class, o, "type");
r.capacity = o.optLong("capacity", 4);
r.appointment = o.optBoolean("appointment", false);
r.confno = o.optString("confno");
r.isPublic = o.optBoolean("isPublic", false);
r.demo = o.optBoolean("demo", false);
r.closed = o.optBoolean("closed", false);
r.demoTime = optInt(o, "demoTime");
r.externalId = o.optString("externalId", null);
r.externalType = o.optString("externalType", null);
r.redirectUrl = o.optString("redirectUrl");
r.moderated = o.optBoolean("moderated", false);
r.allowUserQuestions = o.optBoolean("allowUserQuestions", false);
r.allowRecording = o.optBoolean("allowRecording", false);
r.waitForRecording = o.optBoolean("waitForRecording", false);
r.audioOnly = o.optBoolean("audioOnly", false);
r.getHiddenElements().addAll(optEnumList(RoomElement.class, o.optJSONArray("hiddenElements")));
JSONArray fa = o.optJSONArray("files");
if (fa != null) {
for (int i = 0; i < fa.length(); ++i) {
r.getFiles().add(RoomFileDTO.get(fa.getJSONObject(i)));
}
}
return r;
}
use of com.github.openjson.JSONArray in project openmeetings by apache.
the class Whiteboard method clearSlide.
public JSONArray clearSlide(int slide) {
JSONArray arr = new JSONArray();
roomItems.entrySet().removeIf(e -> {
JSONObject o = new JSONObject(e.getValue());
boolean match = !FileItem.Type.Presentation.name().equals(o.optString(ATTR_FILE_TYPE)) && o.optInt(ATTR_SLIDE, -1) == slide;
if (match) {
arr.put(e);
}
return match;
});
return arr;
}
use of com.github.openjson.JSONArray in project openmeetings by apache.
the class Client method toJson.
public JSONObject toJson(boolean self) {
JSONObject u = new JSONObject();
if (user != null) {
JSONObject a = new JSONObject();
u.put("id", user.getId()).put("firstName", user.getFirstname()).put("lastName", user.getLastname()).put("address", a);
if (user.getAddress() != null) {
if (Strings.isEmpty(user.getFirstname()) && Strings.isEmpty(user.getLastname())) {
a.put("email", user.getAddress().getEmail());
}
a.put("country", user.getAddress().getCountry());
}
}
JSONObject json = new JSONObject().put("user", u).put("cuid", uid).put("uid", uid).put("rights", new JSONArray(rights)).put("activities", new JSONArray(activities)).put("pod", pod).put("width", width).put("height", height).put("self", self);
if (self) {
json.put("cam", cam).put("mic", mic);
}
return json;
}
use of com.github.openjson.JSONArray in project openmeetings by apache.
the class WbPanel method loadWhiteboards.
private StringBuilder loadWhiteboards(StringBuilder sb, Client cl, Whiteboards wbs, Set<Entry<Long, Whiteboard>> boardSet) {
for (Entry<Long, Whiteboard> entry : boardSet) {
Whiteboard wb = entry.getValue();
sb.append(new StringBuilder("WbArea.create(").append(getAddWbJson(wb)).append(");"));
JSONArray arr = new JSONArray();
for (JSONObject o : wb.list()) {
arr.put(addFileUrl(cl, wbs.getUid(), o));
}
sb.append("WbArea.load(").append(getObjWbJson(entry.getKey(), arr).toString(new NullStringer())).append(");");
}
return sb;
}
use of com.github.openjson.JSONArray in project openmeetings by apache.
the class WbPanel method sendFileToWb.
@Override
public void sendFileToWb(final BaseFileItem fi, boolean clean) {
if (isVisible() && fi.getId() != null) {
Whiteboards wbs = wbm.get(roomId);
String wuid = UUID.randomUUID().toString();
Whiteboard wb = wbs.get(wbs.getActiveWb());
switch(fi.getType()) {
case Folder:
// do nothing
break;
case WmlFile:
{
File f = fi.getFile();
if (f.exists() && f.isFile()) {
try (BufferedReader br = Files.newBufferedReader(f.toPath())) {
final boolean[] updated = { false };
JSONArray arr = getArray(new JSONObject(new JSONTokener(br)), o -> {
wb.put(o.getString("uid"), o);
updated[0] = true;
return addFileUrl(rp.getClient(), wbs.getUid(), o, _f -> updateWbSize(wb, _f));
});
if (updated[0]) {
wbm.update(roomId, wb);
}
sendWbAll(WbAction.setSize, getAddWbJson(wb));
sendWbAll(WbAction.load, getObjWbJson(wb.getId(), arr));
} catch (Exception e) {
log.error("Unexpected error while loading WB", e);
}
}
}
break;
case PollChart:
break;
default:
{
JSONObject file = new JSONObject().put(ATTR_FILE_ID, fi.getId()).put(ATTR_FILE_TYPE, fi.getType().name()).put("count", fi.getCount()).put(ATTR_TYPE, "image").put("left", UPLOAD_WB_LEFT).put("top", UPLOAD_WB_TOP).put("width", fi.getWidth() == null ? DEFAULT_WIDTH : fi.getWidth()).put("height", fi.getHeight() == null ? DEFAULT_HEIGHT : fi.getHeight()).put("uid", wuid).put(ATTR_SLIDE, wb.getSlide());
if (FileItem.Type.Video == fi.getType() || FileItem.Type.Recording == fi.getType()) {
file.put(ATTR_TYPE, "video");
file.put(PARAM_STATUS, new JSONObject().put("paused", true).put("pos", 0.0).put("updated", System.currentTimeMillis()));
}
final String ruid = wbs.getUid();
if (clean) {
clearAll(roomId, wb.getId());
}
wb.put(wuid, file);
updateWbSize(wb, fi);
wbm.update(roomId, wb);
sendWbAll(WbAction.setSize, getAddWbJson(wb));
WbWebSocketHelper.sendWbFile(roomId, wb.getId(), ruid, file, fi);
}
break;
}
}
}
Aggregations