From 5df4bef9037596ad19097dbdb8571abd249f248d Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Thu, 7 Jun 2018 12:13:00 -0700 Subject: [PATCH] - toggle presentation downloads --- ...tionConversionCompletedSysPubMsgHdlr.scala | 26 ++++------ .../presentationpod/PresentationSender.scala | 47 +++++++++++++++++++ ...etPresentationDownloadablePubMsgHdlr.scala | 20 ++------ .../core2/FromAkkaAppsMsgSenderActor.scala | 2 - .../common2/msgs/PresentationPodsMsgs.scala | 2 +- .../org/bigbluebutton/api/MeetingService.java | 11 +++++ .../bigbluebutton/api/RecordingService.java | 40 ++++++++++++++++ .../main/java/org/bigbluebutton/api/Util.java | 11 +++-- .../MakePresentationDownloadableMsg.java | 15 ++++++ .../api2/bus/ReceivedJsonMsgHdlrActor.scala | 2 + .../api2/meeting/OldMeetingMsgHdlrActor.scala | 12 ++++- .../modules/present/business/PresentProxy.as | 5 +- .../modules/present/events/DownloadEvent.as | 3 +- .../views/DownloadPresentationRenderer.mxml | 3 +- .../grails-app/conf/UrlMappings.groovy | 2 +- .../grails-app/conf/spring/resources.xml | 1 + .../controllers/PresentationController.groovy | 32 +++++-------- .../web/services/PresentationService.groovy | 9 ---- 18 files changed, 168 insertions(+), 75 deletions(-) create mode 100755 akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationSender.scala mode change 100644 => 100755 akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresentationDownloadablePubMsgHdlr.scala create mode 100755 bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/MakePresentationDownloadableMsg.java diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationConversionCompletedSysPubMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationConversionCompletedSysPubMsgHdlr.scala index 2ac6696e24..6f9cdfe22a 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationConversionCompletedSysPubMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationConversionCompletedSysPubMsgHdlr.scala @@ -16,20 +16,7 @@ trait PresentationConversionCompletedSysPubMsgHdlr { liveMeeting: LiveMeeting, bus: MessageBus ): MeetingState2x = { - def broadcastPresentationConversionCompletedEvtMsg(podId: String, userId: String, messageKey: String, - code: String, presentation: PresentationVO): Unit = { - val routing = Routing.addMsgToClientRouting( - MessageTypes.BROADCAST_TO_MEETING, - liveMeeting.props.meetingProp.intId, userId - ) - val envelope = BbbCoreEnvelope(PresentationConversionCompletedEvtMsg.NAME, routing) - val header = BbbClientMsgHeader(PresentationConversionCompletedEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId) - - val body = PresentationConversionCompletedEvtMsgBody(podId, messageKey, code, presentation) - val event = PresentationConversionCompletedEvtMsg(header, body) - val msgEvent = BbbCommonEnvCoreMsg(envelope, event) - bus.outGW.send(msgEvent) - } + val meetingId = liveMeeting.props.meetingProp.intId val pages = new collection.mutable.HashMap[String, PageVO] @@ -39,15 +26,20 @@ trait PresentationConversionCompletedSysPubMsgHdlr { pages += page.id -> page } - val pres = new PresentationInPod(msg.body.presentation.id, msg.body.presentation.name, msg.body.presentation.current, - pages.toMap, msg.body.presentation.downloadable) + val downloadable = msg.body.presentation.downloadable + val presentationId = msg.body.presentation.id + val pres = new PresentationInPod(presentationId, msg.body.presentation.name, msg.body.presentation.current, + pages.toMap, downloadable) val presVO = PresentationPodsApp.translatePresentationToPresentationVO(pres) val podId = msg.body.podId val newState = for { pod <- PresentationPodsApp.getPresentationPod(state, podId) } yield { - broadcastPresentationConversionCompletedEvtMsg(pod.id, msg.header.userId, msg.body.messageKey, msg.body.code, presVO) + PresentationSender.broadcastPresentationConversionCompletedEvtMsg(bus, meetingId, + pod.id, msg.header.userId, msg.body.messageKey, msg.body.code, presVO) + PresentationSender.broadcastSetPresentationDownloadableEvtMsg(bus, meetingId, pod.id, + msg.header.userId, presentationId, downloadable, pres.name) var pods = state.presentationPodManager.addPod(pod) pods = pods.addPresentationToPod(pod.id, pres) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationSender.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationSender.scala new file mode 100755 index 0000000000..3c7d111df6 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationSender.scala @@ -0,0 +1,47 @@ +package org.bigbluebutton.core.apps.presentationpod + +import org.bigbluebutton.common2.domain.PresentationVO +import org.bigbluebutton.common2.msgs._ +import org.bigbluebutton.core.bus.MessageBus + +object PresentationSender { + def broadcastSetPresentationDownloadableEvtMsg( + bus: MessageBus, + meetingId: String, + podId: String, userId: String, + presentationId: String, + downloadable: Boolean, + presFilename: String + ): Unit = { + val routing = Routing.addMsgToClientRouting( + MessageTypes.BROADCAST_TO_MEETING, + meetingId, userId + ) + val envelope = BbbCoreEnvelope(SetPresentationDownloadableEvtMsg.NAME, routing) + val header = BbbClientMsgHeader(SetPresentationDownloadableEvtMsg.NAME, meetingId, userId) + + val body = SetPresentationDownloadableEvtMsgBody(podId, presentationId, downloadable, presFilename) + val event = SetPresentationDownloadableEvtMsg(header, body) + val msgEvent = BbbCommonEnvCoreMsg(envelope, event) + bus.outGW.send(msgEvent) + } + + def broadcastPresentationConversionCompletedEvtMsg( + bus: MessageBus, + meetingId: String, + podId: String, userId: String, messageKey: String, + code: String, presentation: PresentationVO + ): Unit = { + val routing = Routing.addMsgToClientRouting( + MessageTypes.BROADCAST_TO_MEETING, + meetingId, userId + ) + val envelope = BbbCoreEnvelope(PresentationConversionCompletedEvtMsg.NAME, routing) + val header = BbbClientMsgHeader(PresentationConversionCompletedEvtMsg.NAME, meetingId, userId) + + val body = PresentationConversionCompletedEvtMsgBody(podId, messageKey, code, presentation) + val event = PresentationConversionCompletedEvtMsg(header, body) + val msgEvent = BbbCommonEnvCoreMsg(envelope, event) + bus.outGW.send(msgEvent) + } +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresentationDownloadablePubMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresentationDownloadablePubMsgHdlr.scala old mode 100644 new mode 100755 index 61f3c04e6d..2c24143076 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresentationDownloadablePubMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresentationDownloadablePubMsgHdlr.scala @@ -14,26 +14,14 @@ trait SetPresentationDownloadablePubMsgHdlr extends RightsManagementTrait { liveMeeting: LiveMeeting, bus: MessageBus ): MeetingState2x = { + val meetingId = liveMeeting.props.meetingProp.intId + if (filterPresentationMessage(liveMeeting.users2x, msg.header.userId) && permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId val reason = "No permission to remove presentation from meeting." PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) state } else { - def broadcastSetPresentationDownloadableEvtMsg(podId: String, userId: String, presentationId: String, downloadable: Boolean): Unit = { - val routing = Routing.addMsgToClientRouting( - MessageTypes.BROADCAST_TO_MEETING, - liveMeeting.props.meetingProp.intId, userId - ) - val envelope = BbbCoreEnvelope(SetPresentationDownloadableEvtMsg.NAME, routing) - val header = BbbClientMsgHeader(SetPresentationDownloadableEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId) - - val body = SetPresentationDownloadableEvtMsgBody(podId, presentationId, downloadable) - val event = SetPresentationDownloadableEvtMsg(header, body) - val msgEvent = BbbCommonEnvCoreMsg(envelope, event) - bus.outGW.send(msgEvent) - } val podId = msg.body.podId val presentationId = msg.body.presentationId @@ -41,8 +29,10 @@ trait SetPresentationDownloadablePubMsgHdlr extends RightsManagementTrait { val newState = for { pod <- PresentationPodsApp.getPresentationPod(state, podId) + pres <- pod.getPresentation(presentationId) } yield { - broadcastSetPresentationDownloadableEvtMsg(pod.id, msg.header.userId, presentationId, downloadable) + PresentationSender.broadcastSetPresentationDownloadableEvtMsg(bus, meetingId, pod.id, + msg.header.userId, presentationId, downloadable, pres.name) val pods = state.presentationPodManager.setPresentationDownloadableInPod(pod.id, presentationId, downloadable) state.update(pods) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala index 919ae73edf..0b54cb1db0 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala @@ -75,8 +75,6 @@ class FromAkkaAppsMsgSenderActor(msgSender: MessageSender) msgSender.send(fromAkkaAppsPresRedisChannel, json) case RemovePresentationEvtMsg.NAME => msgSender.send(fromAkkaAppsPresRedisChannel, json) - case SetPresentationDownloadableEvtMsg.NAME => - msgSender.send(fromAkkaAppsPresRedisChannel, json) case SetCurrentPresentationEvtMsg.NAME => msgSender.send(fromAkkaAppsPresRedisChannel, json) diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/PresentationPodsMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/PresentationPodsMsgs.scala index fa95db5af2..adb578c82b 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/PresentationPodsMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/PresentationPodsMsgs.scala @@ -129,7 +129,7 @@ case class RemovePresentationEvtMsgBody(podId: String, presentationId: String) object SetPresentationDownloadableEvtMsg { val NAME = "SetPresentationDownloadableEvtMsg"} case class SetPresentationDownloadableEvtMsg(header: BbbClientMsgHeader, body: SetPresentationDownloadableEvtMsgBody) extends BbbCoreMsg -case class SetPresentationDownloadableEvtMsgBody(podId: String, presentationId: String, downloadable: Boolean) +case class SetPresentationDownloadableEvtMsgBody(podId: String, presentationId: String, downloadable: Boolean, presFilename: String) object ResizeAndMovePageEvtMsg { val NAME = "ResizeAndMovePageEvtMsg"} case class ResizeAndMovePageEvtMsg(header: BbbClientMsgHeader, body: ResizeAndMovePageEvtMsgBody) extends BbbCoreMsg diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java index 4a17a23321..84321b4f82 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java @@ -18,6 +18,7 @@ package org.bigbluebutton.api; +import java.io.File; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; @@ -856,6 +857,8 @@ public class MeetingService implements MessageListener { processGuestPolicyChanged((GuestPolicyChanged) message); } else if (message instanceof RecordChapterBreak) { processRecordingChapterBreak((RecordChapterBreak) message); + } else if (message instanceof MakePresentationDownloadableMsg) { + processMakePresentationDownloadableMsg((MakePresentationDownloadableMsg) message); } } }; @@ -874,6 +877,14 @@ public class MeetingService implements MessageListener { recordingService.kickOffRecordingChapterBreak(msg.meetingId, msg.timestamp); } + private void processMakePresentationDownloadableMsg(MakePresentationDownloadableMsg msg) { + recordingService.processMakePresentationDownloadableMsg(msg); + } + + public File getDownloadablePresentationFile(String meetingId, String presId, String presFilename) { + return recordingService.getDownloadablePresentationFile(meetingId, presId, presFilename); + } + public void start() { log.info("Starting Meeting Service."); try { diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/RecordingService.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/RecordingService.java index 351cd69dc5..1d99812653 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/RecordingService.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/RecordingService.java @@ -36,6 +36,7 @@ import java.util.Set; import org.apache.commons.io.FileUtils; import org.bigbluebutton.api.domain.Recording; import org.bigbluebutton.api.domain.RecordingMetadata; +import org.bigbluebutton.api.messaging.messages.MakePresentationDownloadableMsg; import org.bigbluebutton.api.util.RecordingMetadataReaderHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,6 +50,41 @@ public class RecordingService { private String deletedDir = "/var/bigbluebutton/deleted"; private RecordingMetadataReaderHelper recordingServiceHelper; private String recordStatusDir; + private String presentationBaseDir; + + private void copyPresentationFile(File presFile, File dlownloadableFile) { + try { + FileUtils.copyFile(presFile, dlownloadableFile); + } catch (IOException ex) { + log.error("Failed to copy file: " + ex); + } + } + + public void processMakePresentationDownloadableMsg(MakePresentationDownloadableMsg msg) { + File presDir = Util.getPresentationDir(presentationBaseDir, msg.meetingId, msg.presId); + File downloadableFile = new File(presDir.getAbsolutePath() + File.separatorChar + msg.presFilename); + + if (presDir != null) { + if (msg.downloadable) { + File presFile = new File(presDir.getAbsolutePath() + File.separatorChar + msg.presId + ".pdf"); + copyPresentationFile(presFile, downloadableFile); + } else { + if (downloadableFile.exists()) { + if(downloadableFile.delete()) { + log.info("File deleted. {}", downloadableFile.getAbsolutePath()); + } else { + log.warn("Failed to delete. {}", downloadableFile.getAbsolutePath()); + } + } + } + } + } + + public File getDownloadablePresentationFile(String meetingId, String presId, String presFilename) { + File presDir = Util.getPresentationDir(presentationBaseDir, meetingId, presId); + File downloadableFile = new File(presDir.getAbsolutePath() + File.separatorChar + presFilename); + return downloadableFile; + } public void kickOffRecordingChapterBreak(String meetingId, Long timestamp) { String done = recordStatusDir + "/" + meetingId + "-" + timestamp + ".done"; @@ -287,6 +323,10 @@ public class RecordingService { unpublishedDir = dir; } + public void setPresentationBaseDir(String dir) { + presentationBaseDir = dir; + } + public void setPublishedDir(String dir) { publishedDir = dir; } diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/Util.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/Util.java index 0d7d543f68..e89097adb5 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/Util.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/Util.java @@ -14,7 +14,7 @@ public final class Util { return presId + "." + fileExt; } - public static File createPresentationDirectory(String meetingId, String presentationDir, String presentationId) { + public static File createPresentationDir(String meetingId, String presentationDir, String presentationId) { String meetingPath = presentationDir + File.separatorChar + meetingId + File.separatorChar + meetingId; String presPath = meetingPath + File.separatorChar + presentationId; File dir = new File(presPath); @@ -24,11 +24,14 @@ public final class Util { return null; } - public static File downloadPresentationDirectory(String uploadDirectory) { - File dir = new File(uploadDirectory + File.separatorChar + "download"); - if (dir.mkdirs()) { + public static File getPresentationDir(String presentationBaseDir, String meetingId, String presentationId) { + String meetingPath = presentationBaseDir + File.separatorChar + meetingId + File.separatorChar + meetingId; + String presPath = meetingPath + File.separatorChar + presentationId; + File dir = new File(presPath); + if (dir.exists()) { return dir; } return null; } + } diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/MakePresentationDownloadableMsg.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/MakePresentationDownloadableMsg.java new file mode 100755 index 0000000000..2faa23411c --- /dev/null +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/MakePresentationDownloadableMsg.java @@ -0,0 +1,15 @@ +package org.bigbluebutton.api.messaging.messages; + +public class MakePresentationDownloadableMsg implements IMessage { + public final String meetingId; + public final String presId; + public final String presFilename; + public final Boolean downloadable; + + public MakePresentationDownloadableMsg(String meetingId, String presId, String presFilename, Boolean downloadable) { + this.meetingId = meetingId; + this.presId = presId; + this.presFilename = presFilename; + this.downloadable = downloadable; + } +} diff --git a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/bus/ReceivedJsonMsgHdlrActor.scala b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/bus/ReceivedJsonMsgHdlrActor.scala index da4f382cb6..289edd8306 100755 --- a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/bus/ReceivedJsonMsgHdlrActor.scala +++ b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/bus/ReceivedJsonMsgHdlrActor.scala @@ -93,6 +93,8 @@ class ReceivedJsonMsgHdlrActor(val msgFromAkkaAppsEventBus: MsgFromAkkaAppsEvent route[GuestPolicyChangedEvtMsg](envelope, jsonNode) case RecordingChapterBreakSysMsg.NAME => route[RecordingChapterBreakSysMsg](envelope, jsonNode) + case SetPresentationDownloadableEvtMsg.NAME => + route[SetPresentationDownloadableEvtMsg](envelope, jsonNode) case _ => //log.debug("************ Cannot route envelope name " + envelope.name) // do nothing diff --git a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala index 638109b95d..b583fbf171 100755 --- a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala +++ b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala @@ -41,7 +41,7 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW) case m: GuestsWaitingApprovedEvtMsg => handleGuestsWaitingApprovedEvtMsg(m) case m: GuestPolicyChangedEvtMsg => handleGuestPolicyChangedEvtMsg(m) case m: RecordingChapterBreakSysMsg => handleRecordingChapterBreakSysMsg(m) - + case m: SetPresentationDownloadableEvtMsg => handleSetPresentationDownloadableEvtMsg(m) case _ => log.error("***** Cannot handle " + msg.envelope.name) } } @@ -140,4 +140,14 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW) val m = new GuestStatusChangedEventMsg(msg.header.meetingId, u) olgMsgGW.handle(m) } + + def handleSetPresentationDownloadableEvtMsg(msg: SetPresentationDownloadableEvtMsg): Unit = { + val meetingId = msg.header.meetingId + val presId = msg.body.presentationId + val downloadable = msg.body.downloadable + val presFilename = msg.body.presFilename + val m = new MakePresentationDownloadableMsg(meetingId, presId, presFilename, downloadable) + olgMsgGW.handle(m) + } + } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/present/business/PresentProxy.as b/bigbluebutton-client/src/org/bigbluebutton/modules/present/business/PresentProxy.as index 37916515e3..7041e231ea 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/present/business/PresentProxy.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/present/business/PresentProxy.as @@ -198,8 +198,9 @@ package org.bigbluebutton.modules.present.business * */ public function startDownload(e:DownloadEvent):void { - var presentationName:String = e.fileNameToDownload; - var downloadUri:String = host + "/bigbluebutton/presentation/" + conference + "/" + room + "/" + presentationName + "/download"; + var presFilename:String = e.presFilename; + var presId:String = e.presId + var downloadUri:String = host + "/bigbluebutton/presentation/download/" + room + "/" + presId + "/" + presFilename; LOGGER.debug("PresentationApplication::downloadPresentation()... " + downloadUri); var req:URLRequest = new URLRequest(downloadUri); navigateToURL(req,"_blank"); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/present/events/DownloadEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/present/events/DownloadEvent.as index d45300b107..690de7b88c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/present/events/DownloadEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/present/events/DownloadEvent.as @@ -25,7 +25,8 @@ package org.bigbluebutton.modules.present.events public static const CLOSE_DOWNLOAD_WINDOW:String = "CLOSE_DOWNLOAD_WINDOW"; public static const DOWNLOAD_PRESENTATION:String = "DOWNLOAD_PRESENTATION"; - public var fileNameToDownload:String; + public var presFilename:String; + public var presId:String; public var podId:String; public function DownloadEvent(type:String) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/DownloadPresentationRenderer.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/DownloadPresentationRenderer.mxml index 574a0e0b97..109669c6d7 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/DownloadPresentationRenderer.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/present/ui/views/DownloadPresentationRenderer.mxml @@ -13,7 +13,8 @@ private function downloadPresentation():void { var downloadEvent:DownloadEvent = new DownloadEvent(DownloadEvent.DOWNLOAD_PRESENTATION); - downloadEvent.fileNameToDownload = data.id as String; + downloadEvent.presId = data.id as String; + downloadEvent.presFilename = data.name as String; globalDispatch.dispatchEvent(downloadEvent); } ]]> diff --git a/bigbluebutton-web/grails-app/conf/UrlMappings.groovy b/bigbluebutton-web/grails-app/conf/UrlMappings.groovy index e7d2eba071..3082ebc7e7 100755 --- a/bigbluebutton-web/grails-app/conf/UrlMappings.groovy +++ b/bigbluebutton-web/grails-app/conf/UrlMappings.groovy @@ -49,7 +49,7 @@ class UrlMappings { action = [GET:'showTextfile'] } - "/presentation/$conference/$room/$presentation_name/download"(controller:"presentation") { + "/presentation/download/$meetingId/$presId/$presFilename"(controller:"presentation") { action = [GET:'downloadFile'] } diff --git a/bigbluebutton-web/grails-app/conf/spring/resources.xml b/bigbluebutton-web/grails-app/conf/spring/resources.xml index a1a9f6fae7..05d1f968bb 100755 --- a/bigbluebutton-web/grails-app/conf/spring/resources.xml +++ b/bigbluebutton-web/grails-app/conf/spring/resources.xml @@ -99,6 +99,7 @@ with BigBlueButton; if not, see . + diff --git a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/PresentationController.groovy b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/PresentationController.groovy index 69ae7a25a4..b131ed025c 100755 --- a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/PresentationController.groovy +++ b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/PresentationController.groovy @@ -93,7 +93,7 @@ class PresentationController { def filenameExt = FilenameUtils.getExtension(presFilename); String presentationDir = presentationService.getPresentationDir() def presId = Util.generatePresentationId(presFilename) - File uploadDir = Util.createPresentationDirectory(meetingId, presentationDir, presId) + File uploadDir = Util.createPresentationDir(meetingId, presentationDir, presId) if (uploadDir != null) { def newFilename = Util.createNewFilename(presId, filenameExt) @@ -102,18 +102,6 @@ class PresentationController { def isDownloadable = params.boolean('is_downloadable') //instead of params.is_downloadable def podId = params.pod_id - log.debug "@AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..." + podId - - if(isDownloadable) { - log.debug "@Creating download directory..." - File downloadDir = Util.downloadPresentationDirectory(uploadDir.absolutePath) - if (downloadDir != null) { - def notValidCharsRegExp = /[^0-9a-zA-Z_\.]/ - def downloadableFileName = presFilename.replaceAll(notValidCharsRegExp, '-') - def downloadableFile = new File( downloadDir.absolutePath + File.separatorChar + downloadableFileName ) - downloadableFile << pres.newInputStream() - } - } def presentationBaseUrl = presentationService.presentationBaseUrl UploadedPresentation uploadedPres = new UploadedPresentation(podId, meetingId, presId, @@ -276,16 +264,18 @@ class PresentationController { } def downloadFile = { - def presentationName = params.presentation_name - def conf = params.conference - def rm = params.room - println "Controller: Download request for $presentationName" + def presId = params.presId + def presFilename = params.presFilename + def meetingId = params.meetingId + + log.debug "Controller: Download request for $presFilename" + String presentationDir = presentationService.getPresentationDir() InputStream is = null; try { - def pres = presentationService.getFile(conf, rm, presentationName) + def pres = meetingService.getDownloadablePresentationFile(meetingId, presId, presFilename) if (pres.exists()) { - println "Controller: Sending pdf reply for $presentationName" + log.debug "Controller: Sending pdf reply for $presFilename" def bytes = pres.readBytes() def responseName = pres.getName(); @@ -293,10 +283,10 @@ class PresentationController { response.addHeader("Cache-Control", "no-cache") response.outputStream << bytes; } else { - println "$pres does not exist." + log.warn "$pres does not exist." } } catch (IOException e) { - println("Error reading file.\n" + e.getMessage()); + log.error("Error reading file.\n" + e.getMessage()); } return null; diff --git a/bigbluebutton-web/grails-app/services/org/bigbluebutton/web/services/PresentationService.groovy b/bigbluebutton-web/grails-app/services/org/bigbluebutton/web/services/PresentationService.groovy index 88f765f990..79fa143a86 100755 --- a/bigbluebutton-web/grails-app/services/org/bigbluebutton/web/services/PresentationService.groovy +++ b/bigbluebutton-web/grails-app/services/org/bigbluebutton/web/services/PresentationService.groovy @@ -168,15 +168,6 @@ class PresentationService { } - def getFile = {conf, room, presentationName -> - println "download request for $presentationName" - def fileDirectory = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar + -"download") - //list the files of the download directory ; it must have only 1 file to download - def list = fileDirectory.listFiles() - //new File(pdfFile) - list[0] - } } /*** Helper classes **/