private void doActionWhiteboard()

in openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java [314:461]


	private void doActionWhiteboard(Client c, WbAction a, JSONObject obj, boolean redo, IPartialPageRequestHandler handler) throws IOException {
		switch (a) {
			case CREATE_OBJ:
			{
				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(a, obj, UndoObject.Type.ADD, o));
				if (redo) {
					sendWbAll(WbAction.CREATE_OBJ, obj);
				} else {
					cleanRedo(wb.getId());
					sendWbOthers(WbAction.CREATE_OBJ, obj);
				}
			}
				break;
			case MODIFY_OBJ:
			{
				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 oi = arr.getJSONObject(i);
					String uid = oi.getString("uid");
					JSONObject po = wb.get(uid);
					if (po != null) {
						undo.put(po);
						wb.put(uid, oi);
					}
				}
				if (arr.length() != 0) {
					wbm.update(roomId, wb);
					addUndo(wb.getId(), new UndoObject(a, obj, UndoObject.Type.MODIFY, undo));
					if (redo) {
						sendWbAll(WbAction.MODIFY_OBJ, obj);
					} else {
						cleanRedo(wb.getId());
						sendWbOthers(WbAction.MODIFY_OBJ, obj);
					}
				}
			}
				break;
			case DELETE_OBJ:
			{
				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 oi = arr.getJSONObject(i);
					JSONObject u = wb.remove(oi.getString("uid"));
					if (u != null) {
						undo.put(u);
					}
				}
				if (undo.length() != 0) {
					wbm.update(roomId, wb);
					addUndo(wb.getId(), new UndoObject(a, obj, UndoObject.Type.REMOVE, undo));
				}
				if (!redo) {
					cleanRedo(wb.getId());
				}
				sendWbAll(WbAction.DELETE_OBJ, obj);
			}
				break;
			case CLEAR_SLIDE:
			{
				wbm.cleanSlide(roomId, obj.getLong("wbId"), obj.getInt(ATTR_SLIDE)
						, (wb, arr) -> {
							if (!redo) {
								cleanRedo(wb.getId());
							}
							addUndo(wb.getId(), new UndoObject(a, obj, UndoObject.Type.REMOVE, arr));
						});
			}
				break;
			case SAVE:
				wb2save = obj.getLong("wbId");
				fileName.show(handler);
				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.DELETE_OBJ, 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.CREATE_OBJ, 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.MODIFY_OBJ, obj.put("obj", arr));
						}
							break;
					}
				}
			}
				break;
			case REDO:
			{
				Long wbId = obj.getLong("wbId");
				UndoObject uo = getRedo(wbId);
				if (uo != null) {
					doActionInternal(c, uo.getAction(), uo.getOrigObject(), true, handler);
				}
			}
				break;
			case VIDEO_STATUS:
			{
				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_OMTYPE))) {
					JSONObject ns = obj.getJSONObject(PARAM_STATUS);
					po.put(PARAM_STATUS, ns.put(PARAM_UPDATED, System.currentTimeMillis()));
					wbm.update(roomId, wb.put(uid, po));
					obj.put(ATTR_SLIDE, po.getInt(ATTR_SLIDE));
					sendWbAll(WbAction.VIDEO_STATUS, obj);
				}
			}
				break;
			default:
				break;
		}
	}