Author: solomax
Date: Thu Aug 11 06:12:30 2016
New Revision: 1755907

URL: http://svn.apache.org/viewvc?rev=1755907&view=rev
Log:
[OPENMEETINGS-1030] file upload works as expected, minor issues with file 
display need to be fixed

Added:
    
openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestStoredFile.java
      - copied, changed from r1755906, 
openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestStoredFile.java
    
openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestStoredFile.java
      - copied, changed from r1755906, 
openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestStoredFile.java
Removed:
    
openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestStoredFile.java
    
openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/crypt/TestStoredFile.java
Modified:
    
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java
    
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java
    
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java
    
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java
    
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
    
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java
    
openmeetings/application/branches/3.2.x/openmeetings-flash/src/main/swf/modules/conference/whiteboard/base/baseDraw.lzx
    
openmeetings/application/branches/3.2.x/openmeetings-flash/src/main/swf/modules/conference/whiteboard/base/baseDrawImage.lzx
    
openmeetings/application/branches/3.2.x/openmeetings-flash/src/main/swf/modules/conference/whiteboard/base/drawViewNew.lzx
    
openmeetings/application/branches/3.2.x/openmeetings-flash/src/main/swf/modules/conference/whiteboard/base/remoteWhiteboard.lzx
    
openmeetings/application/branches/3.2.x/openmeetings-flash/src/main/swf/modules/conference/whiteboard/base/whiteboardVideoPlayer.lzx
    openmeetings/application/branches/3.2.x/openmeetings-util/pom.xml
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFilePanel.java
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java
    
openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
    
openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java
    
openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java
    
openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java
    
openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java
    
openmeetings/application/trunk/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
    
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java
    openmeetings/application/trunk/openmeetings-util/pom.xml
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFilePanel.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.html
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/UploadDialog.java

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/FlvExplorerConverter.java
 Thu Aug 11 06:12:30 2016
@@ -42,6 +42,7 @@ import org.springframework.beans.factory
 
 public class FlvExplorerConverter extends BaseConverter {
        private static final Logger log = 
Red5LoggerFactory.getLogger(FlvExplorerConverter.class, webAppRootKey);
+       private static final Pattern p = Pattern.compile("\\d{2,4}(x)\\d{2,4}");
 
        // Spring loaded Beans
        @Autowired
@@ -127,18 +128,14 @@ public class FlvExplorerConverter extend
        }
        
        private static FlvDimension getFlvDimension(String txt) throws 
Exception {
-               Pattern p = Pattern.compile("\\d{2,4}(x)\\d{2,4}");
-               
                Matcher matcher = p.matcher(txt);
                
                while (matcher.find()) {
                        String foundResolution = txt.substring(matcher.start(), 
matcher.end());
-                       
                        String[] resultions = foundResolution.split("x");
-                       
                        return new 
FlvDimension(Integer.valueOf(resultions[0]).intValue(), 
Integer.valueOf(resultions[1]).intValue());
                }
                
-               throw new Exception("Failed to get FLV dimension: " + txt);
+               return new FlvDimension(100, 100); // will return 100x100 for 
non-video to be able to play
        }
 }

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/file/FileUtils.java
 Thu Aug 11 06:12:30 2016
@@ -18,12 +18,15 @@
  */
 package org.apache.openmeetings.core.data.file;
 
+import static org.apache.openmeetings.util.OmFileHelper.MP4_EXTENSION;
+import static org.apache.openmeetings.util.OmFileHelper.JPG_EXTENSION;
 import static org.apache.openmeetings.util.OmFileHelper.thumbImagePrefix;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 import java.util.Locale;
 
 import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
@@ -40,19 +43,28 @@ public class FileUtils {
        @Autowired
        private FileExplorerItemDao fileDao;
 
-       public long getSizeOfDirectoryAndSubs(FileExplorerItem file) {
+       public long getSize(List<FileExplorerItem> list) {
+               long size = 0;
+               for (FileExplorerItem f : list) {
+                       log.debug("FileExplorerItem fList " + f.getName());
+                       size += getSize(f);
+               }
+               return size;
+       }
+       
+       public long getSize(FileExplorerItem file) {
                try {
                        long fileSize = 0;
 
                        File base = OmFileHelper.getUploadFilesDir();
                        if (Type.Image == file.getType()) {
-
-                               File tFile = new File(base, file.getHash());
+                               String fname = String.format("%s%s", 
file.getHash(), JPG_EXTENSION);
+                               File tFile = new File(base, fname);
                                if (tFile.exists()) {
                                        fileSize += tFile.length();
                                }
 
-                               File thumbFile = new File(base, 
thumbImagePrefix + file.getHash());
+                               File thumbFile = new File(base, 
thumbImagePrefix + fname);
                                if (thumbFile.exists()) {
                                        fileSize += thumbFile.length();
                                }
@@ -66,10 +78,21 @@ public class FileUtils {
                                }
                        }
 
+                       if (Type.Video == file.getType()) {
+                               //FIXME TODO refactor
+                               File video = new 
File(OmFileHelper.getStreamsHibernateDir(), "UPLOADFLV_" + file.getId() + 
MP4_EXTENSION);
+                               if (video.exists()) {
+                                       fileSize += video.length();
+                               }
+                               File thumb = new 
File(OmFileHelper.getStreamsHibernateDir(), "UPLOADFLV_" + file.getId() + 
JPG_EXTENSION);
+                               if (thumb.exists()) {
+                                       fileSize += thumb.length();
+                               }
+                       }
+
                        log.debug("calling [1] fileDao.update()");
-                       fileDao.update(file);
                        for (FileExplorerItem child : 
fileDao.getByParent(file.getId())) {
-                               fileSize += getSizeOfDirectoryAndSubs(child);
+                               fileSize += getSize(child);
                        }
 
                        return fileSize;

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardManager.java
 Thu Aug 11 06:12:30 2016
@@ -23,7 +23,6 @@ import static org.apache.openmeetings.ut
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.openmeetings.db.dto.room.WhiteboardObject;
 import org.red5.logging.Red5LoggerFactory;
@@ -36,8 +35,8 @@ public class WhiteboardManager {
        @Autowired
        private WhiteBoardObjectListManagerById wbListManagerById;
 
-       @SuppressWarnings({ "rawtypes", "unchecked" })
-       public void addWhiteBoardObjectById(Long roomId, Map whiteboardObj, 
Long whiteBoardId) {
+       @SuppressWarnings("unchecked")
+       public void addWhiteBoardObjectById(Long roomId, Map<Integer, Object> 
whiteboardObj, Long whiteBoardId) {
                try {
                        log.debug("addWhiteBoardObjectById: ", whiteboardObj);
 
@@ -46,7 +45,7 @@ public class WhiteboardManager {
                        log.debug("action: " + action);
                        log.debug("actionObject: " + whiteboardObj.get(3));
 
-                       List actionObject = (List) whiteboardObj.get(3);
+                       List<Object> actionObject = (List<Object>) 
whiteboardObj.get(3);
 
                        if (action.equals("moveMap")) {
                                WhiteboardObject whiteboardObject = 
wbListManagerById.getWhiteBoardObjectListByRoomIdAndWhiteboard(roomId, 
whiteBoardId);
@@ -65,64 +64,16 @@ public class WhiteboardManager {
                                if (!objectType.equals("pointerWhiteBoard")) {
                                        String objectOID = 
actionObject.get(actionObject.size() - 1).toString();
                                        log.debug("objectOID: " + objectOID);
-                                       
whiteboardObject.getRoomItems().put(objectOID, actionObject);
+                                       whiteboardObject.add(objectOID, 
actionObject);
                                        
wbListManagerById.setWhiteBoardObjectListRoomObjAndWhiteboardId(roomId, 
whiteboardObject, whiteBoardId);
                                }
                        } else if (action.equals("clear")) {
                                WhiteboardObject whiteboardObject = 
wbListManagerById.getWhiteBoardObjectListByRoomIdAndWhiteboard(roomId, 
whiteBoardId);
-                               whiteboardObject.setRoomItems(new 
ConcurrentHashMap<String, List>());
+                               whiteboardObject.clear();
                                
wbListManagerById.setWhiteBoardObjectListRoomObjAndWhiteboardId(roomId, 
whiteboardObject, whiteBoardId);
                        } else if (action.equals("delete") || 
action.equals("undo")) {
                                WhiteboardObject whiteboardObject = 
wbListManagerById.getWhiteBoardObjectListByRoomIdAndWhiteboard(roomId, 
whiteBoardId);
-                               String objectOID = 
actionObject.get(actionObject.size() - 1).toString();
-                               String objectType = 
actionObject.get(0).toString();
-                               log.debug("removal of objectOID: " + objectOID);
-
-                               log.debug("removal of objectOID: " + objectOID);
-
-                               // Re-Index all items in its zIndex
-                               if (objectType.equals("ellipse")
-                                               || 
objectType.equals("drawarrow")
-                                               || objectType.equals("line")
-                                               || objectType.equals("paint")
-                                               || 
objectType.equals("rectangle")
-                                               || objectType.equals("uline")
-                                               || objectType.equals("image")
-                                               || objectType.equals("letter")
-                                               || objectType.equals("clipart")
-                                               || objectType.equals("swf")
-                                               || 
objectType.equals("mindmapnode")
-                                               || objectType.equals("flv")) {
-
-                                       Integer zIndex = 
Integer.valueOf(actionObject.get(actionObject.size() - 8).toString());
-
-                                       log.debug("1|zIndex " + zIndex);
-                                       log.debug("2|zIndex " + 
actionObject.get(actionObject.size() - 8).toString());
-                                       log.debug("3|zIndex " + 
actionObject.get(actionObject.size() - 8));
-
-                                       int l = 0;
-                                       for (Object o : actionObject) {
-                                               log.debug("4|zIndex " + l + " 
-- " + o);
-                                               l++;
-                                       }
-
-                                       for (Entry<String, List> e : 
whiteboardObject.getRoomItems().entrySet()) {
-                                               List actionObjectStored = 
e.getValue();
-
-                                               Integer zIndexStored = 
Integer.valueOf(actionObjectStored.get(actionObjectStored.size() - 
8).toString());
-
-                                               log.debug("zIndexStored|zIndex 
" + zIndexStored + "|" + zIndex);
-
-                                               if (zIndexStored >= zIndex) {
-                                                       zIndexStored -= 1;
-                                                       log.debug("new-zIndex " 
+ zIndexStored);
-                                               }
-                                               
actionObjectStored.set(actionObjectStored.size() - 8, zIndexStored);
-
-                                               
whiteboardObject.getRoomItems().put(e.getKey(), actionObjectStored);
-                                       }
-                               }
-                               
whiteboardObject.getRoomItems().remove(objectOID);
+                               whiteboardObject.remove(actionObject);
 
                                
wbListManagerById.setWhiteBoardObjectListRoomObjAndWhiteboardId(roomId, 
whiteboardObject, whiteBoardId);
                        } else if (action.equals("size") || 
action.equals("editProp")
@@ -134,13 +85,11 @@ public class WhiteboardManager {
                                WhiteboardObject whiteboardObject = 
wbListManagerById.getWhiteBoardObjectListByRoomIdAndWhiteboard(roomId, 
whiteBoardId);
                                String objectOID = 
actionObject.get(actionObject.size() - 1).toString();
                                // List roomItem = roomList.get(objectOID);
-                               List currentObject = 
whiteboardObject.getRoomItems().get(objectOID);
-                               if (actionObject.get(0).equals("paint")) {
+                               List<Object> currentObject = 
whiteboardObject.get(objectOID);
+                               if ("paint".equals(actionObject.get(0))) {
                                        actionObject.set(1, 
currentObject.get(1));
                                }
-                               whiteboardObject.getRoomItems().put(objectOID, 
actionObject);
-
-                               Map<String, List> roomList = 
whiteboardObject.getRoomItems();
+                               whiteboardObject.add(objectOID, actionObject);
 
                                if (action.equals("swf")) {
                                        log.debug("actionObject " + 
actionObject);
@@ -151,8 +100,8 @@ public class WhiteboardManager {
 
                                                        
log.debug("updateObjectsToSlideNumber :: " + baseObjectName + "," + 
slidesNumber);
 
-                                                       for (Entry<String, 
List> me : roomList.entrySet()) {
-                                                               List 
actionObjectStored = me.getValue();
+                                                       for (Entry<String, 
List<Object>> me : whiteboardObject.entrySet()) {
+                                                               List<Object> 
actionObjectStored = me.getValue();
 
                                                                if 
(actionObjectStored.get(0).equals("ellipse")
                                                                                
|| actionObjectStored.get(0).equals("drawarrow")
@@ -164,7 +113,7 @@ public class WhiteboardManager {
                                                                                
|| actionObjectStored.get(0).equals("image")
                                                                                
|| actionObjectStored.get(0).equals("letter")) {
 
-                                                                       Map 
swfObj = (Map) actionObjectStored.get(actionObjectStored.size() - 7);
+                                                                       
Map<String, Object> swfObj = (Map<String, Object>) 
actionObjectStored.get(actionObjectStored.size() - 7);
                                                                        
log.debug("swfObj :1: " + swfObj);
 
                                                                        if 
(swfObj != null) {
@@ -185,10 +134,8 @@ public class WhiteboardManager {
                        } else if (action.equals("clearSlide")) {
                                WhiteboardObject whiteboardObject = 
wbListManagerById.getWhiteBoardObjectListByRoomIdAndWhiteboard(roomId, 
whiteBoardId);
 
-                               Map roomList = whiteboardObject.getRoomItems();
-
-                               for (String objectName : (List<String>) 
actionObject) {
-                                       roomList.remove(objectName);
+                               for (Object objectName : actionObject) {
+                                       whiteboardObject.remove(objectName);
                                }
 
                                
wbListManagerById.setWhiteBoardObjectListRoomObjAndWhiteboardId(roomId, 
whiteboardObject, whiteBoardId);

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java
 Thu Aug 11 06:12:30 2016
@@ -160,7 +160,7 @@ public class ConferenceLibrary implement
 
                List<?> roomItems = LibraryWmlLoader.loadWmlFile(fi.getHash());
 
-               Map<Integer, String> wbClear = new HashMap<>();
+               Map<Integer, Object> wbClear = new HashMap<>();
                wbClear.put(2, "clear");
                wbClear.put(3, null);
 

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/red5/ScopeApplicationAdapter.java
 Thu Aug 11 06:12:30 2016
@@ -1406,7 +1406,7 @@ public class ScopeApplicationAdapter ext
                                , fuid // uniquObjectSyncName //17
                                , fi.getName() // standardFileName //18
                                , true // fullFit //19 FIXME TODO
-                               , 1 // zIndex //-8 FIXME TODO
+                               , 0 // zIndex //-8
                                , null //-7
                                , 0 // this.counter //-6 FIXME TODO
                                , 0 // posx //-5
@@ -1427,7 +1427,7 @@ public class ScopeApplicationAdapter ext
                                , false // 3: false //playRemote
                                , size.x // 4: 416
                                , size.y // 5: 240
-                               , 1 // 6: 1 // z-index 
+                               , 0 // 6: 1 // z-index 
                                , null // 7: null //TODO 
                                , 0 // 8: 0 //TODO // counter
                                , 0 // 9: 0 //TODO // x
@@ -1438,7 +1438,7 @@ public class ScopeApplicationAdapter ext
                                );
        }
        
-       public void sendToWhiteboard(String uid, Long wbId, FileItem fi, String 
url) {
+       public void sendToWhiteboard(String uid, Long wbId, FileItem fi, String 
url, boolean clean) {
                ClientSessionInfo csi = 
sessionManager.getClientByPublicSIDAnyServer(uid);
                if (csi == null) {
                        log.warn("No client was found to send Wml:: {}", uid);
@@ -1459,6 +1459,13 @@ public class ScopeApplicationAdapter ext
                                break;
                        default:
                }
+               if (clean) {
+                       Map<Integer, Object> wbClear = new HashMap<>();
+                       wbClear.put(2, "clear");
+                       wbClear.put(3, null);
+
+                       sendToScope(client.getRoomId(), 
"sendVarsToWhiteboardById", new Object[] { wbClear });
+               }
                sendToWhiteboard(client, Arrays.asList("whiteboard", new 
Date(), "draw", wbObject), wbId);
        }
        

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java?rev=1755907&r1=1755906&r2=1755907&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/WhiteboardObject.java
 Thu Aug 11 06:12:30 2016
@@ -18,21 +18,28 @@
  */
 package org.apache.openmeetings.db.dto.room;
 
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
-public class WhiteboardObject {
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
 
+public class WhiteboardObject {
+       private static final Logger log = 
Red5LoggerFactory.getLogger(WhiteboardObject.class, webAppRootKey);
        private long whiteBoardId;
        private Integer x = 0;
        private Integer y = 0;
        private Integer zoom = 100;
        private Boolean fullFit = true;
-       @SuppressWarnings("rawtypes")
-       private Map<String, List> roomItems = new ConcurrentHashMap<>();
+       private Map<String, List<Object>> roomItems = new ConcurrentHashMap<>();
        private Date created = new Date();
+       private int zIndex = 1;
 
        public WhiteboardObject() {}
        
@@ -60,16 +67,6 @@ public class WhiteboardObject {
                this.y = y;
        }
 
-       @SuppressWarnings("rawtypes")
-       public Map<String, List> getRoomItems() {
-               return roomItems;
-       }
-
-       @SuppressWarnings("rawtypes")
-       public void setRoomItems(Map<String, List> roomItems) {
-               this.roomItems = roomItems;
-       }
-
        public Date getCreated() {
                return created;
        }
@@ -94,4 +91,81 @@ public class WhiteboardObject {
                this.fullFit = fullFit;
        }
 
+       public void clear() {
+               roomItems.clear();
+               zIndex = 1;
+       }
+
+       public void add(String oid, List<Object> actionObject) {
+               Object type = actionObject.size() > 0 ? actionObject.get(0) : 
"";
+               if (actionObject.size() > 8 && ("swf".equals(type) || 
"image".equals(type) || "flv".equals(type))) {
+                       Integer zInd = 
(Integer)actionObject.get(actionObject.size() - 8);
+                       if (zInd == null || zInd == 0 || zInd < zIndex) {
+                               actionObject.set(actionObject.size() - 8, 
zIndex++);
+                       }
+               }
+               roomItems.put(oid, actionObject);
+       }
+
+       public List<Object> get(String oid) {
+               return roomItems.get(oid);
+       }
+
+       public Set<Entry<String, List<Object>>> entrySet() {
+               return roomItems.entrySet();
+       }
+
+       public void remove(Object oid) {
+               roomItems.remove(oid);
+       }
+
+       public void remove(List<Object> actionObject) {
+               String oid = actionObject.get(actionObject.size() - 
1).toString();
+               String type = actionObject.get(0).toString();
+               log.debug("Removal of object: oid = {}, type = {} ", oid, type);
+
+               /* I believe this is redundant
+               // Re-Index all items in its zIndex
+               if (type.equals("ellipse")
+                               || type.equals("drawarrow")
+                               || type.equals("line")
+                               || type.equals("paint")
+                               || type.equals("rectangle")
+                               || type.equals("uline")
+                               || type.equals("image")
+                               || type.equals("letter")
+                               || type.equals("clipart")
+                               || type.equals("swf")
+                               || type.equals("mindmapnode")
+                               || type.equals("flv")) {
+
+                       Integer zIndex = 
Integer.valueOf(actionObject.get(actionObject.size() - 8).toString());
+
+                       log.debug("1|zIndex " + zIndex);
+                       log.debug("2|zIndex " + 
actionObject.get(actionObject.size() - 8).toString());
+                       log.debug("3|zIndex " + 
actionObject.get(actionObject.size() - 8));
+
+                       int l = 0;
+                       for (Object o : actionObject) {
+                               log.debug("4|zIndex " + l + " -- " + o);
+                               l++;
+                       }
+
+                       for (Entry<String, List<Object>> e : 
roomItems.entrySet()) {
+                               List<Object> actionObjectStored = e.getValue();
+
+                               Integer zIndexStored = 
Integer.valueOf(actionObjectStored.get(actionObjectStored.size() - 
8).toString());
+
+                               log.debug("zIndexStored|zIndex " + zIndexStored 
+ "|" + zIndex);
+
+                               if (zIndexStored >= zIndex) {
+                                       zIndexStored -= 1;
+                                       log.debug("new-zIndex " + zIndexStored);
+                               }
+                               
actionObjectStored.set(actionObjectStored.size() - 8, zIndexStored);
+                       }
+               }
+               */
+               roomItems.remove(oid);
+       }
 }


Reply via email to