Search in sources :

Example 11 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem 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 12 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class BaseFileItemConverter method read.

@Override
public BaseFileItem read(InputNode node) throws Exception {
    long oldId = toLong(node.getValue());
    long newId = idMap.containsKey(oldId) ? idMap.get(oldId) : oldId;
    BaseFileItem r = fileDao.get(newId);
    return r == null ? new FileItem() : r;
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) FileItem(org.apache.openmeetings.db.entity.file.FileItem)

Example 13 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class RoomPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    // let's refresh user in client
    cm.update(getClient().updateUser(userDao));
    Component accessDenied = new WebMarkupContainer(ACCESS_DENIED_ID).setVisible(false);
    room.add(AttributeModifier.append(ATTR_CLASS, r.getType().name()));
    room.add(menu = new RoomMenuPanel("menu", this));
    room.add(AttributeModifier.append("data-room-id", r.getId()));
    if (interview) {
        room.add(new WebMarkupContainer("wb-area").add(wb));
    } else {
        Droppable<BaseFileItem> wbArea = new Droppable<BaseFileItem>("wb-area") {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("hoverClass", Options.asString("ui-state-hover"));
                behavior.setOption("accept", Options.asString(".recorditem, .fileitem, .readonlyitem"));
            }

            @Override
            public void onDrop(AjaxRequestTarget target, Component component) {
                Object o = component.getDefaultModelObject();
                if (wb.isVisible() && o instanceof BaseFileItem) {
                    BaseFileItem f = (BaseFileItem) o;
                    if (sidebar.getFilesPanel().isSelected(f)) {
                        for (Entry<String, BaseFileItem> e : sidebar.getFilesPanel().getSelected().entrySet()) {
                            wb.sendFileToWb(e.getValue(), false);
                        }
                    } else {
                        wb.sendFileToWb(f, false);
                    }
                }
            }
        };
        room.add(wbArea.add(wb));
    }
    room.add(roomEnter);
    room.add(sidebar = new RoomSidebar("sidebar", this));
    add(roomClosed = new RedirectMessageDialog("room-closed", "1098", r.isClosed(), r.getRedirectURL()));
    if (r.isClosed()) {
        room.setVisible(false);
    } else if (cm.listByRoom(r.getId()).size() >= r.getCapacity()) {
        accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, getString("99"), menu);
        room.setVisible(false);
    } else if (r.getId().equals(WebSession.get().getRoomId())) {
    // secureHash/invitationHash, already checked
    } else {
        boolean allowed = false;
        String deniedMessage = null;
        if (r.isAppointment()) {
            Appointment a = apptDao.getByRoom(r.getId());
            if (a != null && !a.isDeleted()) {
                boolean isOwner = a.getOwner().getId().equals(getUserId());
                allowed = isOwner;
                log.debug("appointed room, isOwner ? {}", isOwner);
                if (!allowed) {
                    for (MeetingMember mm : a.getMeetingMembers()) {
                        if (getUserId().equals(mm.getUser().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                }
                if (allowed) {
                    Calendar c = WebSession.getCalendar();
                    if (isOwner || c.getTime().after(a.getStart()) && c.getTime().before(a.getEnd())) {
                        eventDetail = new EventDetailDialog(EVENT_DETAILS_ID, a);
                    } else {
                        allowed = false;
                        deniedMessage = String.format("%s %s - %s", getString("error.hash.period"), getDateFormat().format(a.getStart()), getDateFormat().format(a.getEnd()));
                    }
                }
            }
        } else {
            allowed = r.getIspublic() || (r.getOwnerId() != null && r.getOwnerId().equals(getUserId()));
            log.debug("public ? " + r.getIspublic() + ", ownedId ? " + r.getOwnerId() + " " + allowed);
            if (!allowed) {
                User u = getClient().getUser();
                for (RoomGroup ro : r.getGroups()) {
                    for (GroupUser ou : u.getGroupUsers()) {
                        if (ro.getGroup().getId().equals(ou.getGroup().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                    if (allowed) {
                        break;
                    }
                }
            }
        }
        if (!allowed) {
            if (deniedMessage == null) {
                deniedMessage = getString("1599");
            }
            accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, deniedMessage, menu);
            room.setVisible(false);
        }
    }
    waitForModerator = new MessageDialog("wait-for-moderator", getString("204"), getString("696"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    waitApplyModeration = new MessageDialog("wait-apply-moderation", getString("204"), getString(r.isModerated() ? "641" : "498"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    add(room, accessDenied, eventDetail, waitForModerator, waitApplyModeration);
    if (r.isWaitForRecording()) {
        add(new MessageDialog("wait-for-recording", getString("1316"), getString("1315"), DialogButtons.OK, DialogIcon.LIGHT) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("autoOpen", true);
                behavior.setOption("resizable", false);
            }

            @Override
            public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            // no-op
            }
        });
    } else {
        add(new WebMarkupContainer("wait-for-recording").setVisible(false));
    }
    if (room.isVisible()) {
        add(new NicknameDialog("nickname", this));
        add(download);
        add(new BaseWebSocketBehavior("media"));
    } else {
        add(new WebMarkupContainer("nickname").setVisible(false));
    }
    add(clientKicked = new MessageDialog("client-kicked", getString("797"), getString("606"), DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            menu.exit(handler);
        }
    });
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) RoomSidebar(org.apache.openmeetings.web.room.sidebar.RoomSidebar) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) Component(org.apache.wicket.Component) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) Calendar(java.util.Calendar) RoomMenuPanel(org.apache.openmeetings.web.room.menu.RoomMenuPanel) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) BaseWebSocketBehavior(org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) JSONObject(com.github.openjson.JSONObject) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup)

Example 14 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem in project openmeetings by apache.

the class UploadDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    List<FileUpload> ful = uploadField.getFileUploads();
    if (ful != null) {
        boolean clean = cleanWb.getModelObject();
        for (FileUpload fu : ful) {
            FileItem f = new FileItem();
            f.setSize(fu.getSize());
            f.setName(fu.getClientFileName());
            BaseFileItem parent = roomFiles.getLastSelected();
            if (parent == null || !(parent instanceof FileItem)) {
                f.setOwnerId(getUserId());
            } else {
                f.setRoomId(parent.getRoomId());
                f.setOwnerId(parent.getOwnerId());
                f.setGroupId(parent.getGroupId());
                if (parent.getId() != null) {
                    f.setParentId(BaseFileItem.Type.Folder == parent.getType() ? parent.getId() : parent.getParentId());
                }
            }
            f.setInsertedBy(getUserId());
            try {
                ProcessResultList logs = processor.processFile(f, fu.getInputStream());
                for (ProcessResult res : logs.getJobs()) {
                    fileLogDao.add(res.getProcess(), f, res);
                }
                room.getSidebar().updateFiles(target);
                if (logs.hasError()) {
                    form.error(getString("convert.errors.file"));
                } else {
                    if (toWb.getModelObject()) {
                        room.getWb().sendFileToWb(f, clean);
                        clean = false;
                    }
                }
            } catch (Exception e) {
                form.error(e.getMessage());
            } finally {
                fu.closeStreams();
                fu.delete();
            }
        }
        if (form.hasError()) {
            onError(target);
        } else {
            close(target, null);
        }
    }
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) ProcessResult(org.apache.openmeetings.util.process.ProcessResult) FileUpload(org.apache.wicket.markup.html.form.upload.FileUpload) ProcessResultList(org.apache.openmeetings.util.process.ProcessResultList)

Example 15 with BaseFileItem

use of org.apache.openmeetings.db.entity.file.BaseFileItem 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

BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)18 FileItem (org.apache.openmeetings.db.entity.file.FileItem)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 ArrayList (java.util.ArrayList)6 RoomFile (org.apache.openmeetings.db.entity.room.RoomFile)4 JSONObject (com.github.openjson.JSONObject)3 File (java.io.File)3 List (java.util.List)3 Recording (org.apache.openmeetings.db.entity.record.Recording)3 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)2 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)2 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 FileItemDao (org.apache.openmeetings.db.dao.file.FileItemDao)2 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)2 Client (org.apache.openmeetings.db.entity.basic.Client)2 Room (org.apache.openmeetings.db.entity.room.Room)2