Index: lams_build/lib/lams/lams-central.jar =================================================================== diff -u -r00a6e145b37916eb1561ea5c68319b0fc691681b -r42aa5319fbd33938828764c43dd0ab1ca80e2416 Binary files differ Index: lams_build/lib/lams/lams-learning.jar =================================================================== diff -u -r8386a3fecd9c7baf6ed69d499016dedd8a83eac6 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 Binary files differ Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r00a6e145b37916eb1561ea5c68319b0fc691681b -r42aa5319fbd33938828764c43dd0ab1ca80e2416 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/util/ExternalServerUtil.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/util/ExternalServerUtil.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/util/ExternalServerUtil.java (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,88 @@ +package org.lamsfoundation.lams.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLConnection; +import java.util.HashMap; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Map.Entry; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; + +public class ExternalServerUtil { + + private static Logger logger = Logger.getLogger(ExternalServerUtil.class); + + public static InputStream getResponseInputStreamFromExternalServer(String urlStr, HashMap params) + throws IOException { + if (!urlStr.endsWith("?")) + urlStr += "?"; + + for (Entry entry : params.entrySet()) { + urlStr += "&" + entry.getKey() + "=" + entry.getValue(); + } + + logger.debug("Making request to external servlet: " + urlStr); + + URL url = new URL(urlStr); + URLConnection conn = url.openConnection(); + if (!(conn instanceof HttpURLConnection)) { + logger.error("Fail to connect to external server though url: " + urlStr); + throw new ToolException("Fail to connect to external server though url: " + urlStr); + } + + HttpURLConnection httpConn = (HttpURLConnection) conn; + if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { + logger.error("Fail to fetch data from external server, response code: " + httpConn.getResponseCode() + + " Url: " + urlStr); + throw new ToolException("Fail to fetch data from external server, response code: " + + httpConn.getResponseCode() + " Url: " + urlStr); + } + + InputStream is = url.openConnection().getInputStream(); + if (is == null) { + logger.error("Fail to fetch data from external server, return InputStream null: " + urlStr); + throw new ToolException("Fail to fetch data from external server, return inputStream null: " + urlStr); + } + + return is; + } + + public static File writeFileAndDir(InputStream is, String filename, String dir){ + File file = null; + file = new File(dir); + file.mkdirs(); + return writeFile(is, dir + filename); + } + + public static File writeFile(InputStream is, String filename){ + File file = null; + + try{ + file = new File(filename); + + FileOutputStream out = new FileOutputStream(file); + + //int maxMem = Integer.getInteger(Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_MEMORY_SIZE)) + + byte[] buf = new byte[2 * 1024]; + int len; + while ((len = is.read(buf)) > 0) { + out.write(buf, 0, len); + } + }catch(FileNotFoundException e){ + logger.error("File not found: " + e.getMessage()); + }catch(Exception e){ + logger.error("Fail to create file: " + e.getMessage()); + } + + return file; + } +} Index: lams_central/src/java/org/lamsfoundation/lams/webservice/GetRecordingServlet.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/webservice/GetRecordingServlet.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/GetRecordingServlet.java (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,74 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.webservice; + +import java.io.File; +import java.io.InputStream; +import java.util.HashMap; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.util.ExternalServerUtil; +import org.lamsfoundation.lams.util.WebUtil; + +/** + * @author pgeorges + * + * @web:servlet name="GetRecordingServlet" + * @web:servlet-mapping url-pattern="/GetRecording" + */ +public class GetRecordingServlet extends HttpServlet { + + private static Logger logger = Logger.getLogger(GetRecordingServlet.class); + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException { + + try { + String urlStr = WebUtil.readStrParam(request, "urlStr"); + //HashMap params = (HashMap)request.getAttribute("params"); + String filename = WebUtil.readStrParam(request, "filename"); + String dir = WebUtil.readStrParam(request, "dir"); + + InputStream is = ExternalServerUtil.getResponseInputStreamFromExternalServer(urlStr, new HashMap()); + File file = ExternalServerUtil.writeFileAndDir(is, filename, dir); + + logger.debug("file copy complete"); + + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException { + doPost(request, response); + } + +} + \ No newline at end of file Index: lams_central/web/WEB-INF/tags/FCKEditor.tag =================================================================== diff -u -r0e08d909e2d4b297606e51141e82d86b50393003 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_central/web/WEB-INF/tags/FCKEditor.tag (.../FCKEditor.tag) (revision 0e08d909e2d4b297606e51141e82d86b50393003) +++ lams_central/web/WEB-INF/tags/FCKEditor.tag (.../FCKEditor.tag) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -65,6 +65,7 @@ LinkUploadURL="${basePath}editor/filemanager/upload/simpleuploader?Type=File&CurrentFolder=/${contentFolderID}/" FlashBrowserURL="${basePath}editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector&CurrentFolder=/${contentFolderID}/" FlashUploadURL="${basePath}editor/filemanager/upload/simpleuploader?Type=Flash&CurrentFolder=/${contentFolderID}/" + ContentFolderID="${contentFolderID}" AutoDetectLanguage="false" DefaultLanguage="${language}" ToolbarStartExpanded="${displayExpanded}"/> Index: lams_central/web/fckeditor/editor/plugins/videorecorder/AC_OETags.js =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/AC_OETags.js (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/AC_OETags.js (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,278 @@ +// Flash Player Version Detection - Rev 1.6 +// Detect Client Browser type +// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. +var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; +var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; +var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; + +function ControlVersion() +{ + var version; + var axo; + var e; + + // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry + + try { + // version will be set for 7.X or greater players + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); + version = axo.GetVariable("$version"); + } catch (e) { + } + + if (!version) + { + try { + // version will be set for 6.X players only + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); + + // installed player is some revision of 6.0 + // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, + // so we have to be careful. + + // default to the first public version + version = "WIN 6,0,21,0"; + + // throws if AllowScripAccess does not exist (introduced in 6.0r47) + axo.AllowScriptAccess = "always"; + + // safe to call for 6.0r47 or greater + version = axo.GetVariable("$version"); + + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 4.X or 5.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); + version = axo.GetVariable("$version"); + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 3.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); + version = "WIN 3,0,18,0"; + } catch (e) { + } + } + + if (!version) + { + try { + // version will be set for 2.X player + axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); + version = "WIN 2,0,0,11"; + } catch (e) { + version = -1; + } + } + + return version; +} + +// JavaScript helper required to detect Flash Player PlugIn version information +function GetSwfVer(){ + // NS/Opera version >= 3 check for Flash plugin in plugin array + var flashVer = -1; + + if (navigator.plugins != null && navigator.plugins.length > 0) { + if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { + var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; + var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; + var descArray = flashDescription.split(" "); + var tempArrayMajor = descArray[2].split("."); + var versionMajor = tempArrayMajor[0]; + var versionMinor = tempArrayMajor[1]; + var versionRevision = descArray[3]; + if (versionRevision == "") { + versionRevision = descArray[4]; + } + if (versionRevision[0] == "d") { + versionRevision = versionRevision.substring(1); + } else if (versionRevision[0] == "r") { + versionRevision = versionRevision.substring(1); + if (versionRevision.indexOf("d") > 0) { + versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); + } + } else if (versionRevision[0] == "b") { + versionRevision = versionRevision.substring(1); + } + var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; + } + } + // MSN/WebTV 2.6 supports Flash 4 + else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; + // WebTV 2.5 supports Flash 3 + else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; + // older WebTV supports Flash 2 + else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; + else if ( isIE && isWin && !isOpera ) { + flashVer = ControlVersion(); + } + return flashVer; +} + +// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available +function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) +{ + versionStr = GetSwfVer(); + if (versionStr == -1 ) { + return false; + } else if (versionStr != 0) { + if(isIE && isWin && !isOpera) { + // Given "WIN 2,0,0,11" + tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] + tempString = tempArray[1]; // "2,0,0,11" + versionArray = tempString.split(","); // ['2', '0', '0', '11'] + } else { + versionArray = versionStr.split("."); + } + var versionMajor = versionArray[0]; + var versionMinor = versionArray[1]; + var versionRevision = versionArray[2]; + + // is the major.revision >= requested major.revision AND the minor version >= requested minor + if (versionMajor > parseFloat(reqMajorVer)) { + return true; + } else if (versionMajor == parseFloat(reqMajorVer)) { + if (versionMinor > parseFloat(reqMinorVer)) + return true; + else if (versionMinor == parseFloat(reqMinorVer)) { + if (versionRevision >= parseFloat(reqRevision)) + return true; + } + } + return false; + } +} + +function AC_AddExtension(src, ext) +{ + if (src.indexOf('?') != -1) + return src.replace(/\?/, ext+'?'); + else + return src + ext; +} + +function AC_Generateobj(objAttrs, params, embedAttrs) +{ + var str = ''; + if (isIE && isWin && !isOpera) + { + str += ' '; + str += ''; + } else { + str += ' + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_central/web/fckeditor/editor/plugins/videorecorder/VideoRecorderFCKEditor.jsp =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/VideoRecorderFCKEditor.jsp (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/VideoRecorderFCKEditor.jsp (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,216 @@ +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-lams" prefix="lams" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ +
Index: lams_central/web/fckeditor/editor/plugins/videorecorder/VideoRecorderFCKEditor.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/24-heart-gold.png =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/24-heart-red.png =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/24-heart-silver.png =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/deleteIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/downArrow.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/exportIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/okIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/pauseIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/playIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/playerVolume.png =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/recordIcon.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/images/upArrow.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/assets/styles/main.css =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/assets/styles/main.css (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/assets/styles/main.css (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,35 @@ +Application { + backgroundColor:#ECECEC; + backgroundGradientColors:#ECECEC,#ECECEC; +} + +Tile { + top: 10; + bottom: 10; + left: 10; + right: 10; +} + +Label { + color: #000000; + fontWeight: bold; + fontSize: 14; +} + +.box { + borderColor: #50B2CB; + cornerRadius: 10; + borderStyle: solid; + borderThickness: 1; + paddingBottom: 10; + paddingTop: 10; + paddingLeft: 10; + paddingRight: 10; + backgroundColor:#ffffff; + backgroundAlpha: 1; +} + +Text { + fontSize: 12; + fontWeight: normal; +} \ No newline at end of file Index: lams_central/web/fckeditor/editor/plugins/videorecorder/fckplugin.js =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/fckplugin.js (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/fckplugin.js (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,60 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +// the command to launch +var InsertVideoRecorderCommand=function(){}; + +InsertVideoRecorderCommand.prototype.Execute=function(){ } + +InsertVideoRecorderCommand.GetState=function() { + return FCK_TRISTATE_OFF; +} + +// the popup +var popup = null; +InsertVideoRecorderCommand.Execute=function() +{ + //open a popup window when the button is clicked + if (popup==null || popup.closed || !popup.location){ + popup= window.open( FCKConfig.PluginsPath + 'videorecorder/VideoRecorderFCKEditor.jsp', 'VideoRecorder', 'width=380,height=440,status=no,scrollbars=no,resizable=no,location=no,toolbar=no'); + } + + popup.focus(); +} + +// register the command with fckeditor +FCKCommands.RegisterCommand( 'VideoRecorder', InsertVideoRecorderCommand ) ; + +// place the toolbar button +var oVideoRecorderItem = new FCKToolbarButton( 'VideoRecorder', FCKLang['VideoRecorderBtn'] ) ; +oVideoRecorderItem.IconPath = FCKConfig.PluginsPath + 'videorecorder/icon.png' ; + +FCKToolbarItems.RegisterItem( 'VideoRecorder', oVideoRecorderItem ) ; + +// create an object to handle videorecorder +var FCKVideoRecorder= new Object() ; + +FCKVideoRecorder.Add = function( innerHTML ) +{ + FCK.InsertHtml(innerHTML); +} \ No newline at end of file Index: lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.css =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.css (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.css (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,6 @@ +/* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ + +#ie_historyFrame { width: 0px; height: 0px; display:none } +#firefox_anchorDiv { width: 0px; height: 0px; display:none } +#safari_formDiv { width: 0px; height: 0px; display:none } +#safari_rememberDiv { width: 0px; height: 0px; display:none } Index: lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.js =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.js (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/history/history.js (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,662 @@ +BrowserHistoryUtils = { + addEvent: function(elm, evType, fn, useCapture) { + useCapture = useCapture || false; + if (elm.addEventListener) { + elm.addEventListener(evType, fn, useCapture); + return true; + } + else if (elm.attachEvent) { + var r = elm.attachEvent('on' + evType, fn); + return r; + } + else { + elm['on' + evType] = fn; + } + } +} + +BrowserHistory = (function() { + // type of browser + var browser = { + ie: false, + firefox: false, + safari: false, + opera: false, + version: -1 + }; + + // if setDefaultURL has been called, our first clue + // that the SWF is ready and listening + //var swfReady = false; + + // the URL we'll send to the SWF once it is ready + //var pendingURL = ''; + + // Default app state URL to use when no fragment ID present + var defaultHash = ''; + + // Last-known app state URL + var currentHref = document.location.href; + + // Initial URL (used only by IE) + var initialHref = document.location.href; + + // Initial URL (used only by IE) + var initialHash = document.location.hash; + + // History frame source URL prefix (used only by IE) + var historyFrameSourcePrefix = 'history/historyFrame.html?'; + + // History maintenance (used only by Safari) + var currentHistoryLength = -1; + + var historyHash = []; + + var initialState = createState(initialHref, initialHref + '#' + initialHash, initialHash); + + var backStack = []; + var forwardStack = []; + + var currentObjectId = null; + + //UserAgent detection + var useragent = navigator.userAgent.toLowerCase(); + + if (useragent.indexOf("opera") != -1) { + browser.opera = true; + } else if (useragent.indexOf("msie") != -1) { + browser.ie = true; + browser.version = parseFloat(useragent.substring(useragent.indexOf('msie') + 4)); + } else if (useragent.indexOf("safari") != -1) { + browser.safari = true; + browser.version = parseFloat(useragent.substring(useragent.indexOf('safari') + 7)); + } else if (useragent.indexOf("gecko") != -1) { + browser.firefox = true; + } + + if (browser.ie == true && browser.version == 7) { + window["_ie_firstload"] = false; + } + + // Accessor functions for obtaining specific elements of the page. + function getHistoryFrame() + { + return document.getElementById('ie_historyFrame'); + } + + function getAnchorElement() + { + return document.getElementById('firefox_anchorDiv'); + } + + function getFormElement() + { + return document.getElementById('safari_formDiv'); + } + + function getRememberElement() + { + return document.getElementById("safari_remember_field"); + } + + // Get the Flash player object for performing ExternalInterface callbacks. + // Updated for changes to SWFObject2. + function getPlayer(id) { + if (id && document.getElementById(id)) { + var r = document.getElementById(id); + if (typeof r.SetVariable != "undefined") { + return r; + } + else { + var o = r.getElementsByTagName("object"); + var e = r.getElementsByTagName("embed"); + if (o.length > 0 && typeof o[0].SetVariable != "undefined") { + return o[0]; + } + else if (e.length > 0 && typeof e[0].SetVariable != "undefined") { + return e[0]; + } + } + } + else { + var o = document.getElementsByTagName("object"); + var e = document.getElementsByTagName("embed"); + if (e.length > 0 && typeof e[0].SetVariable != "undefined") { + return e[0]; + } + else if (o.length > 0 && typeof o[0].SetVariable != "undefined") { + return o[0]; + } + else if (o.length > 1 && typeof o[1].SetVariable != "undefined") { + return o[1]; + } + } + return undefined; + } + + function getPlayers() { + var players = []; + if (players.length == 0) { + var tmp = document.getElementsByTagName('object'); + players = tmp; + } + + if (players.length == 0 || players[0].object == null) { + var tmp = document.getElementsByTagName('embed'); + players = tmp; + } + return players; + } + + function getIframeHash() { + var doc = getHistoryFrame().contentWindow.document; + var hash = String(doc.location.search); + if (hash.length == 1 && hash.charAt(0) == "?") { + hash = ""; + } + else if (hash.length >= 2 && hash.charAt(0) == "?") { + hash = hash.substring(1); + } + return hash; + } + + /* Get the current location hash excluding the '#' symbol. */ + function getHash() { + // It would be nice if we could use document.location.hash here, + // but it's faulty sometimes. + var idx = document.location.href.indexOf('#'); + return (idx >= 0) ? document.location.href.substr(idx+1) : ''; + } + + /* Get the current location hash excluding the '#' symbol. */ + function setHash(hash) { + // It would be nice if we could use document.location.hash here, + // but it's faulty sometimes. + if (hash == '') hash = '#' + document.location.hash = hash; + } + + function createState(baseUrl, newUrl, flexAppUrl) { + return { 'baseUrl': baseUrl, 'newUrl': newUrl, 'flexAppUrl': flexAppUrl, 'title': null }; + } + + /* Add a history entry to the browser. + * baseUrl: the portion of the location prior to the '#' + * newUrl: the entire new URL, including '#' and following fragment + * flexAppUrl: the portion of the location following the '#' only + */ + function addHistoryEntry(baseUrl, newUrl, flexAppUrl) { + + //delete all the history entries + forwardStack = []; + + if (browser.ie) { + //Check to see if we are being asked to do a navigate for the first + //history entry, and if so ignore, because it's coming from the creation + //of the history iframe + if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) { + currentHref = initialHref; + return; + } + if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) { + newUrl = baseUrl + '#' + defaultHash; + flexAppUrl = defaultHash; + } else { + // for IE, tell the history frame to go somewhere without a '#' + // in order to get this entry into the browser history. + getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl; + } + setHash(flexAppUrl); + } else { + + //ADR + if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) { + initialState = createState(baseUrl, newUrl, flexAppUrl); + } else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) { + backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl); + } + + if (browser.safari) { + // for Safari, submit a form whose action points to the desired URL + if (browser.version <= 419.3) { + var file = window.location.pathname.toString(); + file = file.substring(file.lastIndexOf("/")+1); + getFormElement().innerHTML = '
'; + //get the current elements and add them to the form + var qs = window.location.search.substring(1); + var qs_arr = qs.split("&"); + for (var i = 0; i < qs_arr.length; i++) { + var tmp = qs_arr[i].split("="); + var elem = document.createElement("input"); + elem.type = "hidden"; + elem.name = tmp[0]; + elem.value = tmp[1]; + document.forms.historyForm.appendChild(elem); + } + document.forms.historyForm.submit(); + } else { + top.location.hash = flexAppUrl; + } + // We also have to maintain the history by hand for Safari + historyHash[history.length] = flexAppUrl; + _storeStates(); + } else { + // Otherwise, write an anchor into the page and tell the browser to go there + addAnchor(flexAppUrl); + setHash(flexAppUrl); + } + } + backStack.push(createState(baseUrl, newUrl, flexAppUrl)); + } + + function _storeStates() { + if (browser.safari) { + getRememberElement().value = historyHash.join(","); + } + } + + function handleBackButton() { + //The "current" page is always at the top of the history stack. + var current = backStack.pop(); + if (!current) { return; } + var last = backStack[backStack.length - 1]; + if (!last && backStack.length == 0){ + last = initialState; + } + forwardStack.push(current); + } + + function handleForwardButton() { + //summary: private method. Do not call this directly. + + var last = forwardStack.pop(); + if (!last) { return; } + backStack.push(last); + } + + function handleArbitraryUrl() { + //delete all the history entries + forwardStack = []; + } + + /* Called periodically to poll to see if we need to detect navigation that has occurred */ + function checkForUrlChange() { + + if (browser.ie) { + if (currentHref != document.location.href && currentHref + '#' != document.location.href) { + //This occurs when the user has navigated to a specific URL + //within the app, and didn't use browser back/forward + //IE seems to have a bug where it stops updating the URL it + //shows the end-user at this point, but programatically it + //appears to be correct. Do a full app reload to get around + //this issue. + if (browser.version < 7) { + currentHref = document.location.href; + document.location.reload(); + } else { + if (getHash() != getIframeHash()) { + // this.iframe.src = this.blankURL + hash; + var sourceToSet = historyFrameSourcePrefix + getHash(); + getHistoryFrame().src = sourceToSet; + } + } + } + } + + if (browser.safari) { + // For Safari, we have to check to see if history.length changed. + if (currentHistoryLength >= 0 && history.length != currentHistoryLength) { + //alert("did change: " + history.length + ", " + historyHash.length + "|" + historyHash[history.length] + "|>" + historyHash.join("|")); + // If it did change, then we have to look the old state up + // in our hand-maintained array since document.location.hash + // won't have changed, then call back into BrowserManager. + currentHistoryLength = history.length; + var flexAppUrl = historyHash[currentHistoryLength]; + if (flexAppUrl == '') { + //flexAppUrl = defaultHash; + } + //ADR: to fix multiple + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + pl[i].browserURLChange(flexAppUrl); + } + } else { + getPlayer().browserURLChange(flexAppUrl); + } + _storeStates(); + } + } + if (browser.firefox) { + if (currentHref != document.location.href) { + var bsl = backStack.length; + + var urlActions = { + back: false, + forward: false, + set: false + } + + if ((window.location.hash == initialHash || window.location.href == initialHref) && (bsl == 1)) { + urlActions.back = true; + // FIXME: could this ever be a forward button? + // we can't clear it because we still need to check for forwards. Ugg. + // clearInterval(this.locationTimer); + handleBackButton(); + } + + // first check to see if we could have gone forward. We always halt on + // a no-hash item. + if (forwardStack.length > 0) { + if (forwardStack[forwardStack.length-1].flexAppUrl == getHash()) { + urlActions.forward = true; + handleForwardButton(); + } + } + + // ok, that didn't work, try someplace back in the history stack + if ((bsl >= 2) && (backStack[bsl - 2])) { + if (backStack[bsl - 2].flexAppUrl == getHash()) { + urlActions.back = true; + handleBackButton(); + } + } + + if (!urlActions.back && !urlActions.forward) { + var foundInStacks = { + back: -1, + forward: -1 + } + + for (var i = 0; i < backStack.length; i++) { + if (backStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { + arbitraryUrl = true; + foundInStacks.back = i; + } + } + for (var i = 0; i < forwardStack.length; i++) { + if (forwardStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { + arbitraryUrl = true; + foundInStacks.forward = i; + } + } + handleArbitraryUrl(); + } + + // Firefox changed; do a callback into BrowserManager to tell it. + currentHref = document.location.href; + var flexAppUrl = getHash(); + if (flexAppUrl == '') { + //flexAppUrl = defaultHash; + } + //ADR: to fix multiple + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + pl[i].browserURLChange(flexAppUrl); + } + } else { + getPlayer().browserURLChange(flexAppUrl); + } + } + } + //setTimeout(checkForUrlChange, 50); + } + + /* Write an anchor into the page to legitimize it as a URL for Firefox et al. */ + function addAnchor(flexAppUrl) + { + if (document.getElementsByName(flexAppUrl).length == 0) { + getAnchorElement().innerHTML += "" + flexAppUrl + ""; + } + } + + var _initialize = function () { + if (browser.ie) + { + var scripts = document.getElementsByTagName('script'); + for (var i = 0, s; s = scripts[i]; i++) { + if (s.src.indexOf("history.js") > -1) { + var iframe_location = (new String(s.src)).replace("history.js", "historyFrame.html"); + } + } + historyFrameSourcePrefix = iframe_location + "?"; + var src = historyFrameSourcePrefix; + + var iframe = document.createElement("iframe"); + iframe.id = 'ie_historyFrame'; + iframe.name = 'ie_historyFrame'; + //iframe.src = historyFrameSourcePrefix; + try { + document.body.appendChild(iframe); + } catch(e) { + setTimeout(function() { + document.body.appendChild(iframe); + }, 0); + } + } + + if (browser.safari) + { + var rememberDiv = document.createElement("div"); + rememberDiv.id = 'safari_rememberDiv'; + document.body.appendChild(rememberDiv); + rememberDiv.innerHTML = ''; + + var formDiv = document.createElement("div"); + formDiv.id = 'safari_formDiv'; + document.body.appendChild(formDiv); + + var reloader_content = document.createElement('div'); + reloader_content.id = 'safarireloader'; + var scripts = document.getElementsByTagName('script'); + for (var i = 0, s; s = scripts[i]; i++) { + if (s.src.indexOf("history.js") > -1) { + html = (new String(s.src)).replace(".js", ".html"); + } + } + reloader_content.innerHTML = ''; + document.body.appendChild(reloader_content); + reloader_content.style.position = 'absolute'; + reloader_content.style.left = reloader_content.style.top = '-9999px'; + iframe = reloader_content.getElementsByTagName('iframe')[0]; + + if (document.getElementById("safari_remember_field").value != "" ) { + historyHash = document.getElementById("safari_remember_field").value.split(","); + } + + } + + if (browser.firefox) + { + var anchorDiv = document.createElement("div"); + anchorDiv.id = 'firefox_anchorDiv'; + document.body.appendChild(anchorDiv); + } + + //setTimeout(checkForUrlChange, 50); + } + + return { + historyHash: historyHash, + backStack: function() { return backStack; }, + forwardStack: function() { return forwardStack }, + getPlayer: getPlayer, + initialize: function(src) { + _initialize(src); + }, + setURL: function(url) { + document.location.href = url; + }, + getURL: function() { + return document.location.href; + }, + getTitle: function() { + return document.title; + }, + setTitle: function(title) { + try { + backStack[backStack.length - 1].title = title; + } catch(e) { } + //if on safari, set the title to be the empty string. + if (browser.safari) { + if (title == "") { + try { + var tmp = window.location.href.toString(); + title = tmp.substring((tmp.lastIndexOf("/")+1), tmp.lastIndexOf("#")); + } catch(e) { + title = ""; + } + } + } + document.title = title; + }, + setDefaultURL: function(def) + { + defaultHash = def; + def = getHash(); + //trailing ? is important else an extra frame gets added to the history + //when navigating back to the first page. Alternatively could check + //in history frame navigation to compare # and ?. + if (browser.ie) + { + window['_ie_firstload'] = true; + var sourceToSet = historyFrameSourcePrefix + def; + var func = function() { + getHistoryFrame().src = sourceToSet; + window.location.replace("#" + def); + setInterval(checkForUrlChange, 50); + } + try { + func(); + } catch(e) { + window.setTimeout(function() { func(); }, 0); + } + } + + if (browser.safari) + { + currentHistoryLength = history.length; + if (historyHash.length == 0) { + historyHash[currentHistoryLength] = def; + var newloc = "#" + def; + window.location.replace(newloc); + } else { + //alert(historyHash[historyHash.length-1]); + } + //setHash(def); + setInterval(checkForUrlChange, 50); + } + + + if (browser.firefox || browser.opera) + { + var reg = new RegExp("#" + def + "$"); + if (window.location.toString().match(reg)) { + } else { + var newloc ="#" + def; + window.location.replace(newloc); + } + setInterval(checkForUrlChange, 50); + //setHash(def); + } + + }, + + /* Set the current browser URL; called from inside BrowserManager to propagate + * the application state out to the container. + */ + setBrowserURL: function(flexAppUrl, objectId) { + if (browser.ie && typeof objectId != "undefined") { + currentObjectId = objectId; + } + //fromIframe = fromIframe || false; + //fromFlex = fromFlex || false; + //alert("setBrowserURL: " + flexAppUrl); + //flexAppUrl = (flexAppUrl == "") ? defaultHash : flexAppUrl ; + + var pos = document.location.href.indexOf('#'); + var baseUrl = pos != -1 ? document.location.href.substr(0, pos) : document.location.href; + var newUrl = baseUrl + '#' + flexAppUrl; + + if (document.location.href != newUrl && document.location.href + '#' != newUrl) { + currentHref = newUrl; + addHistoryEntry(baseUrl, newUrl, flexAppUrl); + currentHistoryLength = history.length; + } + + return false; + }, + + browserURLChange: function(flexAppUrl) { + var objectId = null; + if (browser.ie && currentObjectId != null) { + objectId = currentObjectId; + } + pendingURL = ''; + + if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { + var pl = getPlayers(); + for (var i = 0; i < pl.length; i++) { + try { + pl[i].browserURLChange(flexAppUrl); + } catch(e) { } + } + } else { + try { + getPlayer(objectId).browserURLChange(flexAppUrl); + } catch(e) { } + } + + currentObjectId = null; + } + + } + +})(); + +// Initialization + +// Automated unit testing and other diagnostics + +function setURL(url) +{ + document.location.href = url; +} + +function backButton() +{ + history.back(); +} + +function forwardButton() +{ + history.forward(); +} + +function goForwardOrBackInHistory(step) +{ + history.go(step); +} + +//BrowserHistoryUtils.addEvent(window, "load", function() { BrowserHistory.initialize(); }); +(function(i) { + var u =navigator.userAgent;var e=/*@cc_on!@*/false; + var st = setTimeout; + if(/webkit/i.test(u)){ + st(function(){ + var dr=document.readyState; + if(dr=="loaded"||dr=="complete"){i()} + else{st(arguments.callee,10);}},10); + } else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){ + document.addEventListener("DOMContentLoaded",i,false); + } else if(e){ + (function(){ + var t=document.createElement('doc:rdy'); + try{t.doScroll('left'); + i();t=null; + }catch(e){st(arguments.callee,0);}})(); + } else{ + window.onload=i; + } +})( function() {BrowserHistory.initialize();} ); Index: lams_central/web/fckeditor/editor/plugins/videorecorder/history/historyFrame.html =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/history/historyFrame.html (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/history/historyFrame.html (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,29 @@ + + + + + + + + Hidden frame for Browser History support. + + Index: lams_central/web/fckeditor/editor/plugins/videorecorder/icon.png =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/lang/en.js =================================================================== diff -u --- lams_central/web/fckeditor/editor/plugins/videorecorder/lang/en.js (revision 0) +++ lams_central/web/fckeditor/editor/plugins/videorecorder/lang/en.js (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,32 @@ +FCKLang.VideoRecorderBtn = 'Insert a video recording' ; +FCKLang.button_ok = 'OK' ; +FCKLang.button_save = 'Save' ; +FCKLang.button_cancel = 'Cancel' ; +FCKLang.button_yes = 'Yes' ; +FCKLang.button_no = 'No' ; +FCKLang.videorecorder_video_player = 'Video Player'; +FCKLang.videorecorder_video_recorder = 'Video Recorder'; +FCKLang.videorecorder_web_application_not_available = 'The requested web application is not available'; +FCKLang.videorecorder_net_connection_not_connected = 'Connection to the media server could not be established' ; +FCKLang.videorecorder_net_connection_closed = 'Connection to the media server closed'; +FCKLang.videorecorder_playing = 'Playing'; +FCKLang.videorecorder_ready = 'Ready'; +FCKLang.videorecorder_paused = 'Paused'; +FCKLang.videorecorder_recording = 'Recording'; +FCKLang.videorecorder_buffering = 'Buffering'; +FCKLang.videorecorder_waiting = 'Waiting'; +FCKLang.videorecorder_description = 'Description'; +FCKLang.videorecorder_title = 'Title'; +FCKLang.videorecorder_new_recording_details = 'New Recording Details'; +FCKLang.videorecorder_recording_complete_authoring = 'Recording complete and added to the list of video recordings. Click the play button to review the last added recording or the record button to record another video.'; +FCKLang.videorecorder_enter_something_here = 'Enter {0} here'; +FCKLang.videorecorder_recording_complete_fck = 'Recording complete. Click the play button to review, the record button to overwrite the recording or the save button to post the current recording.'; +FCKLang.videorecorder_tooltip_play = 'Play the recording'; +FCKLang.videorecorder_tooltip_pause = 'Pause the recording being played'; +FCKLang.videorecorder_tooltip_resume = 'Resume the recording'; +FCKLang.videorecorder_tooltip_save_recording = 'Save the recording'; +FCKLang.videorecorder_tooltip_start_recording = 'Start recording'; +FCKLang.videorecorder_tooltip_start_recording_again = 'Start recording again (overwrites previous recording)'; +FCKLang.videorecorder_tooltip_start_recording_next = 'Record another recording'; +FCKLang.videorecorder_tooltip_stop_recording = 'Stop recording'; +FCKLang.videorecorder_disabled = 'Disabled'; \ No newline at end of file Index: lams_central/web/fckeditor/editor/plugins/videorecorder/playerProductInstall.swf =================================================================== diff -u Binary files differ Index: lams_central/web/fckeditor/editor/plugins/videorecorder/screenshot.png =================================================================== diff -u Binary files differ Index: lams_central/web/includes/javascript/fckconfig_custom.js =================================================================== diff -u -r88eb4c294f771222c09198b0f0aa3e8cdaa30a86 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_central/web/includes/javascript/fckconfig_custom.js (.../fckconfig_custom.js) (revision 88eb4c294f771222c09198b0f0aa3e8cdaa30a86) +++ lams_central/web/includes/javascript/fckconfig_custom.js (.../fckconfig_custom.js) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -1,6 +1,6 @@ FCKConfig.ToolbarSets["Default"] = [ ['Source','-','FitWindow', 'Preview','PasteWord','Undo','Redo','Bold','Italic','Underline', '-','Subscript','Superscript','OrderedList','UnorderedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','TextColor','BGColor','Equation'], - ['MoviePlayer','Image','Link','Table','Rule','Smiley','SpecialChar','Templates','FontFormat','FontName','FontSize','About'] + ['MoviePlayer','VideoRecorder','Image','Link','Table','Rule','Smiley','SpecialChar','Templates','FontFormat','FontName','FontSize','About'] ] ; FCKConfig.ToolbarSets["Default-Learner"] = [ @@ -45,3 +45,4 @@ FCKConfig.Plugins.Add('wikilink', 'en', FCKConfig.BasePath + '../../../tool/lawiki10/'); FCKConfig.Plugins.Add('equation', 'en'); FCKConfig.Plugins.Add('movieplayer', 'en'); +FCKConfig.Plugins.Add('videorecorder', 'en'); Index: lams_common/db/sql/insert_lams_windows_config_data.sql =================================================================== diff -u -r00a6e145b37916eb1561ea5c68319b0fc691681b -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_common/db/sql/insert_lams_windows_config_data.sql (.../insert_lams_windows_config_data.sql) (revision 00a6e145b37916eb1561ea5c68319b0fc691681b) +++ lams_common/db/sql/insert_lams_windows_config_data.sql (.../insert_lams_windows_config_data.sql) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -245,4 +245,10 @@ values ('SMTPUser','', 'config.smtp.user', 'config.header.email', 'STRING', 0); insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) -values ('SMTPPassword','', 'config.smtp.password', 'config.header.email', 'STRING', 0); \ No newline at end of file +values ('SMTPPassword','', 'config.smtp.password', 'config.header.email', 'STRING', 0); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('Red5ServerUrl','rtmp://localhost/', 'config.red5.server.url', 'config.header.red5', 'STRING', 1); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('Red5RecordingsUrl','http://localhost:8080/streams/', 'config.red5.recordings.url', 'config.header.red5', 'STRING', 1); Index: lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java =================================================================== diff -u -r3b1c6836dcfb5f9b80c9284d1815139d1fc08b30 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 3b1c6836dcfb5f9b80c9284d1815139d1fc08b30) +++ lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -244,7 +244,11 @@ public static String ADMIN_SCREEN_SIZE = "AdminScreenSize"; public static String GMAP_KEY = "GmapKey"; + + public static String RED5_SERVER_URL = "Red5ServerUrl"; + public static String RED5_RECORDINGS_URL = "Red5RecordingsUrl"; + public static String SMTP_AUTH_USER = "SMTPUser"; public static String SMTP_AUTH_PASSWORD = "SMTPPassword"; Index: lams_flash/src/central/flex/VideoRecorder/src/AddCommentPopUp.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/AddCommentPopUp.mxml (.../AddCommentPopUp.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/AddCommentPopUp.mxml (.../AddCommentPopUp.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -16,6 +16,10 @@ this.dictionary = dictionary; commentLabel.text = dictionary.getLabelAndConcatenate("videorecorder.comment", [":"]); commentInput.text = dictionary.getLabelAndReplace("videorecorder.enter.something.here", ["videorecorder.comment"]); + cancelButton.label = dictionary.getLabel("button.cancel"); + cancelButton.toolTip = dictionary.getLabel("videorecorder.tooltip.cancel.comment"); + okButton.label = dictionary.getLabel("button.save"); + okButton.toolTip = dictionary.getLabel("videorecorder.tooltip.save.comment"); } ]]> Index: lams_flash/src/central/flex/VideoRecorder/src/GetRecordingDetailsPopUp.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/GetRecordingDetailsPopUp.mxml (.../GetRecordingDetailsPopUp.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/GetRecordingDetailsPopUp.mxml (.../GetRecordingDetailsPopUp.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -19,7 +19,8 @@ descriptionLabel.text = dictionary.getLabelAndConcatenate("videorecorder.description", [":"]); titleInput.text = dictionary.getLabelAndReplace("videorecorder.enter.something.here", ["videorecorder.title"]); descriptionInput.text = dictionary.getLabelAndReplace("videorecorder.enter.something.here", ["videorecorder.description"]); - doneButton.label = dictionary.getLabel("button.done"); + doneButton.label = dictionary.getLabel("button.save"); + doneButton.toolTip = dictionary.getLabel("videorecorder.tooltip.save.recording"); } public function set dictionary(dictionary:XMLDictionary):void{ @@ -35,8 +36,8 @@ - + Index: lams_flash/src/central/flex/VideoRecorder/src/HTTPServices.as =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/HTTPServices.as (.../HTTPServices.as) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/HTTPServices.as (.../HTTPServices.as) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -6,6 +6,7 @@ videoRecorderActions.resultFormat = "e4x"; videoRecorderActions.request.method = "getRecordingsByToolSessionIdAndUserId"; videoRecorderActions.request.toolSessionId = toolSessionId; + videoRecorderActions.request.toolContentId = toolContentId; videoRecorderActions.request.userId = userId; if(allowLearnerVideoVisibility || mode == "teacher") @@ -52,6 +53,9 @@ else videoRecorderActions.request.isJustSound = false; + videoRecorderActions.request.toolContentId = -1; + videoRecorderActions.request.saveToLams = false; + videoRecorderActions.request.toolSessionId = toolSessionId; videoRecorderActions.addEventListener(ResultEvent.RESULT, saveRecordingSuccessHandler); videoRecorderActions.addEventListener(FaultEvent.FAULT, saveRecordingFaultHandler); @@ -136,6 +140,9 @@ // set the user's voted value ratingClicked.votedValue = e.result.userRating; + // fix the tooltip + ratingClicked.toolTip = dictionary.getLabelAndConcatenate("videorecorder.tooltip.already.rated", [" ", String(e.result.userRating)]); + // update the video recordings getRecordingsFromServer(sortButtonGroup.sortBy, sortButtonGroup.sortDirection); } Index: lams_flash/src/central/flex/VideoRecorder/src/VideoInformation.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/VideoInformation.mxml (.../VideoInformation.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/VideoInformation.mxml (.../VideoInformation.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -5,27 +5,35 @@ import org.lamsfoundation.lams.common.dictionary.XMLDictionary; import mx.core.Application; - private var allowRatings:Boolean; - private var allowComments:Boolean; - private var dictionary:XMLDictionary; + public var allowRatings:Boolean; + public var allowComments:Boolean; + public var dictionary:XMLDictionary; - public function init():void{ - allowRatings = Application.application.getAllowRatings(); - allowComments = Application.application.getAllowComments(); - dictionary = Application.application.getDictionary(); - + public function init():void{ // enable/disable ratings if(!allowRatings) authorBox.removeChild(authorBox.getChildByName("ratingsBox")); // enable/disable comments if(!allowComments) videoInformationBox.removeChild(videoInformationBox.getChildByName("commentsBox")); + + enableVideoInformationButtons(false); + resetInformation(); } public function enableVideoInformationButtons(enabled:Boolean):void{ ratingButton.enabled = enabled; addCommentButton.enabled = enabled; + + if(enabled){ + addCommentButton.toolTip = dictionary.getLabel("videorecorder.tooltip.add.comment"); + ratingButton.toolTip = dictionary.getLabel("videorecorder.tooltip.rate.recording"); + } + else{ + addCommentButton.toolTip = dictionary.getLabelAndConcatenate("videorecorder.tooltip.add.comment", [" (", dictionary.getLabel("videorecorder.disabled"), ")"]); + ratingButton.toolTip = dictionary.getLabelAndConcatenate("videorecorder.tooltip.rate.recording", [" (", dictionary.getLabel("videorecorder.disabled"), ")"]); + } } public function printComments(comments:XMLList):void{ @@ -54,7 +62,8 @@ ratingButton.value = 0; ratingButton.votedValue = 0; ratingButton.enabled = false; - addCommentButton.enabled = false; + addCommentButton.enabled = false; + addCommentButton.toolTip = dictionary.getLabelAndConcatenate("videorecorder.tooltip.add.comment", [" (", dictionary.getLabel("videorecorder.disabled"), ")"]); } ]]> Index: lams_flash/src/central/flex/VideoRecorder/src/VideoProfile.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/VideoProfile.mxml (.../VideoProfile.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/VideoProfile.mxml (.../VideoProfile.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -2,21 +2,30 @@ @@ -33,7 +42,7 @@ - + Index: lams_flash/src/central/flex/VideoRecorder/src/VideoRecorder.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorder/src/VideoRecorder.mxml (.../VideoRecorder.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorder/src/VideoRecorder.mxml (.../VideoRecorder.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -1,8 +1,9 @@ - + - + - + Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/.project =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorderFCKEditor/.project (.../.project) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorderFCKEditor/.project (.../.project) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -17,6 +17,11 @@ + bin-release1 + 2 + D:/LAMS_HEAD/lams_central/web/fckeditor/editor/plugins/videorecorder + + [source path] flex 2 D:/LAMS_HEAD/lams_flash/src/common/flex Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/src/GetRecordingDetailsPopUp.mxml =================================================================== diff -u --- lams_flash/src/central/flex/VideoRecorderFCKEditor/src/GetRecordingDetailsPopUp.mxml (revision 0) +++ lams_flash/src/central/flex/VideoRecorderFCKEditor/src/GetRecordingDetailsPopUp.mxml (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/src/HTTPServices.as =================================================================== diff -u --- lams_flash/src/central/flex/VideoRecorderFCKEditor/src/HTTPServices.as (revision 0) +++ lams_flash/src/central/flex/VideoRecorderFCKEditor/src/HTTPServices.as (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,100 @@ +// creates an httpservice and saves a video recording +import mx.rpc.events.FaultEvent; +import mx.rpc.events.ResultEvent; +import mx.rpc.http.HTTPService; + +private function saveRecordingToServer(title:String, description:String, filename:String, toolContentId:int):void{ + var videoRecorderActions:HTTPService = new HTTPService(); + videoRecorderActions.url = toolServletUrl; + videoRecorderActions.method = "POST"; + videoRecorderActions.resultFormat = "e4x"; + videoRecorderActions.request.method = "saveRecording"; + videoRecorderActions.request.title = title; + videoRecorderActions.request.description = description; + videoRecorderActions.request.filename = filename; + videoRecorderActions.request.toolContentId = toolContentId; + + videoRecorderActions.request.saveToLams = false; + videoRecorderActions.request.isJustSound = false; + videoRecorderActions.request.userId = -1; + videoRecorderActions.request.toolSessionId = -1; + videoRecorderActions.request.recordingId = -1; + videoRecorderActions.request.rating = 0; + + videoRecorderActions.addEventListener(ResultEvent.RESULT, saveRecordingSuccessHandler); + videoRecorderActions.addEventListener(FaultEvent.FAULT, saveRecordingFaultHandler); + + videoRecorderActions.send(); +} + +// success handler for successful save recording +private function saveRecordingSuccessHandler(e:ResultEvent):void { + // alert complete + Alert.show(dictionary.getLabel("videorecorder.recording.complete.authoring")); + + // change the start recording button's label + videoDisplay.makeReadyVideo(filename); + + // update tooltip + videoControlBar.recordButton.toolTip = dictionary.getLabel("videorecorder.tooltip.start.recording.again"); + + // change the panel status + videoDisplayPanel.status = dictionary.getLabel("videorecorder.ready"); +} + +// fault handler for save recording +private function saveRecordingFaultHandler(e:FaultEvent):void { + Alert.show(e.toString()); +} + +// export recording to lams server +private function copyRecordingToLamsServer(src:String, dir:String, filename:String):void{ + var videoRecorderActions:HTTPService = new HTTPService(); + videoRecorderActions.url = saveToLamsServletUrl; + videoRecorderActions.method = "POST"; + videoRecorderActions.resultFormat = "e4x"; + + videoRecorderActions.request.urlStr = src; + videoRecorderActions.request.dir = dir; + videoRecorderActions.request.filename = filename; + + videoRecorderActions.addEventListener(ResultEvent.RESULT, copyRecordingToLamsServerSuccessHandler); + videoRecorderActions.addEventListener(FaultEvent.FAULT, copyRecordingToLamsServerFaultHandler); + + videoRecorderActions.send(); +} + +// success handler for copy recording +private function copyRecordingToLamsServerSuccessHandler(e:ResultEvent):void { + // rock on +} +// fault handler for copy recording +private function copyRecordingToLamsServerFaultHandler(e:FaultEvent):void { + Alert.show(e.toString()); +} + +// attempts to get lanugage XML +private function getLanguageXMLFromServer():void{ + var videoRecorderActions:HTTPService = new HTTPService(); + videoRecorderActions.url = saveToLamsServletUrl; + videoRecorderActions.method = "POST"; + videoRecorderActions.resultFormat = "e4x"; + + videoRecorderActions.request.method = "getLanguageXMLForFCK"; + + videoRecorderActions.addEventListener(ResultEvent.RESULT, getLanguageXMLSuccessHandler); + videoRecorderActions.addEventListener(FaultEvent.FAULT, getLanguageXMLFaultHandler); + + videoRecorderActions.send(); +} + +// success handler for get lanugage XML +private function getLanguageXMLSuccessHandler(e:ResultEvent):void { + setLanguageXML(String(e.result)); +} + +// fault handler for get lanugage XML +private function getLanguageXMLFaultHandler(e:FaultEvent):void { + Alert.show(e.toString()); +} + Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoControlBar.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoControlBar.mxml (.../VideoControlBar.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoControlBar.mxml (.../VideoControlBar.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -6,10 +6,12 @@ private var _mode:String; private function onCreationComplete(event:Event):void{ - if(_mode == "playerModeOffline" || _mode == "playerModeOffline"){ + if(_mode == "playerModeOffline" || _mode == "playerModeOnline"){ removeChild(getChildByName("recordButton")); removeChild(getChildByName("saveAndCloseButton")); } + else if(_mode == "recorderModeAuthor") + removeChild(getChildByName("saveAndCloseButton")); } public function set mode(mode:String):void{ @@ -18,9 +20,9 @@ ]]> - - + + - + \ No newline at end of file Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoRecorderFCKEditor.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoRecorderFCKEditor.mxml (.../VideoRecorderFCKEditor.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/central/flex/VideoRecorderFCKEditor/src/VideoRecorderFCKEditor.mxml (.../VideoRecorderFCKEditor.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -3,6 +3,12 @@ - + Index: lams_flash/src/central/flex/VideoRecorderFCKEditor/src/assets/images/okIcon.swf =================================================================== diff -u Binary files differ Index: lams_flash/src/common/flex/org/lamsfoundation/lams/common/ui/components/VideoDisplay.mxml =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/common/flex/org/lamsfoundation/lams/common/ui/components/VideoDisplay.mxml (.../VideoDisplay.mxml) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/common/flex/org/lamsfoundation/lams/common/ui/components/VideoDisplay.mxml (.../VideoDisplay.mxml) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -298,45 +298,42 @@ // view camera helper method to start and stop actual viewing public function viewCameraHelper():void { - // if camera is set - if(_cam){ - // if camera is not being used - if(!isCameraViewed){ - // reset video - reset(); + // if camera is not being used + if(!isCameraViewed){ + // reset video + reset(); + + // if the item clicked is full video OR if showing a camera + if(_cam){ + // attach the cam to the videoDisplay + video.attachCamera(_cam); - // if the item clicked is full video OR if showing a camera - if(_cam && _mic){ - // attach the cam to the videoDisplay - video.attachCamera(_cam); - - //change the view stack - selectedChild = recorderView; - } - // else if the item played is sound OR if we can only start sound - else if(_mic && !_cam){ - //change the view stack - selectedChild = audioView; - } - - _isCameraViewed = true; - - // dispatch event - dispatchEvent(new VideoDisplayEvent(VideoDisplayEvent.STARTCAM)); + //change the view stack + selectedChild = recorderView; } - // if camera is being used - else { - // clear the videoDisplay - video.attachCamera(null); - _isCameraViewed = false; - - // change view - selectedChild = blackView; - - // dispatch event - dispatchEvent(new VideoDisplayEvent(VideoDisplayEvent.STOPCAM)); + // else if the item played is sound OR if we can only start sound + else if(_mic && !_cam){ + //change the view stack + selectedChild = audioView; } + + _isCameraViewed = true; + + // dispatch event + dispatchEvent(new VideoDisplayEvent(VideoDisplayEvent.STARTCAM)); } + // if camera is being used + else { + // clear the videoDisplay + video.attachCamera(null); + _isCameraViewed = false; + + // change view + selectedChild = blackView; + + // dispatch event + dispatchEvent(new VideoDisplayEvent(VideoDisplayEvent.STOPCAM)); + } } // publish method Index: lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/ArgumentsToRendererFactory.as =================================================================== diff -u --- lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/ArgumentsToRendererFactory.as (revision 0) +++ lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/ArgumentsToRendererFactory.as (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,31 @@ +package org.lamsfoundation.lams.common.util +{ + import flash.utils.Dictionary; + + import mx.core.IFactory; + + public class ArgumentsToRendererFactory implements IFactory + { + private var klass:Class; + private var args:*; + + public function ArgumentsToRendererFactory(args:*,klass:Class) { + this.args=args; + this.klass=klass; + } + + public function newInstance():* + { + var instance:Object = new klass; + + + for (var key:String in args) { + if (instance.hasOwnProperty(key)) { + instance[key] = args[key]; + } + } + + return instance; + } + } +} \ No newline at end of file Index: lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/VideoDisplayUtil.as =================================================================== diff -u -r251a00158d63f52d7482fa4aa2decb78d6322a8c -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/VideoDisplayUtil.as (.../VideoDisplayUtil.as) (revision 251a00158d63f52d7482fa4aa2decb78d6322a8c) +++ lams_flash/src/common/flex/org/lamsfoundation/lams/common/util/VideoDisplayUtil.as (.../VideoDisplayUtil.as) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -26,6 +26,11 @@ return "lamsRecording_forFCK" + "_user" + userId + "_" + randomNumber(1, 1000000000); } + + public static function createFilenameForAuthor(toolContentId:int):String{ + + return "lamsRecording_tool" + toolContentId + "_" + randomNumber(1, 1000000000); + } // creates a random number between bounds private static function randomNumber(low:Number=NaN, high:Number=NaN):Number { Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MultipleDirFileBundler.java =================================================================== diff -u --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MultipleDirFileBundler.java (revision 0) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MultipleDirFileBundler.java (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -0,0 +1,70 @@ +package org.lamsfoundation.lams.learning.export.web.action; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +import org.lamsfoundation.lams.util.HttpUrlConnectionUtil; +import org.lamsfoundation.lams.learning.export.web.action.Bundler; + +/** + * Added this bundler when files need to be accessed from different directories + * + * @author pgeorges + * + */ + +public class MultipleDirFileBundler extends Bundler { + + public MultipleDirFileBundler() {} + + /** + * This method bundles the files to the given output dir + * + * @param request the request for the export + * @param cookies cookies for the request + * @param outputDirectory the location where the files should be written + * @param toolImageUrlDir the url location of the images directory + * @param fileNames an array of file-names (not paths) you wish to include in the bundle + * @throws Exception + */ + public void bundle(HttpServletRequest request, Cookie[] cookies, String outputDirectory, String[] fileUrlDir, ArrayList[] filenames) throws Exception + { + bundleViaHTTP(request, cookies, outputDirectory, fileUrlDir, filenames); + } + + /** + * See bundle + * + * @param request + * @param cookies + * @param outputDirectory + * @param toolImageUrlDir + * @param fileNames + * @throws MalformedURLException + * @throws FileNotFoundException + * @throws IOException + */ + private void bundleViaHTTP(HttpServletRequest request, Cookie[] cookies, String outputDirectory, String[] fileUrlDir, ArrayList[] filenames) + throws MalformedURLException, FileNotFoundException, IOException + { + + String fileDirStr = outputDirectory+File.separator+"files"; + File fileDir = new File(fileDirStr); + fileDir.mkdirs(); + + for(int i = 0; i < filenames.length; i++){ + ArrayList filenameArray = filenames[i]; + + for(int j = 0; j < filenameArray.size(); j++){ + String url = fileUrlDir[i] + filenameArray.get(j); + HttpUrlConnectionUtil.writeResponseToFile(url, fileDirStr, filenameArray.get(j), cookies); + } + } + } +} Index: lams_tool_videorecorder/db/sql/create_lams_tool_videoRecorder.sql =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/db/sql/create_lams_tool_videoRecorder.sql (.../create_lams_tool_videoRecorder.sql) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/db/sql/create_lams_tool_videoRecorder.sql (.../create_lams_tool_videoRecorder.sql) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -41,6 +41,8 @@ allow_learner_video_export bit, allow_comments bit, allow_ratings bit, + export_offline bit, + export_all bit, primary key (uid) )type=innodb; @@ -56,6 +58,7 @@ create table tl_lavidr10_recording ( uid bigint not null auto_increment, + tool_content_id bigint, create_date datetime, update_date datetime, create_by bigint, @@ -118,7 +121,9 @@ allow_learner_video_visibility, allow_learner_video_export, allow_comments, - allow_ratings) + allow_ratings, + export_offline, + export_all) VALUES( "VideoRecorder", "Instructions", @@ -134,6 +139,8 @@ 1, 1, 1, + 1, + 1, 1 ); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/IVideoRecorderRecordingDAO.java =================================================================== diff -u -r3d081de4a45da632ee6029251318fac795d41813 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/IVideoRecorderRecordingDAO.java (.../IVideoRecorderRecordingDAO.java) (revision 3d081de4a45da632ee6029251318fac795d41813) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/IVideoRecorderRecordingDAO.java (.../IVideoRecorderRecordingDAO.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -42,6 +42,8 @@ List getByToolSessionId(Long toolSessionId); + List getByToolContentId(Long toolContentId); + List getBySessionAndUserIds(Long toolSessionId, Long userId); void saveOrUpdate(VideoRecorderRecording videoRecorderRecording); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/hibernate/VideoRecorderRecordingDAO.java =================================================================== diff -u -r3d081de4a45da632ee6029251318fac795d41813 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/hibernate/VideoRecorderRecordingDAO.java (.../VideoRecorderRecordingDAO.java) (revision 3d081de4a45da632ee6029251318fac795d41813) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dao/hibernate/VideoRecorderRecordingDAO.java (.../VideoRecorderRecordingDAO.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -43,6 +43,9 @@ private static final String SQL_QUERY_BY_SESSION_ID = "from " + VideoRecorderRecording.class.getName() + " as vrr " + "where vrr.videoRecorderSession.sessionId=?"; + private static final String SQL_QUERY_BY_TOOL_CONTENT_ID = "from " + VideoRecorderRecording.class.getName() + " as vrr " + + "where vrr.toolContentId=?"; + private static final String SQL_QUERY_BY_SESSION_ID_AND_USER_ID = "from " + VideoRecorderRecording.class.getName() + " as vrr " + "where vrr.videoRecorderSession.sessionId=? and vrr.createBy=?"; @@ -65,6 +68,10 @@ return (List)(this.getHibernateTemplate().find(SQL_QUERY_BY_SESSION_ID_AND_USER_ID, new Object[] {toolSessionId, userId})); } + public List getByToolContentId(Long toolContentId){ + return (List)(this.getHibernateTemplate().find(SQL_QUERY_BY_TOOL_CONTENT_ID, toolContentId)); + } + public void saveOrUpdate(VideoRecorderRecording videoRecorderRecording) { this.getHibernateTemplate().saveOrUpdate(videoRecorderRecording); this.getHibernateTemplate().flush(); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderDTO.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderDTO.java (.../VideoRecorderDTO.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderDTO.java (.../VideoRecorderDTO.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -59,13 +59,15 @@ public boolean allowUseCamera; - public boolean allowLearnerVideoExport; - public boolean allowLearnerVideoVisibility; public boolean allowComments; public boolean allowRatings; + + public boolean exportOffline; + + public boolean exportAll; public Set onlineInstructionsFiles; @@ -88,10 +90,11 @@ lockOnFinish = videoRecorder.isLockOnFinished(); allowUseVoice = videoRecorder.isAllowUseVoice(); allowUseCamera = videoRecorder.isAllowUseCamera(); - allowLearnerVideoExport = videoRecorder.isAllowLearnerVideoExport(); allowLearnerVideoVisibility = videoRecorder.isAllowLearnerVideoVisibility(); allowComments = videoRecorder.isAllowComments(); allowRatings = videoRecorder.isAllowRatings(); + exportAll = videoRecorder.isExportAll(); + exportOffline = videoRecorder.isExportOffline(); onlineInstructionsFiles = new TreeSet(); offlineInstructionsFiles = new TreeSet(); @@ -218,15 +221,7 @@ public void setLearnerVideoVisibility(boolean allowLearnerVideoVisibility) { this.allowLearnerVideoVisibility = allowLearnerVideoVisibility; } - - public boolean isAllowLearnerVideoExport() { - return allowLearnerVideoExport; - } - - public void setAllowLearnerVideoExport(boolean allowLearnerVideoExport) { - this.allowLearnerVideoExport = allowLearnerVideoExport; - } - + public boolean isAllowComments() { return allowComments; } @@ -243,6 +238,22 @@ this.allowRatings = allowRatings; } + public boolean isExportOffline() { + return exportOffline; + } + + public void setExportOffline(boolean exportOffline) { + this.exportOffline = exportOffline; + } + + public boolean isExportAll() { + return exportAll; + } + + public void setExportAll(boolean exportAll) { + this.exportAll = exportAll; + } + public boolean isLockOnFinish() { return lockOnFinish; } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderRecordingDTO.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderRecordingDTO.java (.../VideoRecorderRecordingDTO.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/dto/VideoRecorderRecordingDTO.java (.../VideoRecorderRecordingDTO.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -47,6 +47,8 @@ private static Logger logger = Logger.getLogger(VideoRecorderRecordingDTO.class); public Long uid; + + public Long toolContentId; public Date createDate; @@ -75,6 +77,7 @@ public VideoRecorderRecordingDTO(VideoRecorderRecording videoRecorderRecording) { this.uid = videoRecorderRecording.getUid(); + this.toolContentId = videoRecorderRecording.getToolContentId(); this.createDate = videoRecorderRecording.getCreateDate(); this.updateDate = videoRecorderRecording.getUpdateDate(); this.createBy = videoRecorderRecording.getCreateBy(); @@ -112,6 +115,14 @@ this.uid = uid; } + public Long getToolContentId() { + return toolContentId; + } + + public void setToolContentId(Long toolContentId) { + this.toolContentId = toolContentId; + } + public Date getCreateDate() { return createDate; } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorder.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorder.java (.../VideoRecorder.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorder.java (.../VideoRecorder.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -71,15 +71,17 @@ private boolean allowUseVoice; private boolean allowUseCamera; - - private boolean allowLearnerVideoExport; - + private boolean allowLearnerVideoVisibility; private boolean allowComments; private boolean allowRatings; + private boolean exportOffline; + + private boolean exportAll; + private String onlineInstructions; private String offlineInstructions; @@ -110,7 +112,8 @@ boolean runOffline, boolean lockOnFinished, boolean filteringEnabled, String filterKeywords, String onlineInstructions, String offlineInstructions, boolean contentInUse, boolean defineLater, boolean allowUseVoice, boolean allowUseCamera, boolean allowLearnerVideoExport, boolean allowLearnerVideoVisibility, - Long toolContentId, Set videoRecorderAttachments, Set videoRecorderSessions) { + Long toolContentId, Set videoRecorderAttachments, Set videoRecorderSessions, boolean exportAll, + boolean exportOffline) { this.createDate = createDate; this.updateDate = updateDate; this.createBy = createBy; @@ -127,8 +130,9 @@ this.videoRecorderSessions = videoRecorderSessions; this.allowUseVoice = allowUseVoice; this.allowUseCamera = allowUseCamera; - this.allowLearnerVideoExport = allowLearnerVideoExport; this.allowLearnerVideoVisibility = allowLearnerVideoVisibility; + this.exportOffline = exportOffline; + this.exportAll = exportAll; } // Property accessors @@ -273,18 +277,6 @@ } /** - * @hibernate.property column="allow_learner_video_export" length="1" - * @return - */ - public boolean isAllowLearnerVideoExport() { - return allowLearnerVideoExport; - } - - public void setAllowLearnerVideoExport(boolean allowLearnerVideoExport) { - this.allowLearnerVideoExport = allowLearnerVideoExport; - } - - /** * @hibernate.property column="allow_comments" length="1" * @return */ @@ -307,8 +299,32 @@ public void setAllowRatings(boolean allowRatings) { this.allowRatings = allowRatings; } + + /** + * @hibernate.property column="export_offline" length="1" + * @return + */ + public boolean isExportOffline() { + return exportOffline; + } + + public void setExportOffline(boolean exportOffline) { + this.exportOffline = exportOffline; + } /** + * @hibernate.property column="export_all" length="1" + * @return + */ + public boolean isExportAll() { + return exportAll; + } + + public void setExportAll(boolean exportAll) { + this.exportAll = exportAll; + } + + /** * @hibernate.property column="online_instructions" length="65535" * */ @@ -434,7 +450,6 @@ buffer.append("allowUseVoice").append("='").append(isAllowUseVoice()).append("' "); buffer.append("allowUseCamera").append("='").append(isAllowUseCamera()).append("' "); buffer.append("allowLearnerVideoVisibility").append("='").append(isAllowLearnerVideoVisibility()).append("' "); - buffer.append("allowLearnerVideoExport").append("='").append(isAllowLearnerVideoExport()).append("' "); buffer.append("]"); return buffer.toString(); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderRecording.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderRecording.java (.../VideoRecorderRecording.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderRecording.java (.../VideoRecorderRecording.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -39,12 +39,14 @@ * @hibernate.class table="tl_lavidr10_recording" */ -public class VideoRecorderRecording implements java.io.Serializable { +public class VideoRecorderRecording implements java.io.Serializable, Cloneable{ private static final long serialVersionUID = -3701664859818409197L; // Fields private Long uid; + + private Long toolContentId; private Date createDate; @@ -75,6 +77,7 @@ } public VideoRecorderRecording(VideoRecorderRecordingDTO recording, VideoRecorderSession videoRecorderSession) { + this.uid = recording.uid; this.createDate = recording.createDate; this.updateDate = recording.updateDate; this.createBy = recording.createBy; @@ -86,13 +89,29 @@ this.comments = VideoRecorderComment.getVideoRecorderComments(recording.comments); this.videoRecorderSession = videoRecorderSession; this.filename = recording.filename; + this.toolContentId = recording.toolContentId; } + + public VideoRecorderRecording(VideoRecorderRecording recording){ + this.uid = recording.uid; + this.createDate = new Date(); + this.updateDate = new Date(); + this.createBy = recording.createBy; + this.title = recording.title; + this.description = recording.description; + this.rating = recording.rating; + this.isJustSound = false; + this.ratings = null; + this.comments = null; + this.filename = recording.filename; + this.toolContentId = recording.toolContentId; + } /** full constructor */ public VideoRecorderRecording( Date createDate, Date updateDate, VideoRecorderUser createBy, String title, String description, Float rating, Boolean isJustSound, Long videoRecorderUid, VideoRecorderSession videoRecorderSession, String filename, - Set ratings, Set comments) { + Set ratings, Set comments, Long toolContentId) { this.createDate = createDate; this.updateDate = updateDate; @@ -105,6 +124,7 @@ this.comments = comments; this.videoRecorderSession = videoRecorderSession; this.filename = filename; + this.toolContentId = toolContentId; } // Property accessors @@ -122,6 +142,19 @@ } /** + * @hibernate.property column="tool_content_id" + * + */ + + public Long getToolContentId() { + return toolContentId; + } + + public void setToolContentId(Long toolContentId) { + this.toolContentId = toolContentId; + } + + /** * @hibernate.property column="create_date" * */ @@ -327,4 +360,16 @@ + (getUid() == null ? 0 : this.getUid().hashCode()); return result; } + + public Object clone() { + Object obj = null; + try { + obj = super.clone(); + ((VideoRecorderRecording) obj).setUid(null); + } catch (CloneNotSupportedException e) { + return null; + } + + return obj; + } } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderSession.java =================================================================== diff -u -r3d081de4a45da632ee6029251318fac795d41813 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderSession.java (.../VideoRecorderSession.java) (revision 3d081de4a45da632ee6029251318fac795d41813) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/model/VideoRecorderSession.java (.../VideoRecorderSession.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -29,6 +29,7 @@ import java.util.Set; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderSessionDTO; /** * @@ -80,6 +81,11 @@ this.videoRecorder = videoRecorder; this.videoRecorderUsers = videoRecorderUsers; } + + public VideoRecorderSession(VideoRecorderSessionDTO videoRecorderSessionDTO) { + this.sessionId = videoRecorderSessionDTO.getSessionID(); + this.sessionName = videoRecorderSessionDTO.getSessionName(); + } // Property accessors /** Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/IVideoRecorderService.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/IVideoRecorderService.java (.../IVideoRecorderService.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/IVideoRecorderService.java (.../IVideoRecorderService.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -206,20 +206,36 @@ /** * * @param toolSessionId + * @param toolContentId * @return */ - public List getRecordingsByToolSessionId(Long toolSessionId); + public List getRecordingsByToolSessionId(Long toolSessionId, Long toolContentId); /** * * @param toolSessionId - * @paramuserId + * @param userId + * @param toolContentId * @return */ - public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId); + public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId, Long toolContentId); /** * + * @param toolContentId + * @return + */ + public List getRecordingsByToolContentId(Long toolContentId); + + /** + * + * @param toolContentId + * @return + */ + public VideoRecorderRecording getFirstRecordingByToolContentId(Long toolContentId); + + /** + * * @param videoRecorderRecording */ public void saveOrUpdateVideoRecorderRecording(VideoRecorderRecording videoRecorderRecording); @@ -274,4 +290,6 @@ public String getLanguageXML(); public String getLanguageXMLForFCK(); + + public String getMessage(String key); } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java (.../VideoRecorderService.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java (.../VideoRecorderService.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.Date; import java.util.Hashtable; +import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; @@ -219,10 +220,24 @@ if (fromContentId != null) { fromContent = videoRecorderDAO.getByContentId(fromContentId); } + + List list = videoRecorderRecordingDAO.getByToolContentId(fromContentId); + + VideoRecorderRecording vrr; + if(!list.isEmpty()){ + vrr = list.get(0); + VideoRecorderRecording clonedRecording = new VideoRecorderRecording(vrr); + clonedRecording.setUid(null); + clonedRecording.setToolContentId(toContentId); + videoRecorderRecordingDAO.saveOrUpdate(clonedRecording); + } + if (fromContent == null) { // create the fromContent using the default tool content fromContent = getDefaultContent(); } + + VideoRecorder toContent = VideoRecorder.newInstance(fromContent, toContentId, videoRecorderToolContentHandler); videoRecorderDAO.saveOrUpdate(toContent); } @@ -451,18 +466,34 @@ return VideoRecorderCommentDTO.getVideoRecorderCommentDTOs(list); } - public List getRecordingsByToolSessionId(Long toolSessionId){ + public List getRecordingsByToolSessionId(Long toolSessionId, Long toolContentId){ List list = videoRecorderRecordingDAO.getByToolSessionId(toolSessionId); + list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); } - public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId){ + public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId, Long toolContentId){ List list = videoRecorderRecordingDAO.getBySessionAndUserIds(toolSessionId, userId); + list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); } + public List getRecordingsByToolContentId(Long toolContentId){ + List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); + return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); + } + + public VideoRecorderRecording getFirstRecordingByToolContentId(Long toolContentId){ + List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); + if(!list.isEmpty()){ + return list.get(0); + }else{ + return null; + } + } + public VideoRecorderAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { if (file == null || StringUtils.isEmpty(file.getFileName())) { throw new VideoRecorderException("Could not find upload file: " + file); @@ -800,6 +831,8 @@ languageCollection.add(new String("videorecorder.enter.something.here")); languageCollection.add(new String("videorecorder.message.sure.delete")); languageCollection.add(new String("videorecorder.confirm")); + languageCollection.add(new String("videorecorder.update")); + languageCollection.add(new String("videorecorder.refresh")); languageCollection.add(new String("videorecorder.web.application.not.available")); languageCollection.add(new String("videorecorder.net.connection.not.connected")); languageCollection.add(new String("videorecorder.net.connection.closed")); @@ -809,6 +842,29 @@ languageCollection.add(new String("videorecorder.recording")); languageCollection.add(new String("videorecorder.buffering")); languageCollection.add(new String("videorecorder.waiting")); + languageCollection.add(new String("videorecorder.tooltip.sort.author")); + languageCollection.add(new String("videorecorder.tooltip.sort.title")); + languageCollection.add(new String("videorecorder.tooltip.sort.date")); + languageCollection.add(new String("videorecorder.tooltip.play")); + languageCollection.add(new String("videorecorder.tooltip.pause")); + languageCollection.add(new String("videorecorder.tooltip.resume")); + languageCollection.add(new String("videorecorder.tooltip.start.camera")); + languageCollection.add(new String("videorecorder.tooltip.stop.camera")); + languageCollection.add(new String("videorecorder.tooltip.add.comment")); + languageCollection.add(new String("videorecorder.tooltip.add.rating")); + languageCollection.add(new String("videorecorder.tooltip.refresh")); + languageCollection.add(new String("videorecorder.tooltip.save.recording")); + languageCollection.add(new String("videorecorder.tooltip.save.comment")); + languageCollection.add(new String("videorecorder.tooltip.cancel.comment")); + languageCollection.add(new String("videorecorder.tooltip.start.recording")); + languageCollection.add(new String("videorecorder.tooltip.stop.recording")); + languageCollection.add(new String("videorecorder.tooltip.delete.recording")); + languageCollection.add(new String("videorecorder.tooltip.export.recording")); + languageCollection.add(new String("videorecorder.tooltip.click.to.ready.recording")); + languageCollection.add(new String("videorecorder.tooltip.rate.recording")); + languageCollection.add(new String("videorecorder.tooltip.already.rated")); + languageCollection.add(new String("videorecorder.disabled")); + String languageOutput = ""; for(int i = 0; i < languageCollection.size(); i++){ @@ -822,6 +878,11 @@ public String getLanguageXMLForFCK(){ ArrayList languageCollection = new ArrayList(); + languageCollection.add(new String("button.ok")); + languageCollection.add(new String("button.save")); + languageCollection.add(new String("button.cancel")); + languageCollection.add(new String("button.yes")); + languageCollection.add(new String("button.no")); languageCollection.add(new String("videorecorder.video.player")); languageCollection.add(new String("videorecorder.video.recorder")); languageCollection.add(new String("videorecorder.web.application.not.available")); @@ -833,6 +894,22 @@ languageCollection.add(new String("videorecorder.recording")); languageCollection.add(new String("videorecorder.buffering")); languageCollection.add(new String("videorecorder.waiting")); + languageCollection.add(new String("videorecorder.description")); + languageCollection.add(new String("videorecorder.title")); + languageCollection.add(new String("videorecorder.new.recording.details")); + languageCollection.add(new String("videorecorder.recording.complete.authoring")); + languageCollection.add(new String("videorecorder.enter.something.here")); + languageCollection.add(new String("videorecorder.recording.complete.fck")); + languageCollection.add(new String("videorecorder.tooltip.play")); + languageCollection.add(new String("videorecorder.tooltip.pause")); + languageCollection.add(new String("videorecorder.tooltip.resume")); + languageCollection.add(new String("videorecorder.tooltip.save.recording")); + languageCollection.add(new String("videorecorder.tooltip.start.recording")); + languageCollection.add(new String("videorecorder.tooltip.start.recording.again")); + languageCollection.add(new String("videorecorder.tooltip.start.recording.next")); + languageCollection.add(new String("videorecorder.tooltip.stop.recording")); + languageCollection.add(new String("videorecorder.disabled")); + String languageOutput = ""; for(int i = 0; i < languageCollection.size(); i++){ @@ -843,4 +920,8 @@ return languageOutput; } -} + + public String getMessage(String key){ + return messageService.getMessage(key); + } +} \ No newline at end of file Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/util/VideoRecorderRecordingComparator.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/util/VideoRecorderRecordingComparator.java (.../VideoRecorderRecordingComparator.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/util/VideoRecorderRecordingComparator.java (.../VideoRecorderRecordingComparator.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -4,6 +4,7 @@ import java.util.Date; import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderRecordingDTO; +import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderUser; /** * @@ -22,9 +23,18 @@ public int compare(VideoRecorderRecordingDTO dto1, VideoRecorderRecordingDTO dto2) { if(sortBy.compareTo("author") == 0){ - Long userId1 = dto1.getCreateBy().getUid(); - Long userId2 = dto2.getCreateBy().getUid(); + VideoRecorderUser user1 = dto1.getCreateBy(); + VideoRecorderUser user2 = dto2.getCreateBy(); + if(user1 == null) + return -1; + + if(user2 == null) + return 1; + + Long userId1 = user1.getUid(); + Long userId2 = user2.getUid(); + if(userId1 > userId2) { if(sortDirection == "ascending") return -1; @@ -40,32 +50,57 @@ } } else if(sortBy.compareTo("date") == 0){ + VideoRecorderUser user1 = dto1.getCreateBy(); + VideoRecorderUser user2 = dto2.getCreateBy(); + + if(user1 == null) + return -1; + + if(user2 == null) + return 1; + Date date1 = dto1.getCreateDate(); Date date2 = dto2.getCreateDate(); + int difference = date1.compareTo(date2); + + if(Math.abs(difference) == 0) + return 1; + if(sortDirection.compareTo("ascending") == 0){ - int difference = date1.compareTo(date2); int result = difference / Math.abs(difference); return result; } else if(sortDirection.compareTo("descending") == 0){ - int difference = date1.compareTo(date2); int result = -difference / Math.abs(difference); return result; } } else if(sortBy.compareTo("title") == 0){ + VideoRecorderUser user1 = dto1.getCreateBy(); + VideoRecorderUser user2 = dto2.getCreateBy(); + + if(user1 == null) + return -1; + + if(user2 == null) + return 1; + String title1 = dto1.getTitle(); String title2 = dto2.getTitle(); + int difference = title1.compareTo(title2); + + if(Math.abs(difference) == 0) + return 1; + if(sortDirection.compareTo("ascending") == 0){ - int difference = title1.compareTo(title2); + int result = difference / Math.abs(difference); return result; } else if(sortDirection.compareTo("descending") == 0){ - int difference = title1.compareTo(title2); int result = -difference / Math.abs(difference); return result; } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/AuthoringAction.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -48,16 +49,25 @@ import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.ToolSessionManager; +import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderDTO; +import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderRecordingDTO; +import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderSessionDTO; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorder; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderAttachment; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderCondition; +import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderSession; +import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderUser; import org.lamsfoundation.lams.tool.videoRecorder.service.IVideoRecorderService; +import org.lamsfoundation.lams.tool.videoRecorder.service.VideoRecorderService; import org.lamsfoundation.lams.tool.videoRecorder.service.VideoRecorderServiceProxy; import org.lamsfoundation.lams.tool.videoRecorder.util.VideoRecorderConstants; import org.lamsfoundation.lams.tool.videoRecorder.web.forms.AuthoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.FileValidatorUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; @@ -98,6 +108,12 @@ // Extract toolContentID from parameters. Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + // get httpsession + HttpSession ss = SessionManager.getSession(); + + // get LAMS user + UserDTO user = (UserDTO)ss.getAttribute(AttributeNames.USER); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode", true); @@ -106,7 +122,10 @@ if (videoRecorderService == null) { videoRecorderService = VideoRecorderServiceProxy.getVideoRecorderService(this.getServlet().getServletContext()); } - + + // get toolSessionManager + ToolSessionManager toolSessionManager =VideoRecorderServiceProxy.getVideoRecorderSessionManager(this.getServlet().getServletContext()); + // retrieving VideoRecorder with given toolContentID VideoRecorder videoRecorder = videoRecorderService.getVideoRecorderByContentId(toolContentID); if (videoRecorder == null) { @@ -115,7 +134,25 @@ videoRecorderService.saveOrUpdateVideoRecorder(videoRecorder); // TODO NOTE: this causes DB orphans when LD not saved. } - + + // transform to dto + VideoRecorderDTO videoRecorderDT0 = new VideoRecorderDTO(videoRecorder); + + // get recordings + List recordings = videoRecorderService.getRecordingsByToolContentId(toolContentID); + + // setup first recording + VideoRecorderRecordingDTO firstRecording = null; + + // if there are recordings + if(!recordings.isEmpty()){ + // fetch the first one + firstRecording = recordings.get(0); + } + + // add it to the request + request.setAttribute("videoRecorderRecordingDTO", firstRecording); + if (mode != null && mode.isTeacher()) { // Set the defineLater flag so that learners cannot use content // while we @@ -133,9 +170,18 @@ toolContentID); authForm.setSessionMapID(map.getSessionID()); - // add the sessionMap to HTTPSession. + // add the sessionMap to HTTPSession request.getSession().setAttribute(map.getSessionID(), map); request.setAttribute(VideoRecorderConstants.ATTR_SESSION_MAP, map); + + // add the toolContentId + request.setAttribute("toolContentId", toolContentID); + + // add the videoRecorderDTO + request.setAttribute("videoRecorderDTO", videoRecorderDT0); + + // set language xml + request.setAttribute("languageXML", videoRecorderService.getLanguageXMLForFCK()); return mapping.findForward("success"); } @@ -384,9 +430,10 @@ videoRecorder.setAllowUseVoice(authForm.isAllowUseVoice()); videoRecorder.setAllowUseCamera(authForm.isAllowUseCamera()); videoRecorder.setAllowLearnerVideoVisibility(authForm.isAllowLearnerVideoVisibility()); - videoRecorder.setAllowLearnerVideoExport(authForm.isAllowLearnerVideoExport()); videoRecorder.setAllowComments(authForm.isAllowComments()); videoRecorder.setAllowRatings(authForm.isAllowComments()); + videoRecorder.setExportAll(authForm.isExportAll()); + videoRecorder.setExportOffline(authForm.isExportOffline()); //} } @@ -406,9 +453,10 @@ authForm.setAllowUseVoice(videoRecorder.isAllowUseVoice()); authForm.setAllowUseCamera(videoRecorder.isAllowUseCamera()); authForm.setAllowLearnerVideoVisibility(videoRecorder.isAllowLearnerVideoVisibility()); - authForm.setAllowLearnerVideoExport(videoRecorder.isAllowLearnerVideoExport()); authForm.setAllowComments(videoRecorder.isAllowComments()); authForm.setAllowRatings(videoRecorder.isAllowComments()); + authForm.setExportAll(videoRecorder.isExportAll()); + authForm.setExportOffline(videoRecorder.isExportOffline()); } /** Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/LearningAction.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/LearningAction.java (.../LearningAction.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/LearningAction.java (.../LearningAction.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -79,7 +79,7 @@ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - + LearningForm learningForm = (LearningForm) form; // 'toolSessionID' and 'mode' paramters are expected to be present. @@ -107,6 +107,8 @@ VideoRecorder videoRecorder = videoRecorderSession.getVideoRecorder(); + Long toolContentID = videoRecorder.getToolContentId(); + // check defineLater if (videoRecorder.isDefineLater()) { return mapping.findForward("defineLater"); @@ -122,12 +124,16 @@ VideoRecorderDTO videoRecorderDT0 = new VideoRecorderDTO(videoRecorder); + VideoRecorderUserDTO videoRecorderUserDTO = new VideoRecorderUserDTO(videoRecorderUser); + // set mode, toolSessionID and userId request.setAttribute("mode", mode.toString()); + request.setAttribute("videoRecorderUserDTO", videoRecorderUserDTO); request.setAttribute("userId", videoRecorderUser.getUid()); request.setAttribute("videoRecorderDTO", videoRecorderDT0); learningForm.setToolSessionID(toolSessionID); request.setAttribute("toolSessionId", toolSessionID); + request.setAttribute("toolContentId", toolContentID); // set language xml request.setAttribute("languageXML", videoRecorderService.getLanguageXML()); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/MonitoringAction.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -123,6 +123,7 @@ request.setAttribute("mode", "author"); request.setAttribute("userId", videoRecorderUser.getUid()); request.setAttribute("toolSessionId", toolSessionID); + request.setAttribute("toolContentId", toolContentID); request.setAttribute("videoRecorderDTO", videoRecorderDT0); request.setAttribute("contentFolderID", contentFolderID); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/forms/AuthoringForm.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -57,15 +57,17 @@ boolean allowUseVoice; boolean allowUseCamera; - - boolean allowLearnerVideoExport; - + boolean allowLearnerVideoVisibility; boolean allowComments; boolean allowRatings; + boolean exportAll; + + boolean exportOffline; + FormFile onlineFile; FormFile offlineFile; @@ -207,15 +209,7 @@ public void setAllowLearnerVideoVisibility(boolean allowLearnerVideoVisibility) { this.allowLearnerVideoVisibility = allowLearnerVideoVisibility; } - - public boolean isAllowLearnerVideoExport() { - return allowLearnerVideoExport; - } - - public void setAllowLearnerVideoExport(boolean allowLearnerVideoExport) { - this.allowLearnerVideoExport = allowLearnerVideoExport; - } - + public boolean isAllowComments() { return allowComments; } @@ -231,4 +225,20 @@ public void setAllowRatings(boolean allowRatings) { this.allowRatings = allowRatings; } + + public boolean isExportAll() { + return exportAll; + } + + public void setExportAll(boolean exportAll) { + this.exportAll = exportAll; + } + + public boolean isExportOffline() { + return exportOffline; + } + + public void setExportOffline(boolean exportOffline) { + this.exportOffline = exportOffline; + } } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/ExportServlet.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/ExportServlet.java (.../ExportServlet.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/ExportServlet.java (.../ExportServlet.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -33,6 +33,8 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -48,22 +50,20 @@ import org.lamsfoundation.lams.learning.export.web.action.MultipleDirFileBundler; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.ToolAccessMode; -import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderDTO; import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderRecordingDTO; -import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderSessionDTO; import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderUserDTO; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorder; -import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderRecording; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderSession; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderUser; import org.lamsfoundation.lams.tool.videoRecorder.service.IVideoRecorderService; import org.lamsfoundation.lams.tool.videoRecorder.service.VideoRecorderServiceProxy; import org.lamsfoundation.lams.tool.videoRecorder.util.VideoRecorderException; +import org.lamsfoundation.lams.tool.videoRecorder.util.VideoRecorderRecordingComparator; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; -import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.ExternalServerUtil; import org.lamsfoundation.lams.web.servlet.AbstractExportPortfolioServlet; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -77,7 +77,8 @@ private final String FILENAME = "videoRecorder_main.html"; public static final String VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lavidr10/includes/flash/"; public static final String VIDEORECORDER_RECORDINGS_HTTP_FOLDER_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lavidr10/recordings/"; - public static final String VIDEORECORDER_RECORDINGS_FOLDER_URL = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + "/" + "lams-tool-lavidr10.war" + "/" + "recordings" + "/"; + public static final String VIDEORECORDER_RECORDINGS_FOLDER_DEST = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + "/" + "lams-tool-lavidr10.war" + "/" + "recordings" + "/"; + public static final String VIDEORECORDER_RECORDINGS_FOLDER_SRC = Configuration.get(ConfigurationKeys.RED5_RECORDINGS_URL); private IVideoRecorderService videoRecorderService; @@ -88,7 +89,9 @@ videoRecorderService = VideoRecorderServiceProxy .getVideoRecorderService(getServletContext()); } - + + toolSessionID = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID)); + try { if (StringUtils.equals(mode, ToolAccessMode.LEARNER.toString())) { request.getSession().setAttribute(AttributeNames.ATTR_MODE, @@ -147,83 +150,82 @@ logger.error(error); throw new VideoRecorderException(error); } - + + // get the session from the toolSessionId VideoRecorderSession videoRecorderSession = videoRecorderService .getSessionBySessionId(toolSessionID); + // get the video recorder from the session VideoRecorder videoRecorder = videoRecorderSession.getVideoRecorder(); + + // get toolContentId from video recorder + toolContentID = videoRecorder.getToolContentId(); + + /* + // get videorecorder from toolContentId + VideoRecorder videoRecorder = videoRecorderService.getVideoRecorderByContentId(toolContentID); + */ + + // get export options + boolean exportAll = videoRecorder.isExportAll(); + boolean exportOffline = videoRecorder.isExportOffline(); + + // transform to dto VideoRecorderDTO videoRecorderDTO = new VideoRecorderDTO(videoRecorder); + // get lams user from session UserDTO lamsUserDTO = (UserDTO) SessionManager.getSession() .getAttribute(AttributeNames.USER); + // get video recorder user from userId and sessionId VideoRecorderUser videoRecorderUser = videoRecorderService .getUserByUserIdAndSessionId(new Long(lamsUserDTO.getUserID()), toolSessionID); + // transform to dto VideoRecorderUserDTO videoRecorderUserDTO = new VideoRecorderUserDTO(videoRecorderUser); - - List videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionIdAndUserId(toolSessionID, videoRecorderUser.getUid()); + // get the video recording dtos + List videoRecorderRecordingDTOs; + + // get video recording dtos + if(exportAll) + { + videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionId(toolSessionID, toolContentID); + }else{ + videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionIdAndUserId(toolSessionID, videoRecorderUser.getUid(), toolContentID); + } + + // sort the list of recording dtos in order to create the xml correctly + Comparator comp = new VideoRecorderRecordingComparator("author", "ascending"); + Collections.sort(videoRecorderRecordingDTOs, comp); + + // get the nb of recordings int nbRecordings = videoRecorderRecordingDTOs.size(); + // set dtos to request (used in export jsp) request.getSession().setAttribute("videoRecorderDTO", videoRecorderDTO); request.getSession().setAttribute("videoRecorderUserDTO", videoRecorderUserDTO); request.getSession().setAttribute("videoRecorderRecordingDTOs", videoRecorderRecordingDTOs); - // set language xml + // set language xml to request request.getSession().setAttribute("languageXML", videoRecorderService.getLanguageXMLForFCK()); - // set red5 server url + // set red5 server url to request String red5ServerUrl = Configuration.get(ConfigurationKeys.RED5_SERVER_URL); request.getSession().setAttribute("red5ServerUrl", red5ServerUrl); - // set LAMS server url + // set LAMS server url to request String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); request.getSession().setAttribute("serverUrl", serverUrl); - ArrayList[] fileArray = new ArrayList[2]; - fileArray[0] = new ArrayList(); - fileArray[1] = new ArrayList(); - - fileArray[0].add("VideoRecorderFCKEditor.swf"); - fileArray[0].add("playerProductInstall.swf"); - fileArray[0].add("AC_OETags.js"); - - try { - Iterator iter = videoRecorderRecordingDTOs.iterator(); - while(iter.hasNext()){ - VideoRecorderRecordingDTO vr = (VideoRecorderRecordingDTO) iter.next(); - InputStream is = getResponseInputStreamFromExternalServer("http://172.20.100.22:8080/streams/" + vr.getFilename(), new HashMap()); - - File imageFile = new File(VIDEORECORDER_RECORDINGS_FOLDER_URL + vr.getFilename()); - - FileOutputStream out = new FileOutputStream(imageFile); - - byte[] buf = new byte[10 * 1024]; - int len; - while ((len = is.read(buf)) > 0) { - out.write(buf, 0, len); - } - - out.close(); - - fileArray[1].add(vr.getFilename()); - } - } catch (Exception e) { - logger.error("Could not find files on Red5 server", e); + // if doing export offline, copy recordings files + if(exportOffline){ + bundleFilesForOffline(request, response, directoryName, cookies, videoRecorderRecordingDTOs); } - - // bundling files - try { - String[] urls = new String[2]; - urls[0] = VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL; - urls[1] = VIDEORECORDER_RECORDINGS_HTTP_FOLDER_URL; - - MultipleDirFileBundler fileBundler = new MultipleDirFileBundler(); - fileBundler.bundle(request, cookies, directoryName, urls, fileArray); - } catch (Exception e) { - logger.error("Could not bundle files", e); + // otherwise, just copy files (like js) + else{ + bundleFilesForOnline(request, response, directoryName, cookies, videoRecorderRecordingDTOs); } } @@ -234,75 +236,113 @@ logger.debug("doExportTeacher: toolContentID:" + toolContentID); // check if toolContentID available - if (toolSessionID == null) { - String error = "Tool Session ID is missing. Unable to continue"; + if (toolContentID == null) { + String error = "Tool Content ID is missing. Unable to continue"; logger.error(error); throw new VideoRecorderException(error); } - - VideoRecorderSession videoRecorderSession = videoRecorderService - .getSessionBySessionId(toolSessionID); - - VideoRecorder videoRecorder = videoRecorderSession.getVideoRecorder(); + + // get video recorder from tool content id + VideoRecorder videoRecorder = videoRecorderService.getVideoRecorderByContentId(toolContentID); + + // make into dto VideoRecorderDTO videoRecorderDTO = new VideoRecorderDTO(videoRecorder); + // get export options + boolean exportAll = videoRecorder.isExportAll(); + boolean exportOffline = videoRecorder.isExportOffline(); + + // get lams user from session UserDTO lamsUserDTO = (UserDTO) SessionManager.getSession() .getAttribute(AttributeNames.USER); - - VideoRecorderUser videoRecorderUser = videoRecorderService - .getUserByUserIdAndSessionId(new Long(lamsUserDTO.getUserID()), - toolSessionID); - VideoRecorderUserDTO videoRecorderUserDTO = new VideoRecorderUserDTO(videoRecorderUser); - - List videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionId(toolSessionID); + // get video recording dtos from just tool content id + List videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionId(new Long(0), toolContentID); + // get nb of recordings int nbRecordings = videoRecorderRecordingDTOs.size(); + // add dtos to request request.getSession().setAttribute("videoRecorderDTO", videoRecorderDTO); - request.getSession().setAttribute("videoRecorderUserDTO", videoRecorderUserDTO); request.getSession().setAttribute("videoRecorderRecordingDTOs", videoRecorderRecordingDTOs); - // set language xml + // set language xml to request request.getSession().setAttribute("languageXML", videoRecorderService.getLanguageXMLForFCK()); - // set red5 server url + // set red5 server url to request String red5ServerUrl = Configuration.get(ConfigurationKeys.RED5_SERVER_URL); request.getSession().setAttribute("red5ServerUrl", red5ServerUrl); - // set LAMS server url + // set LAMS server url to request String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); request.getSession().setAttribute("serverUrl", serverUrl); + // if doing export offline, copy recordings files + if(exportOffline){ + bundleFilesForOffline(request, response, directoryName, cookies, videoRecorderRecordingDTOs); + } + // otherwise, just copy files (like js) + else{ + bundleFilesForOnline(request, response, directoryName, cookies, videoRecorderRecordingDTOs); + } + } + + private void bundleFilesForOnline(HttpServletRequest request, + HttpServletResponse response, String directoryName, Cookie[] cookies, + List videoRecorderRecordingDTOs){ + // prepare the file array + // index 0 is for the files from VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL + ArrayList[] fileArray = new ArrayList[1]; + fileArray[0] = new ArrayList(); + + // add the files need from VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL + fileArray[0].add("VideoRecorderFCKEditor.swf"); + fileArray[0].add("playerProductInstall.swf"); + fileArray[0].add("AC_OETags.js"); + + // bundling files + try { + String[] urls = new String[1]; + urls[0] = VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL; + + MultipleDirFileBundler fileBundler = new MultipleDirFileBundler(); + fileBundler.bundle(request, cookies, directoryName, urls, fileArray); + } catch (Exception e) { + logger.error("Could not bundle files", e); + } + } + + private void bundleFilesForOffline(HttpServletRequest request, + HttpServletResponse response, String directoryName, Cookie[] cookies, + List videoRecorderRecordingDTOs){ + // prepare the file array + // index 0 is for the files from VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL + // index 1 is for the files from VIDEORECORDER_RECORDINGS_HTTP_FOLDER_URL ArrayList[] fileArray = new ArrayList[2]; + fileArray[0] = new ArrayList(); + fileArray[1] = new ArrayList(); + // add the files need from VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL fileArray[0].add("VideoRecorderFCKEditor.swf"); fileArray[0].add("playerProductInstall.swf"); fileArray[0].add("AC_OETags.js"); + // add the files from VIDEORECORDER_RECORDINGS_HTTP_FOLDER_URL try { - int counter = 3; - int listSize = videoRecorderRecordingDTOs.size(); + // for each video recording Iterator iter = videoRecorderRecordingDTOs.iterator(); while(iter.hasNext()){ + // get the video recording VideoRecorderRecordingDTO vr = (VideoRecorderRecordingDTO) iter.next(); - InputStream is = getResponseInputStreamFromExternalServer("http://172.20.100.22:8080/streams/" + vr.getFilename(), new HashMap()); - - File imageFile = new File(VIDEORECORDER_RECORDINGS_FOLDER_URL + vr.getFilename()); + + // get the stream from the external server + InputStream is = ExternalServerUtil.getResponseInputStreamFromExternalServer(VIDEORECORDER_RECORDINGS_FOLDER_SRC + vr.getFilename(), new HashMap()); - FileOutputStream out = new FileOutputStream(imageFile); - - byte[] buf = new byte[10 * 1024]; - int len; - while ((len = is.read(buf)) > 0) { - out.write(buf, 0, len); - } + // write the flv file locally + File file = ExternalServerUtil.writeFile(is, VIDEORECORDER_RECORDINGS_FOLDER_DEST + vr.getFilename()); - out.close(); - + // add the filename to the list fileArray[1].add(vr.getFilename()); - - counter++; } } catch (Exception e) { logger.error("Could not find files on Red5 server", e); @@ -312,47 +352,12 @@ try { String[] urls = new String[2]; urls[0] = VIDEORECORDER_INCLUDES_HTTP_FOLDER_URL; - urls[1] = VIDEORECORDER_RECORDINGS_FOLDER_URL; + urls[1] = VIDEORECORDER_RECORDINGS_HTTP_FOLDER_URL; MultipleDirFileBundler fileBundler = new MultipleDirFileBundler(); fileBundler.bundle(request, cookies, directoryName, urls, fileArray); } catch (Exception e) { logger.error("Could not bundle files", e); } } - - public static InputStream getResponseInputStreamFromExternalServer(String urlStr, HashMap params) - throws ToolException, IOException { - if (!urlStr.endsWith("?")) - urlStr += "?"; - - for (Entry entry : params.entrySet()) { - urlStr += "&" + entry.getKey() + "=" + entry.getValue(); - } - - logger.debug("Making request to external servlet: " + urlStr); - - URL url = new URL(urlStr); - URLConnection conn = url.openConnection(); - if (!(conn instanceof HttpURLConnection)) { - logger.error("Fail to connect to external server though url: " + urlStr); - throw new ToolException("Fail to connect to external server though url: " + urlStr); - } - - HttpURLConnection httpConn = (HttpURLConnection) conn; - if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { - logger.error("Fail to fetch data from external server, response code: " + httpConn.getResponseCode() - + " Url: " + urlStr); - throw new ToolException("Fail to fetch data from external server, response code: " - + httpConn.getResponseCode() + " Url: " + urlStr); - } - - InputStream is = url.openConnection().getInputStream(); - if (is == null) { - logger.error("Fail to fetch data from external server, return InputStream null: " + urlStr); - throw new ToolException("Fail to fetch data from external server, return inputStream null: " + urlStr); - } - - return is; - } } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/VideoRecorderAction.java =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/VideoRecorderAction.java (.../VideoRecorderAction.java) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/web/servlets/VideoRecorderAction.java (.../VideoRecorderAction.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -29,10 +29,12 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.PrintWriter; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Set; @@ -46,12 +48,14 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorder; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderComment; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderRating; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderRecording; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderSession; import org.lamsfoundation.lams.tool.videoRecorder.model.VideoRecorderUser; import org.lamsfoundation.lams.tool.videoRecorder.service.IVideoRecorderService; +import org.lamsfoundation.lams.tool.videoRecorder.service.VideoRecorderService; import org.lamsfoundation.lams.tool.videoRecorder.service.VideoRecorderServiceProxy; import org.lamsfoundation.lams.tool.videoRecorder.util.VideoRecorderRecordingComparator; import org.lamsfoundation.lams.tool.videoRecorder.dto.VideoRecorderCommentDTO; @@ -60,6 +64,8 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.ExternalServerUtil; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; @@ -88,6 +94,7 @@ //--------------------------------------------------------------------- private static final String TOOL_SESSION_ID = "toolSessionId"; + private static final String TOOL_CONTENT_ID = "toolContentId"; private static final String USER_ID = "userId"; private static final String TITLE = "title"; private static final String DESCRIPTION = "description"; @@ -104,7 +111,12 @@ private static final String GET_ALL = "getAll"; private static final String OK_MSG = "ok"; private static final String ERROR_MSG = "error"; - + private static final String SAVE_TO_LAMS = "saveToLams"; + private static final String SAVE_TO_LAMS_DEST = "saveToLamsDest"; + + private String VIDEORECORDER_RECORDINGS_FOLDER_DEST = ""; + private static final String VIDEORECORDER_RECORDINGS_FOLDER_SRC = Configuration.get(ConfigurationKeys.RED5_RECORDINGS_URL); + private Integer getUserId(HttpServletRequest request) { HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); @@ -124,6 +136,7 @@ // get paramaters from POST Long toolSessionId = WebUtil.readLongParam(request, TOOL_SESSION_ID); + Long toolContentId = WebUtil.readLongParam(request, TOOL_CONTENT_ID); Long userId = WebUtil.readLongParam(request, USER_ID); String sortBy = WebUtil.readStrParam(request, SORT_BY); String sortDirection = WebUtil.readStrParam(request, SORT_DIR); @@ -138,17 +151,17 @@ // if no user is specified if(getAll){ // get all recordings - videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionId(toolSessionId); + videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionId(toolSessionId, toolContentId); // otherwise } else{ // get all recordings from user specified - videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionIdAndUserId(toolSessionId, userId); + videoRecorderRecordingDTOs = videoRecorderService.getRecordingsByToolSessionIdAndUserId(toolSessionId, userId, toolContentId); } // sort the list of recording DTOs in order to create the xml correctly Comparator comp = new VideoRecorderRecordingComparator(sortBy, sortDirection); Collections.sort(videoRecorderRecordingDTOs, comp); - + String xmlOutput = buildVideoRecordingsXML(videoRecorderRecordingDTOs, userId); writeAJAXResponse(response, xmlOutput); return null; @@ -160,51 +173,98 @@ try{ // get paramaters from POST - Long toolSessionId = WebUtil.readLongParam(request, TOOL_SESSION_ID); - Long recordingId = WebUtil.readLongParam(request, RECORDING_ID); - Long userId = WebUtil.readLongParam(request, USER_ID); - String title = WebUtil.readStrParam(request, TITLE); - String description = WebUtil.readStrParam(request, DESCRIPTION); - String filename = WebUtil.readStrParam(request, FILENAME); - Boolean isJustSound = WebUtil.readBooleanParam(request, IS_JUST_SOUND); - int rating = WebUtil.readIntParam(request, RATING); + Long toolSessionId = WebUtil.readLongParam(request, TOOL_SESSION_ID, true); + Long toolContentId = WebUtil.readLongParam(request, TOOL_CONTENT_ID, true); + Long recordingId = WebUtil.readLongParam(request, RECORDING_ID, true); + Long userId = WebUtil.readLongParam(request, USER_ID, true); + String title = WebUtil.readStrParam(request, TITLE, false); + String description = WebUtil.readStrParam(request, DESCRIPTION, false); + String filename = WebUtil.readStrParam(request, FILENAME, true); + Boolean isJustSound = WebUtil.readBooleanParam(request, IS_JUST_SOUND, false); + int rating = WebUtil.readIntParam(request, RATING, false); + Boolean saveToLams = WebUtil.readBooleanParam(request, SAVE_TO_LAMS, false); // get service IVideoRecorderService videoRecorderService = VideoRecorderServiceProxy.getVideoRecorderService(getServlet().getServletContext()); - // get user - VideoRecorderUser user = videoRecorderService.getUserByUID(userId); + // initialize session, user and recording + VideoRecorderSession session = null; + VideoRecorderUser user = null; + VideoRecorderRecording videoRecording = null; + VideoRecorder videoRecorder = null; - // get session - VideoRecorderSession session = videoRecorderService.getSessionBySessionId(toolSessionId); - - - // create videoRecording - VideoRecorderRecording videoRecording; - - // if no recordingId is sent, create a new recording - if(recordingId == -1){ - videoRecording = new VideoRecorderRecording(); - videoRecording.setCreateBy(user); - videoRecording.setVideoRecorderSession(session); - videoRecording.setFilename(filename); - videoRecording.setRating((float)rating); - videoRecording.setCreateDate(new Date()); - videoRecording.setIsJustSound(isJustSound); - videoRecording.setRatings(null); - videoRecording.setComments(null); + // if saving from author + if(toolContentId != -1){ + // get video recorder + videoRecorder = videoRecorderService.getVideoRecorderByContentId(toolContentId); + + if(videoRecorder != null){ + // get recording + videoRecording = videoRecorderService.getFirstRecordingByToolContentId(toolContentId); + + // if no recording exists create a new one + if(videoRecording == null){ + videoRecording = new VideoRecorderRecording(); + + videoRecording.setFilename(filename); + videoRecording.setRating((float)rating); + videoRecording.setCreateDate(new Date()); + videoRecording.setIsJustSound(isJustSound); + videoRecording.setRatings(null); + videoRecording.setComments(null); + videoRecording.setCreateBy(null); + videoRecording.setToolContentId(toolContentId); + } + } + } - // otherwise get the recording from the DAO - else{ - videoRecording = videoRecorderService.getRecordingById(recordingId); - } + // if saving from learner + else if(toolSessionId != -1){ + // get session + session = videoRecorderService.getSessionBySessionId(toolSessionId); + + // get user + user = videoRecorderService.getUserByUID(userId); + + // if no recording id is specified + if(recordingId == -1){ + // create a new recording + videoRecording = new VideoRecorderRecording(); + videoRecording.setFilename(filename); + videoRecording.setRating((float)rating); + videoRecording.setCreateDate(new Date()); + videoRecording.setIsJustSound(isJustSound); + videoRecording.setRatings(null); + videoRecording.setComments(null); + videoRecording.setCreateBy(user); + videoRecording.setVideoRecorderSession(session); + } + // otherwise get the recording from the DAO + else{ + videoRecording = videoRecorderService.getRecordingById(recordingId); + } + } + // add the last common information videoRecording.setUpdateDate(new Date()); videoRecording.setTitle(title); videoRecording.setDescription(description); + videoRecording.setFilename(filename); + // save videoRecorderService.saveOrUpdateVideoRecorderRecording(videoRecording); + // if we want the recently + if(saveToLams){ + // get folder dest + VIDEORECORDER_RECORDINGS_FOLDER_DEST = WebUtil.readStrParam(request, SAVE_TO_LAMS_DEST); + // get the stream from the external server + InputStream is = ExternalServerUtil.getResponseInputStreamFromExternalServer(VIDEORECORDER_RECORDINGS_FOLDER_SRC + filename, new HashMap()); + + // write the flv file locally + File file = ExternalServerUtil.writeFile(is, VIDEORECORDER_RECORDINGS_FOLDER_DEST + filename); + } + writeAJAXResponse(response, OK_MSG); }catch(Exception e){ @@ -369,95 +429,43 @@ return null; } - /* - public ActionForward savePreviewImage(ActionMapping mapping, + public ActionForward getLanguageXML(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + // get service + try{ + IVideoRecorderService videoRecorderService = VideoRecorderServiceProxy.getVideoRecorderService(getServlet().getServletContext()); + writeAJAXResponse(response, videoRecorderService.getLanguageXML()); + }catch(Exception e){ + writeAJAXResponse(response, ERROR_MSG + e.getMessage()); + } - // Use functionality in org.red5.io.amf3.ByteArray to get parameters of the ByteArray - String rawImageString = request.getParameter(RAW_IMAGE); - ByteArray rawImage; - int BCurrentlyAvailable = rawImage.bytesAvailable(); - int BWholeSize = rawImage.length(); // Put the Red5 ByteArray into a standard Java array of bytes - byte c[] = new byte[BWholeSize]; - rawImage.readBytes(c); + return null; - // Transform the byte array into a java buffered image - ByteArrayInputStream db = new ByteArrayInputStream(c); - - if(BCurrentlyAvailable > 0) { - System.out.println("The byte Array currently has " + BCurrentlyAvailable + " bytes. The Buffer has " + db.available()); - try{ - BufferedImage JavaImage = ImageIO.read(db); - // Now lets try and write the buffered image out to a file - if(JavaImage != null) { // If you sent a jpeg to the server, just change PNG to JPEG and Red5ScreenShot.png to .jpeg - ImageIO.write(JavaImage, "PNG", new File("Red5ScreenShot.png")); - } - } - catch(IOException e){ - System.out.println("Save_ScreenShot: Writing of screenshot failed " + e); System.out.println("IO Error " + e); - } - } - - return null; - } - */ + } - /* for hierarchal data - private String buildVideoRecordingsXML(List videoRecorderRecordingDTOs, Long userId){ - //start the output - String xmlOutput = ""; - Long lastUserId = Long.valueOf("-1"); - Long currentUserId = Long.valueOf("-1"); - - // for every user, print out its recordings - for(VideoRecorderRecordingDTO videoRecorderRecordingDTO: videoRecorderRecordingDTOs){ - VideoRecorderUser user = videoRecorderRecordingDTO.getCreateBy(); - Set comments = videoRecorderRecordingDTO.getComments(); - Set ratings = videoRecorderRecordingDTO.getRatings(); - - currentUserId = user.getUserId(); - if(currentUserId != lastUserId){ - if(lastUserId != -1){ - xmlOutput += ""; - } - xmlOutput += ""; - xmlOutput += "" + user.getFirstName() + " " + user.getLastName() + ""; - } - - xmlOutput += ""; - xmlOutput += "" + videoRecorderRecordingDTO.getUid() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getTitle() + ""; - xmlOutput += "" + user.getUid() + ""; - xmlOutput += "" + user.getUserId() + ""; - xmlOutput += "" + user.getFirstName() + " " + user.getLoginName() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getCreateDate().toLocaleString() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getUpdateDate().toLocaleString() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getDescription() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getFilename() + ""; - xmlOutput += "" + videoRecorderRecordingDTO.getRating() + ""; - xmlOutput += "" + buildUserRating(ratings, userId) + ""; - - // for every recording, print out its comments - xmlOutput += buildVideoCommentsXML(comments); - xmlOutput += ""; - - lastUserId = currentUserId; + public ActionForward getLanguageXMLForFCK(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + // get service + try{ + IVideoRecorderService videoRecorderService = VideoRecorderServiceProxy.getVideoRecorderService(getServlet().getServletContext()); + writeAJAXResponse(response, videoRecorderService.getLanguageXMLForFCK()); + }catch(Exception e){ + writeAJAXResponse(response, ""); } - if(lastUserId == currentUserId && (lastUserId != -1 || currentUserId != -1)){ - xmlOutput += ""; - } - - xmlOutput += ""; - return xmlOutput; + return null; + } - */ private String buildVideoRecordingsXML(List videoRecorderRecordingDTOs, Long userId){ //start the output String xmlOutput = ""; + // get service + IVideoRecorderService videoRecorderService = VideoRecorderServiceProxy.getVideoRecorderService(getServlet().getServletContext()); + // for all recordings, print out their information for(VideoRecorderRecordingDTO videoRecorderRecordingDTO: videoRecorderRecordingDTOs){ VideoRecorderUser user = videoRecorderRecordingDTO.getCreateBy(); @@ -467,9 +475,18 @@ xmlOutput += ""; xmlOutput += "" + videoRecorderRecordingDTO.getUid() + ""; xmlOutput += "" + videoRecorderRecordingDTO.getTitle() + ""; - xmlOutput += "" + user.getUid() + ""; - xmlOutput += "" + user.getUserId() + ""; - xmlOutput += "" + user.getFirstName() + " " + user.getLoginName() + ""; + + if(user != null){ + xmlOutput += "false"; + xmlOutput += "" + user.getUid() + ""; + xmlOutput += "" + user.getUserId() + ""; + xmlOutput += "" + user.getFirstName() + " " + user.getLoginName() + ""; + } + else if(user == null && videoRecorderRecordingDTO.getToolContentId() != -1){ + xmlOutput += "true"; + xmlOutput += "" + videoRecorderService.getMessage("videorecorder.instructor") + ""; + } + xmlOutput += "" + videoRecorderRecordingDTO.getCreateDate().toLocaleString() + ""; xmlOutput += "" + videoRecorderRecordingDTO.getUpdateDate().toLocaleString() + ""; xmlOutput += "" + videoRecorderRecordingDTO.getDescription() + ""; Index: lams_tool_videorecorder/web/includes/flash/VideoRecorder.html =================================================================== diff -u -r049932651d9d1c08ed1681df0a044d7f519a4215 -r42aa5319fbd33938828764c43dd0ab1ca80e2416 --- lams_tool_videorecorder/web/includes/flash/VideoRecorder.html (.../VideoRecorder.html) (revision 049932651d9d1c08ed1681df0a044d7f519a4215) +++ lams_tool_videorecorder/web/includes/flash/VideoRecorder.html (.../VideoRecorder.html) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) @@ -63,8 +63,8 @@ AC_FL_RunContent( "src", "playerProductInstall", "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", - "width", "682", - "height", "652", + "width", "100%", + "height", "100%", "align", "middle", "id", "VideoRecorder", "quality", "high", @@ -79,8 +79,8 @@ // embed the Flash Content SWF when all tests are passed AC_FL_RunContent( "src", "VideoRecorder", - "width", "682", - "height", "652", + "width", "100%", + "height", "100%", "align", "middle", "id", "VideoRecorder", "quality", "high", @@ -100,14 +100,14 @@