Search in sources :

Example 1 with Whiteboards

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;
        }
    }
}
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)

Example 2 with Whiteboards

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);
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards)

Example 3 with Whiteboards

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);
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards)

Example 4 with Whiteboards

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;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) Recording(org.apache.openmeetings.db.entity.record.Recording) Client(org.apache.openmeetings.db.entity.basic.Client) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 5 with Whiteboards

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;
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) WebSession(org.apache.openmeetings.web.app.WebSession) Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) JSONObject(com.github.openjson.JSONObject) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue) Client(org.apache.openmeetings.db.entity.basic.Client) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Aggregations

Whiteboards (org.apache.openmeetings.db.dto.room.Whiteboards)11 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)9 JSONObject (com.github.openjson.JSONObject)3 Map (java.util.Map)3 Client (org.apache.openmeetings.db.entity.basic.Client)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 FileItem (org.apache.openmeetings.db.entity.file.FileItem)2 JSONArray (com.github.openjson.JSONArray)1 JSONTokener (com.github.openjson.JSONTokener)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1