This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push: new 63dd35e [OPENMEETINGS-2668] upload to various 'roots' should work new ca98a7a Merge branch 'master' of github.com:apache/openmeetings 63dd35e is described below commit 63dd35eee32cfe60db605793bb8ddd374e8190a4 Author: Maxim Solodovnik <solomax...@gmail.com> AuthorDate: Mon Sep 20 11:14:42 2021 +0700 [OPENMEETINGS-2668] upload to various 'roots' should work --- .../sidebar/RoomFileUploadResourceReference.java | 24 ++++++++++++---- .../web/room/sidebar/UploadDialog.html | 5 +++- .../web/room/sidebar/UploadDialog.java | 32 ++++++++++++++-------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFileUploadResourceReference.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFileUploadResourceReference.java index 7c9278f..3a8af9f 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFileUploadResourceReference.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFileUploadResourceReference.java @@ -71,7 +71,10 @@ public class RoomFileUploadResourceReference extends ResourceReference { private static final String PARAM_TO_WB_NAME = "room-upload-to-wb"; private static final String PARAM_CLEAN_NAME = "room-upload-clean"; private static final String PARAM_SID_NAME = "room-upload-sid"; - private static final String PARAM_LAST_SELECTED_NAME = "room-upload-last-selected"; + public static final String PARAM_LAST_SELECTED_ID = "room-upload-last-selected-id"; + public static final String PARAM_LAST_SELECTED_ROOM = "room-upload-last-selected-room"; + public static final String PARAM_LAST_SELECTED_OWNER = "room-upload-last-selected-pwner"; + public static final String PARAM_LAST_SELECTED_GROUP = "room-upload-last-selected-group"; private enum Status { SUCCESS , PROGRESS @@ -114,9 +117,12 @@ public class RoomFileUploadResourceReference extends ResourceReference { final boolean toWb = multiPartRequest.getPostParameters().getParameterValue(PARAM_TO_WB_NAME).toBoolean(false); final boolean clean = multiPartRequest.getPostParameters().getParameterValue(PARAM_CLEAN_NAME).toBoolean(false); - final long lastSelected = multiPartRequest.getPostParameters().getParameterValue(PARAM_LAST_SELECTED_NAME).toLong(-1L); + final long lastSelectedId = multiPartRequest.getPostParameters().getParameterValue(PARAM_LAST_SELECTED_ID).toLong(-1L); + final long lastSelectedRoom = multiPartRequest.getPostParameters().getParameterValue(PARAM_LAST_SELECTED_ROOM).toLong(-1L); + final long lastSelectedOwner = multiPartRequest.getPostParameters().getParameterValue(PARAM_LAST_SELECTED_OWNER).toLong(-1L); + final long lastSelectedGroup = multiPartRequest.getPostParameters().getParameterValue(PARAM_LAST_SELECTED_GROUP).toLong(-1L); final String uuid = randomUUID().toString(); - startRunnable(() -> convertAll(c, fileItems, uuid, toWb, clean, lastSelected)); + startRunnable(() -> convertAll(c, fileItems, uuid, toWb, clean, lastSelectedId, lastSelectedRoom, lastSelectedOwner, lastSelectedGroup)); prepareResponse(response, Status.SUCCESS, uuid, Application.getString("54", langId)); } else { @@ -157,8 +163,8 @@ public class RoomFileUploadResourceReference extends ResourceReference { return !r.isHidden(RoomElement.FILES) && c.hasRight(Right.PRESENTER); } - private void convertAll(Client c, List<FileItem> files, String uuid, boolean toWb, boolean clean, long lastSelected) { - final BaseFileItem parent = fileDao.get(lastSelected); + private void convertAll(Client c, List<FileItem> files, String uuid, boolean toWb, boolean clean, long lastSelectedId, long lastSelectedRoom, long lastSelectedOwner, long lastSelectedGroup) { + final BaseFileItem parent = fileDao.get(lastSelectedId); final long langId = getLangId(c); final long totalSize = files.stream().mapToLong(FileItem::getSize).sum(); final AtomicInteger progress = new AtomicInteger(0); @@ -170,7 +176,13 @@ public class RoomFileUploadResourceReference extends ResourceReference { f.setSize(size); f.setName(curItem.getName()); if (parent == null || BaseFileItem.Type.RECORDING == parent.getType()) { - f.setOwnerId(getUserId()); + if (lastSelectedGroup > -1) { + f.setGroupId(lastSelectedGroup); + } else if (lastSelectedRoom > -1) { + f.setRoomId(lastSelectedRoom); + } else { + f.setOwnerId(lastSelectedOwner > -1 ? lastSelectedOwner : getUserId()); + } } else { f.setRoomId(parent.getRoomId()); f.setOwnerId(parent.getOwnerId()); diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html index 1600d66..2333d66 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html @@ -38,7 +38,10 @@ </div> </div> <input wicket:id="sid" name="room-upload-sid" type="hidden"/> - <input wicket:id="lastSelected" name="room-upload-last-selected" type="hidden" value=""/> + <input wicket:id="lastSelectedId" name="room-upload-last-selected-id" type="hidden" value=""/> + <input wicket:id="lastSelectedRoom" name="room-upload-last-selected-room" type="hidden" value=""/> + <input wicket:id="lastSelectedOwner" name="room-upload-last-selected-owner" type="hidden" value=""/> + <input wicket:id="lastSelectedGroup" name="room-upload-last-selected-group" type="hidden" value=""/> </form> <div class="progress d-none"> <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div> diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java index 270e763..c1b6510 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java @@ -19,9 +19,12 @@ package org.apache.openmeetings.web.room.sidebar; import static org.apache.openmeetings.util.OpenmeetingsVariables.getMaxUploadSize; +import static org.apache.openmeetings.web.room.sidebar.RoomFileUploadResourceReference.PARAM_LAST_SELECTED_GROUP; +import static org.apache.openmeetings.web.room.sidebar.RoomFileUploadResourceReference.PARAM_LAST_SELECTED_ID; +import static org.apache.openmeetings.web.room.sidebar.RoomFileUploadResourceReference.PARAM_LAST_SELECTED_OWNER; +import static org.apache.openmeetings.web.room.sidebar.RoomFileUploadResourceReference.PARAM_LAST_SELECTED_ROOM; -import org.apache.openmeetings.core.data.file.FileProcessor; -import org.apache.openmeetings.db.dao.file.FileItemLogDao; +import org.apache.openmeetings.db.entity.file.BaseFileItem; import org.apache.openmeetings.web.app.WebSession; import org.apache.openmeetings.web.common.OmModalCloseButton; import org.apache.openmeetings.web.room.RoomPanel; @@ -35,7 +38,6 @@ import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.model.ResourceModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.resource.JavaScriptResourceReference; -import org.apache.wicket.spring.injection.annot.SpringBean; import org.apache.wicket.util.lang.Bytes; import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal; @@ -45,12 +47,10 @@ public class UploadDialog extends Modal<String> { private final WebMarkupContainer form = new WebMarkupContainer("form"); private final RoomFilePanel roomFiles; private final RoomPanel room; - private final WebMarkupContainer lastSelected = new WebMarkupContainer("lastSelected"); - - @SpringBean - private FileProcessor processor; - @SpringBean - private FileItemLogDao fileLogDao; + private final WebMarkupContainer lastSelectedId = new WebMarkupContainer("lastSelectedId"); + private final WebMarkupContainer lastSelectedRoom = new WebMarkupContainer("lastSelectedRoom"); // required for "fake" root + private final WebMarkupContainer lastSelectedOwner = new WebMarkupContainer("lastSelectedOwner"); // required for "fake" root + private final WebMarkupContainer lastSelectedGroup = new WebMarkupContainer("lastSelectedGroup"); // required for "fake" root public UploadDialog(String id, RoomPanel room, RoomFilePanel roomFiles) { super(id); @@ -72,7 +72,10 @@ public class UploadDialog extends Modal<String> { .setOutputMarkupId(true) .setOutputMarkupPlaceholderTag(true)); form.add(new WebMarkupContainer("sid").add(AttributeModifier.append("value", room.getClient().getSid())).setMarkupId("room-upload-sid").setOutputMarkupId(true)); - form.add(lastSelected.setMarkupId("room-upload-last-selected").setOutputMarkupId(true)); + form.add(lastSelectedId.setMarkupId(PARAM_LAST_SELECTED_ID).setOutputMarkupId(true)); + form.add(lastSelectedRoom.setMarkupId(PARAM_LAST_SELECTED_ROOM).setOutputMarkupId(true)); + form.add(lastSelectedOwner.setMarkupId(PARAM_LAST_SELECTED_OWNER).setOutputMarkupId(true)); + form.add(lastSelectedGroup.setMarkupId(PARAM_LAST_SELECTED_GROUP).setOutputMarkupId(true)); add(BootstrapFileUploadBehavior.INSTANCE); addButton(OmModalCloseButton.of("85")); @@ -81,7 +84,14 @@ public class UploadDialog extends Modal<String> { @Override public Modal<String> show(IPartialPageRequestHandler handler) { - lastSelected.add(AttributeModifier.replace("value", roomFiles.getLastSelected().getId())); + BaseFileItem last = roomFiles.getLastSelected(); + if (last.getId() == null) { + lastSelectedRoom.add(AttributeModifier.replace("value", last.getRoomId())); + lastSelectedOwner.add(AttributeModifier.replace("value", last.getOwnerId())); + lastSelectedGroup.add(AttributeModifier.replace("value", last.getGroupId())); + } else { + lastSelectedId.add(AttributeModifier.replace("value", last.getId())); + } handler.add(form.setVisible(true)); handler.appendJavaScript("Upload.bindUpload();"); return super.show(handler);