use of org.apache.openmeetings.db.dto.room.Whiteboards 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;
}
}
}
use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.
the class WhiteboardManager method update.
public void update(long roomId, Whiteboard wb) {
Whiteboards wbs = get(roomId);
wbs.update(wb);
update(wbs);
}
use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.
the class WhiteboardManager method activate.
public void activate(long roomId, Long wbId) {
Whiteboards wbs = get(roomId);
wbs.setActiveWb(wbId);
update(wbs);
}
use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.
the class RecordingResourceReference method getRecording.
private Recording getRecording(Long id, String ruid, String uid) {
log.debug("Recording with id {} is requested", id);
Recording r = recDao.get(id);
if (r == null || r.getType() == Type.Folder || r.isDeleted()) {
return null;
}
if (id.equals(getRecordingId())) {
return r;
}
Client c = cm.get(uid);
if (c != null && c.getRoom() != null) {
Whiteboards wbs = wbm.get(c.getRoom().getId());
if (wbs != null && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
if (e.getValue().contains(r.getHash())) {
// item IS on WB
return r;
}
}
}
}
if (r.getOwnerId() == null && r.getGroupId() == null) {
// public
return r;
}
if (r.getOwnerId() != null && getUserId().equals(r.getOwnerId())) {
// own
return r;
}
if (r.getGroupId() != null && groupUserDao.isUserInGroup(r.getGroupId(), getUserId())) {
return r;
}
// external group check was added for plugin recording download
String extType = getExternalType();
if (extType != null) {
User creator = userDao.get(r.getInsertedBy());
if (extType.equals(creator.getExternalType())) {
return r;
}
}
return null;
}
use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.
the class RoomResourceReference method getFileItem.
@Override
protected FileItem getFileItem(Attributes attr) {
PageParameters params = attr.getParameters();
StringValue _id = params.get("id");
String uid = params.get("uid").toString();
Long id = null;
try {
id = _id.toOptionalLong();
} catch (NumberFormatException e) {
// no-op expected
}
WebSession ws = WebSession.get();
Client c = cm.get(uid);
if (id == null || !ws.isSignedIn() || c == null) {
return null;
}
FileItem f = (FileItem) fileDao.getAny(id);
if (f == null) {
return null;
}
String ruid = params.get("ruid").toString();
String wuid = params.get("wuid").toString();
if (c.getRoom() != null) {
Whiteboards wbs = wbManager.get(c.getRoom().getId());
if (!Strings.isEmpty(wuid) && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
JSONObject file = e.getValue().get(wuid);
if (file != null && f.getId().equals(file.optLong(ATTR_FILE_ID))) {
// item IS on WB
return f;
}
}
}
}
if (f.getGroupId() != null && groupUserDao.isUserInGroup(f.getGroupId(), getUserId())) {
return f;
}
return null;
}
Aggregations