Search in sources :

Example 6 with Whiteboards

use of org.apache.openmeetings.db.dto.room.Whiteboards 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 7 with Whiteboards

use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.

the class CleanupJob method cleanRoomFiles.

public void cleanRoomFiles() {
    log.trace("CleanupJob.cleanRoomFiles");
    final long now = System.currentTimeMillis();
    if (!isInitComplete()) {
        return;
    }
    try {
        File[] folders = getStreamsDir().listFiles(File::isDirectory);
        if (folders == null) {
            return;
        }
        for (File folder : folders) {
            Long roomId = null;
            if (NumberUtils.isCreatable(folder.getName())) {
                roomId = Long.valueOf(folder.getName());
                Whiteboards wbList = wbManager.get(roomId);
                for (Map.Entry<Long, Whiteboard> e : wbList.getWhiteboards().entrySet()) {
                    if (!e.getValue().isEmpty()) {
                        roomId = null;
                        break;
                    }
                }
            }
            if (roomId != null && streamClientManager.list(roomId).isEmpty()) {
                File[] files = folder.listFiles(fi -> fi.isFile() && fi.lastModified() + roomFilesTtl < now);
                if (files != null && files.length > 0) {
                    log.debug("Room files are too old and no users in the room: {}", roomId);
                    FileUtils.deleteDirectory(folder);
                }
            }
        }
    } catch (Exception e) {
        log.error("Unexpected exception while processing tests setup videous.", e);
    }
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) File(java.io.File) Map(java.util.Map) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 8 with Whiteboards

use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.

the class WhiteboardManager method clear.

public Whiteboard clear(long roomId, Long wbId) {
    Whiteboards wbs = get(roomId);
    Whiteboard wb = wbs.get(wbId);
    if (wb != null) {
        wb.clear();
        update(wbs);
    }
    return wb;
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 9 with Whiteboards

use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.

the class WhiteboardManager method remove.

public Whiteboard remove(long roomId, Long wbId) {
    Whiteboards wbs = get(roomId);
    Whiteboard wb = wbs.getWhiteboards().remove(wbId);
    update(wbs);
    return wb;
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 10 with Whiteboards

use of org.apache.openmeetings.db.dto.room.Whiteboards in project openmeetings by apache.

the class WhiteboardManager method get.

public Whiteboards get(Long roomId, Long langId) {
    if (roomId == null) {
        return null;
    }
    Whiteboards wbs = onlineWbs.get(roomId);
    if (wbs == null) {
        wbs = new Whiteboards(roomId);
        Whiteboard wb = add(wbs, langId);
        wbs.setActiveWb(wb.getId());
        update(wbs);
    }
    return wbs;
}
Also used : Whiteboards(org.apache.openmeetings.db.dto.room.Whiteboards) 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