Search in sources :

Example 51 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class OmAjaxClientInfoBehavior method renderHead.

@Override
public void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(MAIN_JS)));
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forScript(String.format("OmUtil.init(%s)", new JSONObject().put("debug", DEVELOPMENT == Application.get().getConfigurationType())), "om-util-init")));
}
Also used : PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) JSONObject(com.github.openjson.JSONObject)

Example 52 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class WbPanel method internalWbLoad.

@Override
void internalWbLoad(StringBuilder sb) {
    Long langId = rp.getClient().getUser().getLanguageId();
    if (!wbm.contains(roomId) && rp.getRoom().getFiles() != null && !rp.getRoom().getFiles().isEmpty()) {
        if (wbm.tryLock(roomId)) {
            try {
                TreeMap<Long, List<BaseFileItem>> files = new TreeMap<>();
                for (RoomFile rf : rp.getRoom().getFiles()) {
                    List<BaseFileItem> bfl = files.get(rf.getWbIdx());
                    if (bfl == null) {
                        files.put(rf.getWbIdx(), new ArrayList<>());
                        bfl = files.get(rf.getWbIdx());
                    }
                    bfl.add(rf.getFile());
                }
                Whiteboards _wbs = wbm.get(roomId, langId);
                for (Map.Entry<Long, List<BaseFileItem>> e : files.entrySet()) {
                    Whiteboard wb = wbm.add(roomId, langId);
                    _wbs.setActiveWb(wb.getId());
                    for (BaseFileItem fi : e.getValue()) {
                        sendFileToWb(fi, false);
                    }
                }
            } finally {
                wbm.unlock(roomId);
            }
        }
    }
    Whiteboards wbs = wbm.get(roomId, langId);
    loadWhiteboards(sb, rp.getClient(), wbs, wbm.list(roomId));
    JSONObject wbj = getWbJson(wbs.getActiveWb());
    sb.append("WbArea.activateWb(").append(wbj).append(");");
    Whiteboard wb = wbs.get(wbs.getActiveWb());
    if (wb != null) {
        sb.append("WbArea.setSlide(").append(wbj.put(ATTR_SLIDE, wb.getSlide())).append(");");
    }
    sb.append("WbArea.loadVideos();");
}
Also used : RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) TreeMap(java.util.TreeMap) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) JSONObject(com.github.openjson.JSONObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 53 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class WbPanel method clearAll.

private void clearAll(Long roomId, long wbId) {
    Whiteboard wb = wbm.get(roomId).get(wbId);
    if (wb == null) {
        return;
    }
    JSONArray arr = getArray(wb.toJson(), null);
    if (arr.length() != 0) {
        addUndo(wb.getId(), new UndoObject(UndoObject.Type.remove, arr));
    }
    wb = wbm.clear(roomId, wbId);
    sendWbAll(WbAction.clearAll, new JSONObject().put("wbId", wbId));
    sendWbAll(WbAction.setSize, getAddWbJson(wb));
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 54 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class WbWebSocketHelper method patchUrls.

private static JSONObject patchUrls(BaseFileItem fi, Client c, JSONObject _f) {
    // deep copy to ensure thread safety
    JSONObject f = new JSONObject(_f.toString());
    switch(fi.getType()) {
        case Video:
            f.put(PARAM__SRC, patchUrl(f.getString(PARAM__SRC), c));
            f.put(PARAM__POSTER, patchUrl(f.getString(PARAM__POSTER), c));
            break;
        case Recording:
            f.put(PARAM__SRC, patchUrl(f.getString(PARAM__SRC), c));
            f.put(PARAM__POSTER, patchUrl(f.getString(PARAM__POSTER), c));
            break;
        case Presentation:
            f.put(PARAM__SRC, patchUrl(f.getString(PARAM__SRC), c));
            break;
        default:
            f.put(PARAM_SRC, patchUrl(f.getString(PARAM_SRC), c));
            break;
    }
    return f;
}
Also used : JSONObject(com.github.openjson.JSONObject)

Example 55 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class WbWebSocketHelper method addFileUrl.

public static JSONObject addFileUrl(String ruid, JSONObject _file, BaseFileItem fi, Client c) {
    JSONObject file = new JSONObject(_file.toString(new NullStringer()));
    final FileSystemResourceReference ref;
    final PageParameters pp = new PageParameters().add("id", fi.getId()).add("ruid", ruid).add("wuid", _file.optString("uid"));
    if (c != null) {
        pp.add("uid", c.getUid());
    }
    file.put("deleted", !fi.exists());
    switch(fi.getType()) {
        case Video:
            ref = new RoomResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            file.put(PARAM__POSTER, urlFor(new RoomPreviewResourceReference(), pp));
            break;
        case Recording:
            ref = new Mp4RecordingResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            file.put(PARAM__POSTER, urlFor(new PngRecordingResourceReference(), pp));
            break;
        case Presentation:
            ref = new RoomResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            break;
        default:
            ref = new RoomResourceReference();
            file.put(PARAM_SRC, urlFor(ref, pp));
            break;
    }
    return file;
}
Also used : JSONObject(com.github.openjson.JSONObject) Mp4RecordingResourceReference(org.apache.openmeetings.web.user.record.Mp4RecordingResourceReference) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) RoomResourceReference(org.apache.openmeetings.web.room.RoomResourceReference) PngRecordingResourceReference(org.apache.openmeetings.web.user.record.PngRecordingResourceReference) NullStringer(org.apache.openmeetings.util.NullStringer) RoomPreviewResourceReference(org.apache.openmeetings.web.room.RoomPreviewResourceReference) FileSystemResourceReference(org.apache.wicket.resource.FileSystemResourceReference)

Aggregations

JSONObject (com.github.openjson.JSONObject)64 JSONArray (com.github.openjson.JSONArray)23 Test (org.junit.jupiter.api.Test)11 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)7 Client (org.apache.openmeetings.db.entity.basic.Client)7 ArrayList (java.util.ArrayList)6 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)6 NullStringer (org.apache.openmeetings.util.NullStringer)6 Form (javax.ws.rs.core.Form)5 Response (javax.ws.rs.core.Response)5 List (java.util.List)4 Map (java.util.Map)4 OutputStreamWriter (java.io.OutputStreamWriter)3 Writer (java.io.Writer)3 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)3 Room (org.apache.openmeetings.db.entity.room.Room)3 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)3 JSONFunction (org.apache.wicket.ajax.json.JSONFunction)3 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)3 JSONException (com.github.openjson.JSONException)2