use of org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_SLIDE 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