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 cdcf9b2  [OPENMEETINGS-1836] another attempt to fix drop file URL
cdcf9b2 is described below

commit cdcf9b2b958db54de99397ab0990fa75fca055cd
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Sun Mar 11 21:15:16 2018 +0700

    [OPENMEETINGS-1836] another attempt to fix drop file URL
---
 .../openmeetings/core/util/WebSocketHelper.java    |  8 ----
 .../openmeetings/db/dto/room/Whiteboard.java       | 11 +++--
 .../openmeetings/backup/converter/WbConverter.java |  3 +-
 .../openmeetings/util/OpenmeetingsVariables.java   |  2 +
 .../apache/openmeetings/web/common/ImagePanel.java |  3 +-
 .../web/room/wb/WbWebSocketHelper.java             | 52 ++++++++++++++++++----
 6 files changed, 56 insertions(+), 23 deletions(-)

diff --git 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
index 1a4579c..5e2b568 100644
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
+++ 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
@@ -46,13 +46,11 @@ import org.apache.openmeetings.db.util.ws.RoomMessage;
 import org.apache.openmeetings.db.util.ws.TextRoomMessage;
 import org.apache.openmeetings.util.ws.IClusterWsMessage;
 import org.apache.wicket.Application;
-import org.apache.wicket.ThreadContext;
 import org.apache.wicket.protocol.ws.WebSocketSettings;
 import org.apache.wicket.protocol.ws.api.IWebSocketConnection;
 import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry;
 import org.apache.wicket.protocol.ws.api.registry.PageIdKey;
 import org.apache.wicket.protocol.ws.concurrent.Executor;
-import org.apache.wicket.request.cycle.RequestCycle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -213,11 +211,8 @@ public class WebSocketHelper {
                if (publish) {
                        publish(new WsMessageAll(m));
                }
-               final RequestCycle requestCycle = 
ThreadContext.getRequestCycle();
                new Thread(() -> {
                        Application app = (Application)getApp();
-                       ThreadContext.setRequestCycle(requestCycle);
-                       ThreadContext.setApplication(app);
                        WebSocketSettings settings = 
WebSocketSettings.Holder.get(app);
                        IWebSocketConnectionRegistry reg = 
settings.getConnectionRegistry();
                        Executor executor = 
settings.getWebSocketPushMessageExecutor();
@@ -257,11 +252,8 @@ public class WebSocketHelper {
                        , BiConsumer<IWebSocketConnection, Client> consumer
                        , Predicate<Client> check)
        {
-               final RequestCycle requestCycle = 
ThreadContext.getRequestCycle();
                new Thread(() -> {
                        Application app = (Application)getApp();
-                       ThreadContext.setRequestCycle(requestCycle);
-                       ThreadContext.setApplication(app);
                        WebSocketSettings settings = 
WebSocketSettings.Holder.get(app);
                        IWebSocketConnectionRegistry reg = 
settings.getConnectionRegistry();
                        Executor executor = 
settings.getWebSocketPushMessageExecutor();
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/Whiteboard.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/Whiteboard.java
index c85fd58..229cb1e 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/Whiteboard.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/Whiteboard.java
@@ -18,6 +18,9 @@
  */
 package org.apache.openmeetings.db.dto.room;
 
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_SRC;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM__SRC;
+
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.Serializable;
@@ -197,13 +200,13 @@ public class Whiteboard implements Serializable {
                        JSONObject o = new JSONObject(e.getValue());
                        //filtering
                        if ("Clipart".equals(o.opt("omType"))) {
-                               if (o.has("_src")) {
-                                       o.put("src", o.get("_src"));
+                               if (o.has(PARAM__SRC)) {
+                                       o.put(PARAM_SRC, o.get(PARAM__SRC));
                                }
                        } else {
-                               o.remove("src");
+                               o.remove(PARAM_SRC);
                        }
-                       o.remove("_src");
+                       o.remove(PARAM__SRC);
                        items.put(e.getKey(), o);
                }
                json.put(ITEMS_KEY, items);
diff --git 
a/openmeetings-install/src/main/java/org/apache/openmeetings/backup/converter/WbConverter.java
 
b/openmeetings-install/src/main/java/org/apache/openmeetings/backup/converter/WbConverter.java
index d4d6eff..4a1d589 100644
--- 
a/openmeetings-install/src/main/java/org/apache/openmeetings/backup/converter/WbConverter.java
+++ 
b/openmeetings-install/src/main/java/org/apache/openmeetings/backup/converter/WbConverter.java
@@ -25,6 +25,7 @@ import static 
org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_FILE_TYPE;
 import static org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_SLIDE;
 import static org.apache.openmeetings.db.dto.room.Whiteboard.ATTR_TYPE;
 import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_WML;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM__SRC;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -198,7 +199,7 @@ public class WbConverter {
                add(wb, init(wb, props)
                        .put(ATTR_TYPE, TYPE_IMAGE)
                        .put("omType", "Clipart")
-                       .put("_src", src)
+                       .put(PARAM__SRC, src)
                        .put("angle", props.get(3)));
        }
 
diff --git 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index d7643f8..5e58994 100644
--- 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++ 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -25,6 +25,8 @@ public class OpenmeetingsVariables {
        public static final String ATTR_TITLE = "title";
        public static final String PARAM_USER_ID = "userId";
        public static final String PARAM_STATUS = "status";
+       public static final String PARAM_SRC = "src";
+       public static final String PARAM__SRC = "_src";
        public static final String CONFIG_CRYPT = "crypt.class.name";
        public static final String CONFIG_DASHBOARD_SHOW_CHAT = 
"dashboard.show.chat";
        public static final String CONFIG_DASHBOARD_SHOW_MYROOMS = 
"dashboard.show.myrooms";
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/ImagePanel.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/ImagePanel.java
index dc07b37..487c59a 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/ImagePanel.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/ImagePanel.java
@@ -19,6 +19,7 @@
 package org.apache.openmeetings.web.common;
 
 import static org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_TITLE;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_SRC;
 
 import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
@@ -50,6 +51,6 @@ public abstract class ImagePanel extends Panel {
                profile.addOrReplace(new WebMarkupContainer("img").add(
                                AttributeModifier.append("alt", getTitle())
                                , AttributeModifier.append(ATTR_TITLE, 
getTitle())
-                               , AttributeModifier.append("src", 
getImageUrl())));
+                               , AttributeModifier.append(PARAM_SRC, 
getImageUrl())));
        }
 }
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbWebSocketHelper.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbWebSocketHelper.java
index 7d0f2e3..d75b7b6 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbWebSocketHelper.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbWebSocketHelper.java
@@ -18,6 +18,9 @@
  */
 package org.apache.openmeetings.web.room.wb;
 
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_SRC;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM__SRC;
+
 import java.util.function.Predicate;
 
 import org.apache.openmeetings.core.util.WebSocketHelper;
@@ -38,6 +41,7 @@ import com.github.openjson.JSONObject;
 
 public class WbWebSocketHelper extends WebSocketHelper {
        public static final String PARAM_OBJ = "obj";
+       private static final String PARAM__POSTER = "_poster";
 
        public static void send(IClusterWsMessage _m) {
                if (_m instanceof WsMessageWb) {
@@ -93,27 +97,31 @@ public class WbWebSocketHelper extends WebSocketHelper {
                JSONObject file = new JSONObject(_file.toString(new 
NullStringer()));
                final FileSystemResourceReference ref;
                final PageParameters pp = new PageParameters()
-                               .add("id", fi.getId()).add("uid", c.getUid())
-                               .add("ruid", ruid).add("wuid", 
_file.optString("uid"));
+                               .add("id", fi.getId())
+                               .add("ruid", ruid)
+                               .add("wuid", _file.optString("uid"));
+               if (c != null) {
+                       pp.add("uid", c.getUid());
+               }
                file.put("deleted", !fi.exists());
                switch (fi.getType()) {
                        case Video:
                                ref = new RoomResourceReference();
-                               file.put("_src", urlFor(ref, pp));
-                               file.put("_poster", urlFor(new 
RoomPreviewResourceReference(), pp));
+                               file.put(PARAM__SRC, urlFor(ref, pp));
+                               file.put(PARAM__POSTER, urlFor(new 
RoomPreviewResourceReference(), pp));
                                break;
                        case Recording:
                                ref = new Mp4RecordingResourceReference();
-                               file.put("_src", urlFor(ref, pp));
-                               file.put("_poster", urlFor(new 
PngRecordingResourceReference(), pp));
+                               file.put(PARAM__SRC, urlFor(ref, pp));
+                               file.put(PARAM__POSTER, urlFor(new 
PngRecordingResourceReference(), pp));
                                break;
                        case Presentation:
                                ref = new RoomResourceReference();
-                               file.put("_src", urlFor(ref, pp));
+                               file.put(PARAM__SRC, urlFor(ref, pp));
                                break;
                        default:
                                ref = new RoomResourceReference();
-                               file.put("src", urlFor(ref, pp));
+                               file.put(PARAM_SRC, urlFor(ref, pp));
                                break;
                }
                return file;
@@ -123,16 +131,42 @@ public class WbWebSocketHelper extends WebSocketHelper {
                sendWbFile(roomId, wbId, ruid, file, fi, true);
        }
 
+       //This is required cause WebSocketHelper will send message async
+       private static String patchUrl(String url, Client c) {
+               return String.format("%s&uid=%s", url, c.getUid());
+       }
+
+       private static JSONObject patchUrls(BaseFileItem fi, Client c, 
JSONObject f) {
+               switch (fi.getType()) {
+                       case Video:
+                               f.put(PARAM__SRC, 
patchUrl(f.getString(PARAM__SRC), c));
+                               f.put(PARAM__POSTER, 
patchUrl(f.getString(PARAM__POSTER), c));
+                               break;
+                       case Recording:
+                               f.put(PARAM__SRC, 
patchUrl(f.getString(PARAM__SRC), c));
+                               f.put(PARAM__POSTER, 
patchUrl(f.getString(PARAM__POSTER), c));
+                               break;
+                       case Presentation:
+                               f.put(PARAM__SRC, 
patchUrl(f.getString(PARAM__SRC), c));
+                               break;
+                       default:
+                               f.put(PARAM_SRC, 
patchUrl(f.getString(PARAM_SRC), c));
+                               break;
+               }
+               return f;
+       }
+
        private static void sendWbFile(Long roomId, long wbId, String ruid, 
JSONObject file, BaseFileItem fi, boolean publish) {
                if (publish) {
                        publish(new WsMessageWbFile(roomId, wbId, ruid, file, 
fi));
                }
+               final JSONObject _f = addFileUrl(ruid, file, fi, null);
                WebSocketHelper.sendRoom(
                                roomId
                                , new JSONObject().put("type", "wb")
                                , null
                                , (o, c) -> o.put("func", 
WbAction.createObj.name())
-                                                       .put("param", 
getObjWbJson(wbId, addFileUrl(ruid, file, fi, c))).toString(new 
NullStringer()));
+                                                       .put("param", 
getObjWbJson(wbId, patchUrls(fi, c, _f))).toString(new NullStringer()));
        }
 
        private static void sendWb(Long roomId, WbAction meth, JSONObject obj, 
Predicate<Client> check) {

-- 
To stop receiving notification emails like this one, please contact
solo...@apache.org.

Reply via email to