Search in sources :

Example 6 with Whiteboard

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

the class WbConverter method convert.

public static Whiteboard convert(FileItem fi) {
    Whiteboard wb = new Whiteboard();
    wb.setWidth(0);
    wb.setHeight(0);
    Set<String> uids = new HashSet<>();
    List<?> wml = loadWmlFile(fi.getHash());
    for (Object wo : wml) {
        List<?> props = (List<?>) wo;
        if (!props.isEmpty()) {
            String uid = (String) props.get(props.size() - 1);
            if (uids.contains(uid)) {
                continue;
            }
            uids.add(uid);
            switch((String) props.get(0)) {
                case "letter":
                    processText(wb, props);
                    break;
                case "paint":
                    processPath(wb, props);
                    break;
                case "line":
                case "uline":
                    processLine(wb, props);
                    break;
                case "rectangle":
                case // will replace with rectangle
                "drawarrow":
                    add(wb, processRect(wb, props));
                    break;
                case "ellipse":
                    processEllipse(wb, props);
                    break;
                case "clipart":
                    processClipart(wb, props);
                    break;
                case TYPE_IMAGE:
                    processImage(wb, props);
                    break;
                case "swf":
                    processDoc(wb, props);
                    break;
                case "flv":
                    processVid(wb, props);
                    break;
            }
        }
    }
    return wb;
}
Also used : JSONObject(com.github.openjson.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) HashSet(java.util.HashSet)

Example 7 with Whiteboard

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

the class BackupImport method performImport.

public void performImport(InputStream is) throws Exception {
    userMap.clear();
    groupMap.clear();
    calendarMap.clear();
    appointmentMap.clear();
    roomMap.clear();
    messageFolderMap.clear();
    userContactMap.clear();
    fileMap.clear();
    messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
    messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
    messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
    File f = unzip(is);
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    RegistryMatcher matcher = new RegistryMatcher();
    Serializer simpleSerializer = new Persister(strategy, matcher);
    matcher.bind(Long.class, LongTransform.class);
    registry.bind(Date.class, DateConverter.class);
    BackupVersion ver = getVersion(simpleSerializer, f);
    importConfigs(f);
    importGroups(f, simpleSerializer);
    Long defaultLdapId = importLdap(f, simpleSerializer);
    importOauth(f, simpleSerializer);
    importUsers(f, defaultLdapId);
    importRooms(f);
    importRoomGroups(f);
    importChat(f);
    importCalendars(f);
    importAppointments(f);
    importMeetingMembers(f);
    importRecordings(f);
    importPrivateMsgFolders(f, simpleSerializer);
    importContacts(f);
    importPrivateMsgs(f);
    List<FileItem> files = importFiles(f);
    importPolls(f);
    importRoomFiles(f);
    log.info("Room files import complete, starting copy of files and folders");
    /*
		 * ##################### Import real files and folders
		 */
    importFolders(f);
    if (ver.compareTo(BackupVersion.get("4.0.0")) < 0) {
        for (BaseFileItem bfi : files) {
            if (bfi.isDeleted()) {
                continue;
            }
            if (BaseFileItem.Type.Presentation == bfi.getType()) {
                convertOldPresentation((FileItem) bfi);
                fileItemDao._update(bfi);
            }
            if (BaseFileItem.Type.WmlFile == bfi.getType()) {
                try {
                    Whiteboard wb = WbConverter.convert((FileItem) bfi);
                    wb.save(bfi.getFile().toPath());
                } catch (Exception e) {
                    log.error("Unexpected error while converting WB", e);
                }
            }
        }
    }
    log.info("File explorer item import complete, clearing temp files");
    FileUtils.deleteDirectory(f);
}
Also used : RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) IOException(java.io.IOException) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Persister(org.simpleframework.xml.core.Persister) StoredFile(org.apache.openmeetings.util.StoredFile) File(java.io.File) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard) Serializer(org.simpleframework.xml.Serializer)

Example 8 with Whiteboard

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

Example 9 with Whiteboard

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

the class WbPanel method saveWb.

public String saveWb(Long roomId, Long wbId, String name) {
    Whiteboard wb = wbm.get(roomId).get(wbId);
    FileItem f = new FileItem();
    f.setType(BaseFileItem.Type.WmlFile);
    f.setRoomId(roomId);
    f.setHash(UUID.randomUUID().toString());
    f.setName(name);
    f = fileDao.update(f);
    return wb.save(f.getFile().toPath());
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 10 with Whiteboard

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

Aggregations

Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)16 Whiteboards (org.apache.openmeetings.db.dto.room.Whiteboards)8 JSONObject (com.github.openjson.JSONObject)7 JSONArray (com.github.openjson.JSONArray)4 Client (org.apache.openmeetings.db.entity.basic.Client)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)3 FileItem (org.apache.openmeetings.db.entity.file.FileItem)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Entry (java.util.Map.Entry)2 TreeMap (java.util.TreeMap)2 Room (org.apache.openmeetings.db.entity.room.Room)2