Skip to content

Commit

Permalink
- add urls on presentation page conversion message
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Feb 18, 2020
1 parent 2c03870 commit db4dc4a
Show file tree
Hide file tree
Showing 22 changed files with 365 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting

trait PdfConversionInvalidErrorSysPubMsgHdlr {
this: PresentationPodHdlrs =>
this: PresentationPodHdlrs =>

def handle(
msg: PdfConversionInvalidErrorSysPubMsg, state: MeetingState2x,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.bigbluebutton.core.apps.presentationpod

import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting

trait PresentationPageConvertedSysMsgHdlr {
this: PresentationPodHdlrs =>

def handle(msg: PresentationPageConvertedSysMsg, state: MeetingState2x,
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {

def broadcastEvent(msg: PresentationPageConvertedSysMsg): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, msg.header.userId
)
val envelope = BbbCoreEnvelope(PresentationPageConvertedEventMsg.NAME, routing)
val header = BbbClientMsgHeader(
PresentationPageConvertedEventMsg.NAME,
liveMeeting.props.meetingProp.intId, msg.header.userId
)

val body = PresentationPageConvertedEventMsgBody(
msg.body.podId,
msg.body.messageKey,
msg.body.code,
msg.body.presentationId,
msg.body.numberOfPages,
msg.body.pagesCompleted,
msg.body.presName,
msg.body.page
)
val event = PresentationPageConvertedEventMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
}

broadcastEvent(msg)
state
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class PresentationPodHdlrs(implicit val context: ActorContext)
with PresentationUploadTokenReqMsgHdlr
with ResizeAndMovePagePubMsgHdlr
with SyncGetPresentationPodsMsgHdlr
with RemovePresentationPodPubMsgHdlr {
with RemovePresentationPodPubMsgHdlr
with PresentationPageConvertedSysMsgHdlr {

val log = Logging(context.system, getClass)
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ class ReceivedJsonMsgHandlerActor(
routeGenericMsg[PresentationPageCountErrorSysPubMsg](envelope, jsonNode)
case PresentationPageGeneratedSysPubMsg.NAME =>
routeGenericMsg[PresentationPageGeneratedSysPubMsg](envelope, jsonNode)
case PresentationPageConvertedSysMsg.NAME =>
routeGenericMsg[PresentationPageConvertedSysMsg](envelope, jsonNode)
case PresentationConversionStartedSysMsg.NAME =>
routeGenericMsg[PresentationConversionStartedSysMsg](envelope, jsonNode)
case PresentationConversionCompletedSysPubMsg.NAME =>
routeGenericMsg[PresentationConversionCompletedSysPubMsg](envelope, jsonNode)
case PdfConversionInvalidErrorSysPubMsg.NAME =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ class MeetingActor(
case m: PresentationPageCountErrorSysPubMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: PresentationUploadTokenReqMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: ResizeAndMovePagePubMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: PresentationPageConvertedSysMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)

// Caption
case m: EditCaptionHistoryPubMsg => captionApp2x.handle(m, liveMeeting, msgBus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class AnalyticsActor extends Actor with ActorLogging {
case m: SetCurrentPresentationEvtMsg => logMessage(msg)
case m: SetPresentationDownloadablePubMsg => logMessage(msg)
case m: SetPresentationDownloadableEvtMsg => logMessage(msg)
case m: PresentationPageConvertedSysMsg => logMessage(msg)
case m: PresentationPageConvertedEventMsg => logMessage(msg)
case m: PresentationConversionStartedSysMsg => logMessage(msg)

// Group Chats
case m: SendGroupChatMessageMsg => logMessage(msg)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bigbluebutton.common2.msgs

import org.bigbluebutton.common2.domain.{ PresentationPodVO, PresentationVO }
import org.bigbluebutton.common2.domain.{ PageVO, PresentationPodVO, PresentationVO }

// ------------ client to akka-apps ------------
object CreateNewPresentationPodPubMsg { val NAME = "CreateNewPresentationPodPubMsg" }
Expand Down Expand Up @@ -73,8 +73,8 @@ case class PdfConversionInvalidErrorSysPubMsg(
body: PdfConversionInvalidErrorSysPubMsgBody
) extends StandardMsg
case class PdfConversionInvalidErrorSysPubMsgBody(podId: String, messageKey: String, code: String, presentationId: String,
bigPageNumber: Int, bigPageSize: Int, presName: String)
bigPageNumber: Int, bigPageSize: Int, presName: String)

object PresentationPageGeneratedSysPubMsg { val NAME = "PresentationPageGeneratedSysPubMsg" }
case class PresentationPageGeneratedSysPubMsg(
header: BbbClientMsgHeader,
Expand All @@ -90,6 +90,47 @@ case class PresentationConversionCompletedSysPubMsg(
) extends StandardMsg
case class PresentationConversionCompletedSysPubMsgBody(podId: String, messageKey: String, code: String,
presentation: PresentationVO)

object PresentationPageConvertedSysMsg { val NAME = "PresentationPageConvertedSysMsg" }
case class PresentationPageConvertedSysMsg(
header: BbbClientMsgHeader,
body: PresentationPageConvertedSysMsgBody
) extends StandardMsg
case class PresentationPageConvertedSysMsgBody(
podId: String,
messageKey: String,
code: String,
presentationId: String,
numberOfPages: Int,
pagesCompleted: Int,
presName: String,
page: PageVO
)

object PresentationConversionStartedSysMsg { val NAME = "PresentationConversionStartedSysMsg" }
case class PresentationConversionStartedSysMsg(
header: BbbClientMsgHeader,
body: PresentationConversionStartedSysMsgBody
) extends StandardMsg
case class PresentationConversionStartedSysMsgBody(
podId: String,
presentationId: String,
current: Boolean,
presName: String,
downloadable: Boolean
)

object PresentationConversionEndedSysMsg { val NAME = "PresentationConversionEndedSysMsg" }
case class PresentationConversionEndedSysMsg(
header: BbbClientMsgHeader,
body: PresentationConversionEndedSysMsgBody
) extends StandardMsg
case class PresentationConversionEndedSysMsgBody(
podId: String,
presentationId: String,
presName: String
)

// ------------ bbb-common-web to akka-apps ------------

// ------------ akka-apps to client ------------
Expand Down Expand Up @@ -125,6 +166,22 @@ object PresentationPageGeneratedEvtMsg { val NAME = "PresentationPageGeneratedEv
case class PresentationPageGeneratedEvtMsg(header: BbbClientMsgHeader, body: PresentationPageGeneratedEvtMsgBody) extends BbbCoreMsg
case class PresentationPageGeneratedEvtMsgBody(podId: String, messageKey: String, code: String, presentationId: String, numberOfPages: Int, pagesCompleted: Int, presName: String)

object PresentationPageConvertedEventMsg { val NAME = "PresentationPageConvertedEventMsg" }
case class PresentationPageConvertedEventMsg(
header: BbbClientMsgHeader,
body: PresentationPageConvertedEventMsgBody
) extends BbbCoreMsg
case class PresentationPageConvertedEventMsgBody(
podId: String,
messageKey: String,
code: String,
presentationId: String,
numberOfPages: Int,
pagesCompleted: Int,
presName: String,
page: PageVO
)

object PresentationConversionCompletedEvtMsg { val NAME = "PresentationConversionCompletedEvtMsg" }
case class PresentationConversionCompletedEvtMsg(header: BbbClientMsgHeader, body: PresentationConversionCompletedEvtMsgBody) extends BbbCoreMsg
case class PresentationConversionCompletedEvtMsgBody(podId: String, messageKey: String, code: String, presentation: PresentationVO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ConversionMessageConstants {
public static final String GENERATED_TEXTFILES_KEY = "GENERATED_TEXTFILES";
public static final String GENERATING_SVGIMAGES_KEY = "GENERATING_SVGIMAGES";
public static final String GENERATED_SVGIMAGES_KEY = "GENERATED_SVGIMAGES";
public static final String CONVERSION_STARTED_KEY = "CONVERSION_STARTED_KEY";
public static final String CONVERSION_COMPLETED_KEY = "CONVERSION_COMPLETED";

private ConversionMessageConstants() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bigbluebutton.presentation.imp.ImageToSwfSlidesGenerationService;
import org.bigbluebutton.presentation.imp.OfficeToPdfConversionService;
import org.bigbluebutton.presentation.imp.PdfToSwfSlidesGenerationService;
import org.bigbluebutton.presentation.messages.DocConversionStarted;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -40,21 +41,46 @@ public class DocumentConversionServiceImp implements DocumentConversionService {
private PdfToSwfSlidesGenerationService pdfToSwfSlidesGenerationService;
private ImageToSwfSlidesGenerationService imageToSwfSlidesGenerationService;

private void sendDocConversionStartedProgress(UploadedPresentation pres) {
DocConversionStarted progress = new DocConversionStarted(
pres.getPodId(),
pres.getMeetingId(),
pres.getId(),
pres.getName(),
pres.getAuthzToken(),
pres.isDownloadable(),
pres.isDownloadable());
gw.sendDocConversionMsg(progress);
}

public void processDocument(UploadedPresentation pres) {
SupportedDocumentFilter sdf = new SupportedDocumentFilter(gw);

Map<String, Object> logData = new HashMap<String, Object>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
logData.put("current", pres.isCurrent());
logData.put("logCode", "presentation_conversion_start");
logData.put("message", "Start presentation conversion.");

Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.info(" --analytics-- data={}", logStr);

if (! pres.isConversionStarted()) {
Map<String, Object> logData = new HashMap<String, Object>();

logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
logData.put("current", pres.isCurrent());
logData.put("authzToken", pres.getAuthzToken());
logData.put("logCode", "presentation_conversion_start");
logData.put("message", "Start presentation conversion.");

Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.info(" --analytics-- data={}", logStr);

pres.startConversion();
sendDocConversionStartedProgress(pres);
}





if (sdf.isSupported(pres)) {
String fileType = pres.getFileType();
Expand All @@ -79,6 +105,7 @@ public void processDocument(UploadedPresentation pres) {
} else if (SupportedFileTypes.isImageFile(fileType)) {
imageToSwfSlidesGenerationService.generateSlides(pres);
} else {
Map<String, Object> logData = new HashMap<String, Object>();
logData = new HashMap<String, Object>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
Expand All @@ -87,12 +114,14 @@ public void processDocument(UploadedPresentation pres) {
logData.put("current", pres.isCurrent());
logData.put("logCode", "supported_file_not_handled");
logData.put("message", "Supported file not handled.");
gson = new Gson();
logStr = gson.toJson(logData);

Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.warn(" --analytics-- data={}", logStr);
}

} else {
Map<String, Object> logData = new HashMap<String, Object>();
logData = new HashMap<String, Object>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
Expand All @@ -101,11 +130,13 @@ public void processDocument(UploadedPresentation pres) {
logData.put("current", pres.isCurrent());
logData.put("logCode", "unsupported_file_format");
logData.put("message", "Unsupported file format");
gson = new Gson();
logStr = gson.toJson(logData);

Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.error(" --analytics-- data={}", logStr);
}

Map<String, Object> logData = new HashMap<String, Object>();
logData = new HashMap<String, Object>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
Expand All @@ -114,8 +145,9 @@ public void processDocument(UploadedPresentation pres) {
logData.put("current", pres.isCurrent());
logData.put("logCode", "presentation_conversion_end");
logData.put("message", "End presentation conversion.");
gson = new Gson();
logStr = gson.toJson(logData);

Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.info(" --analytics-- data={}", logStr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public void run() {
}

public void processUploadedFile(String podId, String meetingId, String presId,
String filename, File presFile, Boolean current) {
String filename, File presFile, Boolean current, String authzToken) {
// TODO add podId
UploadedPresentation uploadedPres = new UploadedPresentation(podId, meetingId,
presId, filename, presentationBaseURL, current);
presId, filename, presentationBaseURL, current, authzToken);
uploadedPres.setUploadedFile(presFile);
processUploadedPresentation(uploadedPres);
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public boolean accept(File dir, String name) {
// Hardcode pre-uploaded presentation for breakout room to the default presentation window
processUploadedFile("DEFAULT_PRESENTATION_POD", destinationMeetingId, presId, "default-"
+ presentationSlide.toString() + "." + filenameExt,
newPresentation, true);
newPresentation, true, "breakout-authz-token");
}

public String generatePresentationId(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,24 @@ public final class UploadedPresentation {
private final String baseUrl;
private boolean isDownloadable = false;
private boolean current = false;

public UploadedPresentation(String podId, String meetingId, String id, String name, String baseUrl, Boolean current) {
private String authzToken;
private boolean conversionStarted = false;

public UploadedPresentation(String podId,
String meetingId,
String id,
String name,
String baseUrl,
Boolean current,
String authzToken) {
this.podId = podId;
this.meetingId = meetingId;
this.id = id;
this.name = name;
this.baseUrl = baseUrl;
this.isDownloadable = false;
this.current = current;
this.authzToken = authzToken;
}

public File getUploadedFile() {
Expand Down Expand Up @@ -111,4 +120,16 @@ public boolean isCurrent() {
public void setCurrent(Boolean value) {
this.current = value;
}

public String getAuthzToken() {
return authzToken;
}

public void startConversion() {
conversionStarted = true;
}

public boolean isConversionStarted() {
return conversionStarted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ private void handleSlideGenerationResult(UploadedPresentation pres, ImageToSwfSl
slide.generateBlankSlide();
}
}
slideGenerated++;
notifier.sendConversionUpdateMessage(slideGenerated, pres);
slideGenerated++;
notifier.sendConversionUpdateMessage(slideGenerated, pres, slide.getPageNumber());
}
}

Expand Down
Loading

0 comments on commit db4dc4a

Please sign in to comment.