Search in sources :

Example 1 with ATTR_SLIDE

use of org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_SLIDE 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)1 JSONObject (com.github.openjson.JSONObject)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 File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1