Search in sources :

Example 1 with JSONArray

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

the class RoomDTO method get.

public static RoomDTO get(JSONObject o) {
    if (o == null) {
        return null;
    }
    RoomDTO r = new RoomDTO();
    r.id = optLong(o, "id");
    r.name = o.optString("name");
    r.comment = o.optString("comment");
    r.type = optEnum(Room.Type.class, o, "type");
    r.capacity = o.optLong("capacity", 4);
    r.appointment = o.optBoolean("appointment", false);
    r.confno = o.optString("confno");
    r.isPublic = o.optBoolean("isPublic", false);
    r.demo = o.optBoolean("demo", false);
    r.closed = o.optBoolean("closed", false);
    r.demoTime = optInt(o, "demoTime");
    r.externalId = o.optString("externalId", null);
    r.externalType = o.optString("externalType", null);
    r.redirectUrl = o.optString("redirectUrl");
    r.moderated = o.optBoolean("moderated", false);
    r.allowUserQuestions = o.optBoolean("allowUserQuestions", false);
    r.allowRecording = o.optBoolean("allowRecording", false);
    r.waitForRecording = o.optBoolean("waitForRecording", false);
    r.audioOnly = o.optBoolean("audioOnly", false);
    r.getHiddenElements().addAll(optEnumList(RoomElement.class, o.optJSONArray("hiddenElements")));
    JSONArray fa = o.optJSONArray("files");
    if (fa != null) {
        for (int i = 0; i < fa.length(); ++i) {
            r.getFiles().add(RoomFileDTO.get(fa.getJSONObject(i)));
        }
    }
    return r;
}
Also used : RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) JSONArray(com.github.openjson.JSONArray)

Example 2 with JSONArray

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

the class Whiteboard method clearSlide.

public JSONArray clearSlide(int slide) {
    JSONArray arr = new JSONArray();
    roomItems.entrySet().removeIf(e -> {
        JSONObject o = new JSONObject(e.getValue());
        boolean match = !FileItem.Type.Presentation.name().equals(o.optString(ATTR_FILE_TYPE)) && o.optInt(ATTR_SLIDE, -1) == slide;
        if (match) {
            arr.put(e);
        }
        return match;
    });
    return arr;
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray)

Example 3 with JSONArray

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

the class Client method toJson.

public JSONObject toJson(boolean self) {
    JSONObject u = new JSONObject();
    if (user != null) {
        JSONObject a = new JSONObject();
        u.put("id", user.getId()).put("firstName", user.getFirstname()).put("lastName", user.getLastname()).put("address", a);
        if (user.getAddress() != null) {
            if (Strings.isEmpty(user.getFirstname()) && Strings.isEmpty(user.getLastname())) {
                a.put("email", user.getAddress().getEmail());
            }
            a.put("country", user.getAddress().getCountry());
        }
    }
    JSONObject json = new JSONObject().put("user", u).put("cuid", uid).put("uid", uid).put("rights", new JSONArray(rights)).put("activities", new JSONArray(activities)).put("pod", pod).put("width", width).put("height", height).put("self", self);
    if (self) {
        json.put("cam", cam).put("mic", mic);
    }
    return json;
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray)

Example 4 with JSONArray

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

the class WbPanel method loadWhiteboards.

private StringBuilder loadWhiteboards(StringBuilder sb, Client cl, Whiteboards wbs, Set<Entry<Long, Whiteboard>> boardSet) {
    for (Entry<Long, Whiteboard> entry : boardSet) {
        Whiteboard wb = entry.getValue();
        sb.append(new StringBuilder("WbArea.create(").append(getAddWbJson(wb)).append(");"));
        JSONArray arr = new JSONArray();
        for (JSONObject o : wb.list()) {
            arr.put(addFileUrl(cl, wbs.getUid(), o));
        }
        sb.append("WbArea.load(").append(getObjWbJson(entry.getKey(), arr).toString(new NullStringer())).append(");");
    }
    return sb;
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray) NullStringer(org.apache.openmeetings.util.NullStringer) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 5 with JSONArray

use of com.github.openjson.JSONArray 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;
        }
    }
}
Also used : JSONTokener(com.github.openjson.JSONTokener) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) Arrays(java.util.Arrays) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) Strings(org.apache.directory.api.util.Strings) FileItemDao(org.apache.openmeetings.db.dao.file.FileItemDao) LoggerFactory(org.slf4j.LoggerFactory) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) WbWebSocketHelper.getWbJson(org.apache.openmeetings.web.room.wb.WbWebSocketHelper.getWbJson) PDImageXObject(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) Base64(org.apache.commons.codec.binary.Base64) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) WhiteboardManager(org.apache.openmeetings.web.app.WhiteboardManager) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) JSONArray(com.github.openjson.JSONArray) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Right(org.apache.openmeetings.db.entity.room.Room.Right) ListView(org.apache.wicket.markup.html.list.ListView) ResourceReference(org.apache.wicket.request.resource.ResourceReference) ZoomMode(org.apache.openmeetings.db.dto.room.Whiteboard.ZoomMode) Method(org.apache.wicket.ajax.attributes.AjaxRequestAttributes.Method) NullStringer(org.apache.openmeetings.util.NullStringer) BufferedImage(java.awt.image.BufferedImage) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) ListItem(org.apache.wicket.markup.html.list.ListItem) Set(java.util.Set) UUID(java.util.UUID) Room(org.apache.openmeetings.db.entity.room.Room) List(java.util.List) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) WbWebSocketHelper.getObjWbJson(org.apache.openmeetings.web.room.wb.WbWebSocketHelper.getObjWbJson) Entry(java.util.Map.Entry) LosslessFactory(org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory) PDPage(org.apache.pdfbox.pdmodel.PDPage) JSONTokener(com.github.openjson.JSONTokener) ATTR_TYPE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_TYPE) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NameDialog(org.apache.openmeetings.web.common.NameDialog) HashMap(java.util.HashMap) Deque(java.util.Deque) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PDPageContentStream(org.apache.pdfbox.pdmodel.PDPageContentStream) OmFileHelper(org.apache.openmeetings.util.OmFileHelper) ATTR_FILE_TYPE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_FILE_TYPE) AppendMode(org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode) PARAM_STATUS(org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_STATUS) LinkedList(java.util.LinkedList) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) RoomPanel(org.apache.openmeetings.web.room.RoomPanel) ITEMS_KEY(org.apache.openmeetings.db.dto.room.Whiteboard.ITEMS_KEY) Logger(org.slf4j.Logger) ATTR_CLASS(org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_CLASS) ATTR_SLIDE(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_SLIDE) Files(java.nio.file.Files) ATTR_FILE_ID(org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_FILE_ID) IOException(java.io.IOException) Client(org.apache.openmeetings.db.entity.basic.Client) AttributeModifier.append(org.apache.wicket.AttributeModifier.append) FileItem(org.apache.openmeetings.db.entity.file.FileItem) JSONObject(com.github.openjson.JSONObject) File(java.io.File) Consumer(java.util.function.Consumer) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle) TreeMap(java.util.TreeMap) BufferedReader(java.io.BufferedReader) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) JSONObject(com.github.openjson.JSONObject) BufferedReader(java.io.BufferedReader) JSONArray(com.github.openjson.JSONArray) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) File(java.io.File) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) IOException(java.io.IOException)

Aggregations

JSONArray (com.github.openjson.JSONArray)35 JSONObject (com.github.openjson.JSONObject)30 Test (org.junit.jupiter.api.Test)11 List (java.util.List)5 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)5 ArrayList (java.util.ArrayList)4 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)4 Form (javax.ws.rs.core.Form)3 Response (javax.ws.rs.core.Response)3 JSONException (com.github.openjson.JSONException)2 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Client (org.apache.openmeetings.db.entity.basic.Client)2 Room (org.apache.openmeetings.db.entity.room.Room)2 RoomElement (org.apache.openmeetings.db.entity.room.Room.RoomElement)2 NullStringer (org.apache.openmeetings.util.NullStringer)2 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)2