use of org.apache.openmeetings.db.entity.room.Room in project openmeetings by apache.
the class WbPanel method processWbAction.
@Override
protected void processWbAction(WbAction a, JSONObject obj, AjaxRequestTarget target) throws IOException {
Client c = rp.getClient();
if (c == null) {
return;
}
switch(a) {
case createObj:
case modifyObj:
{
JSONObject o = obj.optJSONObject("obj");
if (o != null && "pointer".equals(o.getString(ATTR_TYPE))) {
sendWbOthers(a, obj);
return;
}
}
break;
case downloadPdf:
{
boolean moder = c.hasRight(Room.Right.moderator);
Room r = rp.getRoom();
if ((moder && !r.isHidden(RoomElement.ActionMenu)) || (!moder && r.isAllowUserQuestions())) {
try (PDDocument doc = new PDDocument()) {
JSONArray arr = obj.getJSONArray("slides");
for (int i = 0; i < arr.length(); ++i) {
String base64Image = arr.getString(i).split(",")[1];
byte[] bb = Base64.decodeBase64(base64Image);
BufferedImage img = ImageIO.read(new ByteArrayInputStream(bb));
float width = img.getWidth();
float height = img.getHeight();
PDPage page = new PDPage(new PDRectangle(width, height));
PDImageXObject pdImageXObject = LosslessFactory.createFromImage(doc, img);
try (PDPageContentStream contentStream = new PDPageContentStream(doc, page, AppendMode.APPEND, false)) {
contentStream.drawImage(pdImageXObject, 0, 0, width, height);
}
doc.addPage(page);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.save(baos);
rp.startDownload(target, baos.toByteArray());
}
}
return;
}
case loadVideos:
{
StringBuilder sb = new StringBuilder("WbArea.initVideos(");
JSONArray arr = new JSONArray();
for (Entry<Long, Whiteboard> entry : wbm.list(roomId)) {
Whiteboard wb = entry.getValue();
for (JSONObject o : wb.list()) {
String ft = o.optString(ATTR_FILE_TYPE);
if (BaseFileItem.Type.Recording.name().equals(ft) || BaseFileItem.Type.Video.name().equals(ft)) {
JSONObject _sts = o.optJSONObject(PARAM_STATUS);
if (_sts == null) {
continue;
}
// copy
JSONObject sts = new JSONObject(_sts.toString());
sts.put("pos", sts.getDouble("pos") + (System.currentTimeMillis() - sts.getLong("updated")) * 1. / 1000);
arr.put(new JSONObject().put("wbId", wb.getId()).put("uid", o.getString("uid")).put(ATTR_SLIDE, o.getString(ATTR_SLIDE)).put(PARAM_STATUS, sts));
}
}
}
sb.append(arr.toString()).append(");");
target.appendJavaScript(sb);
return;
}
default:
break;
}
// presenter-right
if (c.hasRight(Right.presenter)) {
switch(a) {
case createWb:
{
Whiteboard wb = wbm.add(roomId, c.getUser().getLanguageId());
sendWbAll(WbAction.createWb, getAddWbJson(wb));
}
break;
case removeWb:
{
long id = obj.optLong("wbId", -1);
if (id > -1) {
wbm.remove(roomId, id);
sendWbAll(WbAction.removeWb, obj);
}
}
break;
case activateWb:
{
long _id = obj.optLong("wbId", -1);
if (_id > -1) {
wbm.activate(roomId, _id);
sendWbAll(WbAction.activateWb, obj);
}
}
break;
case renameWb:
{
Whiteboard wb = wbm.get(roomId).get(obj.optLong("wbId", -1));
if (wb != null) {
wbm.update(roomId, wb.setName(obj.getString("name")));
sendWbAll(WbAction.renameWb, obj);
}
}
break;
case setSlide:
{
Whiteboard wb = wbm.get(roomId).get(obj.optLong("wbId", -1));
if (wb != null) {
wb.setSlide(obj.optInt(ATTR_SLIDE, 0));
wbm.update(roomId, wb);
sendWbOthers(WbAction.setSlide, obj);
}
}
break;
case clearAll:
{
clearAll(roomId, obj.getLong("wbId"));
}
break;
case setSize:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
wb.setZoom(obj.getDouble("zoom"));
wb.setZoomMode(ZoomMode.valueOf(obj.getString("zoomMode")));
wbm.update(roomId, wb);
sendWbOthers(WbAction.setSize, getAddWbJson(wb));
}
break;
default:
break;
}
}
// wb-right
if (c.hasRight(Right.presenter) || c.hasRight(Right.whiteBoard)) {
switch(a) {
case createObj:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
JSONObject o = obj.getJSONObject("obj");
wb.put(o.getString("uid"), o);
wbm.update(roomId, wb);
addUndo(wb.getId(), new UndoObject(UndoObject.Type.add, o));
sendWbOthers(WbAction.createObj, obj);
}
break;
case modifyObj:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
JSONArray arr = obj.getJSONArray("obj");
JSONArray undo = new JSONArray();
for (int i = 0; i < arr.length(); ++i) {
JSONObject _o = arr.getJSONObject(i);
String uid = _o.getString("uid");
JSONObject po = wb.get(uid);
if (po != null) {
undo.put(po);
wb.put(uid, _o);
}
}
if (arr.length() != 0) {
wbm.update(roomId, wb);
addUndo(wb.getId(), new UndoObject(UndoObject.Type.modify, undo));
}
sendWbOthers(WbAction.modifyObj, obj);
}
break;
case deleteObj:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
JSONArray arr = obj.getJSONArray("obj");
JSONArray undo = new JSONArray();
for (int i = 0; i < arr.length(); ++i) {
JSONObject _o = arr.getJSONObject(i);
JSONObject u = wb.remove(_o.getString("uid"));
if (u != null) {
undo.put(u);
}
}
if (undo.length() != 0) {
wbm.update(roomId, wb);
addUndo(wb.getId(), new UndoObject(UndoObject.Type.remove, undo));
}
sendWbAll(WbAction.deleteObj, obj);
}
break;
case clearSlide:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
JSONArray arr = wb.clearSlide(obj.getInt(ATTR_SLIDE));
if (arr.length() != 0) {
wbm.update(roomId, wb);
addUndo(wb.getId(), new UndoObject(UndoObject.Type.remove, arr));
}
sendWbAll(WbAction.clearSlide, obj);
}
break;
case save:
wb2save = obj.getLong("wbId");
fileName.open(target);
break;
case undo:
{
Long wbId = obj.getLong("wbId");
UndoObject uo = getUndo(wbId);
if (uo != null) {
Whiteboard wb = wbm.get(roomId).get(wbId);
switch(uo.getType()) {
case add:
{
JSONObject o = new JSONObject(uo.getObject());
wb.remove(o.getString("uid"));
wbm.update(roomId, wb);
sendWbAll(WbAction.deleteObj, obj.put("obj", new JSONArray().put(o)));
}
break;
case remove:
{
JSONArray arr = new JSONArray(uo.getObject());
for (int i = 0; i < arr.length(); ++i) {
JSONObject o = arr.getJSONObject(i);
wb.put(o.getString("uid"), o);
}
wbm.update(roomId, wb);
sendWbAll(WbAction.createObj, obj.put("obj", new JSONArray(uo.getObject())));
}
break;
case modify:
{
JSONArray arr = new JSONArray(uo.getObject());
for (int i = 0; i < arr.length(); ++i) {
JSONObject o = arr.getJSONObject(i);
wb.put(o.getString("uid"), o);
}
wbm.update(roomId, wb);
sendWbAll(WbAction.modifyObj, obj.put("obj", arr));
}
break;
}
}
}
break;
case videoStatus:
{
Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
String uid = obj.getString("uid");
JSONObject po = wb.get(uid);
if (po != null && "video".equals(po.getString(ATTR_TYPE))) {
JSONObject ns = obj.getJSONObject(PARAM_STATUS);
po.put(PARAM_STATUS, ns.put("updated", System.currentTimeMillis()));
wbm.update(roomId, wb.put(uid, po));
obj.put(ATTR_SLIDE, po.getInt(ATTR_SLIDE));
sendWbAll(WbAction.videoStatus, obj);
}
}
break;
default:
break;
}
}
}
use of org.apache.openmeetings.db.entity.room.Room in project openmeetings by apache.
the class GroupLogoResourceReference method getResource.
@Override
public IResource getResource() {
return new FileSystemResource() {
private static final long serialVersionUID = 1L;
@Override
protected String getMimeType() throws IOException {
return PNG_MIME_TYPE;
}
@Override
protected ResourceResponse newResourceResponse(Attributes attrs) {
Long id = null;
boolean allowed = false;
WebSession ws = WebSession.get();
if (ws.isSignedIn()) {
PageParameters params = attrs.getParameters();
StringValue _id = params.get("id");
try {
id = _id.toOptionalLong();
} catch (Exception e) {
// no-op expected
}
allowed = id == null || hasAdminLevel(getRights()) || null != groupUserDao.getByGroupAndUser(id, getUserId());
if (!allowed && ws.getInvitation() != null) {
Room r = ws.getInvitation().getRoom() == null ? null : roomDao.get(ws.getInvitation().getRoom().getId());
if (r != null && r.getGroups() != null) {
for (RoomGroup rg : r.getGroups()) {
if (id.equals(rg.getGroup().getId())) {
allowed = true;
break;
}
}
}
}
}
if (allowed) {
return createResourceResponse(attrs, getGroupLogo(id, true).toPath());
} else {
log.debug("Not authorized");
ResourceResponse rr = new ResourceResponse();
rr.setError(HttpServletResponse.SC_FORBIDDEN);
return rr;
}
}
};
}
use of org.apache.openmeetings.db.entity.room.Room in project openmeetings by apache.
the class OmUrlFragment method getPanel.
public static BasePanel getPanel(AreaKeys area, String type) {
BasePanel basePanel = null;
switch(area) {
case admin:
if (TYPE_USER.equals(type)) {
basePanel = new UsersPanel(CHILD_ID);
} else if (TYPE_CONNECTION.equals(type)) {
basePanel = new ConnectionsPanel(CHILD_ID);
} else if (TYPE_GROUP.equals(type)) {
basePanel = new GroupsPanel(CHILD_ID);
} else if (TYPE_ROOM.equals(type)) {
basePanel = new RoomsPanel(CHILD_ID);
} else if (TYPE_CONFIG.equals(type)) {
basePanel = new ConfigsPanel(CHILD_ID);
} else if (TYPE_LANG.equals(type)) {
basePanel = new LangPanel(CHILD_ID);
} else if (TYPE_LDAP.equals(type)) {
basePanel = new LdapsPanel(CHILD_ID);
} else if (TYPE_BACKUP.equals(type)) {
basePanel = new BackupPanel(CHILD_ID);
} else if (TYPE_OAUTH2.equals(type)) {
basePanel = new OAuthPanel(CHILD_ID);
} else if (TYPE_EMAIL.equals(type)) {
basePanel = new EmailPanel(CHILD_ID);
}
break;
case profile:
if (TYPE_MESSAGES.equals(type)) {
basePanel = new SettingsPanel(CHILD_ID, MESSAGES_TAB_ID);
} else if (TYPE_EDIT.equals(type)) {
basePanel = new SettingsPanel(CHILD_ID, EDIT_PROFILE_TAB_ID);
}
break;
case room:
try {
Long roomId = Long.valueOf(type);
Room r = Application.get().getBean(RoomDao.class).get(roomId);
if (r != null) {
basePanel = new RoomPanel(CHILD_ID, r);
}
} catch (NumberFormatException ne) {
// skip it, bad roomid passed
}
if (basePanel == null) {
basePanel = new OmDashboardPanel(CHILD_ID);
}
break;
case rooms:
MenuParams params = MenuParams.publicTabButton;
if (TYPE_GROUP.equals(type)) {
params = MenuParams.privateTabButton;
} else if (Application.get().getBean(ConfigurationDao.class).getBool(CONFIG_MYROOMS_ENABLED, true) && TYPE_MY.equals(type)) {
params = MenuParams.myTabButton;
}
basePanel = new RoomsSelectorPanel(CHILD_ID, params);
break;
case user:
if (TYPE_CALENDAR.equals(type)) {
basePanel = new CalendarPanel(CHILD_ID);
} else if (TYPE_RECORDINGS.equals(type)) {
basePanel = new RecordingsPanel(CHILD_ID);
} else {
basePanel = new OmDashboardPanel(CHILD_ID);
}
break;
default:
break;
}
return basePanel;
}
use of org.apache.openmeetings.db.entity.room.Room in project openmeetings by apache.
the class VideoInfo method update.
public VideoInfo update(AjaxRequestTarget target, BaseFileItem _r) {
boolean reConvEnabled = false;
boolean exists = false;
if (_r instanceof Recording) {
Recording r = (Recording) _r;
rm.setObject(r);
exists = r.exists();
try {
String name = null;
if (r.getRoomId() != null) {
Room room = roomDao.get(r.getRoomId());
if (room != null) {
name = room.getName();
isInterview = Room.Type.interview == room.getType();
}
}
roomName.setObject(name);
} catch (Exception e) {
// no-op
}
if (r.getOwnerId() != null && r.getOwnerId().equals(getUserId()) && r.getStatus() != Status.RECORDING && r.getStatus() != Status.CONVERTING) {
List<RecordingMetaData> metas = metaDao.getByRecording(r.getId());
for (RecordingMetaData meta : metas) {
if (r.getRoomId() == null || !getRecordingMetaData(r.getRoomId(), meta.getStreamName()).exists()) {
break;
}
}
reConvEnabled = !metas.isEmpty();
}
}
reConvert.setEnabled(reConvEnabled);
downloadBtn.setEnabled(exists && !_r.isReadOnly());
share.setEnabled(exists && !_r.isReadOnly());
if (target != null) {
target.add(form);
}
return this;
}
use of org.apache.openmeetings.db.entity.room.Room in project openmeetings by apache.
the class RoomsPanel method updateRoomDetails.
void updateRoomDetails(AjaxRequestTarget target) {
clients.setDefaultModelObject(cm.listByRoom(roomId));
Room room = roomDao.get(roomId);
roomIdLbl.setDefaultModelObject(room.getId());
roomNameLbl.setDefaultModelObject(room.getName());
roomCommentLbl.setDefaultModelObject(room.getComment());
target.add(clientsContainer, details);
}
Aggregations