From 27fd992294a2f33a3d2b1b136c868f3a7f501526 Mon Sep 17 00:00:00 2001 From: Ghazi Triki <ghazi.triki@riadvice.tn> Date: Mon, 3 Oct 2016 17:39:02 +0100 Subject: [PATCH] Handle non PDF slide conversion for breakout rooms. --- .../PresentationUrlDownloadService.java | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/presentation/PresentationUrlDownloadService.java b/bigbluebutton-web/src/java/org/bigbluebutton/presentation/PresentationUrlDownloadService.java index e041c8af2c..f28a59b316 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/presentation/PresentationUrlDownloadService.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/presentation/PresentationUrlDownloadService.java @@ -49,20 +49,29 @@ public class PresentationUrlDownloadService { + File.separator + presentationId); final String presentationFilter = presentationId; - FilenameFilter filter = new FilenameFilter() { + FilenameFilter pdfFilter = new FilenameFilter() { public boolean accept(File dir, String name) { - return name.startsWith(presentationFilter); + return name.startsWith(presentationFilter) + && name.toLowerCase().endsWith("pdf"); } }; - File[] children = sourceMeetingPath.listFiles(filter); + File[] matches = sourceMeetingPath.listFiles(pdfFilter); + if (matches.length != 1) { + // No PDF presentation was found, we look for an image presentation + FilenameFilter imgFlter = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.startsWith(presentationFilter); + } + }; - if (children.length != 1) { - log.error("Not matching file with prefix {} found at {}", + matches = sourceMeetingPath.listFiles(imgFlter); + } + if (matches.length != 1) { + log.info("Not matching PDF file with prefix {} found at {}", sourceMeetingId, sourceMeetingPath); - return; } else { - File sourcePresentationFile = children[0]; + File sourcePresentationFile = matches[0]; String filenameExt = FilenameUtils .getExtension(sourcePresentationFile.getName()); String presId = generatePresentationId(presentationId); @@ -72,13 +81,25 @@ public class PresentationUrlDownloadService { presentationDir, presId); String newFilePath = uploadDir.getAbsolutePath() + File.separatorChar + newFilename; + File newPresentation = new File(newFilePath); - pageExtractor.extractPage(sourcePresentationFile, new File( - newFilePath), presentationSlide); + if (sourcePresentationFile.getName().toLowerCase().endsWith("pdf")) { + pageExtractor.extractPage(sourcePresentationFile, new File( + newFilePath), presentationSlide); + } else { + try { + FileUtils.copyFile(sourcePresentationFile, newPresentation); + } catch (IOException e) { + log.error("Could not copy presentation {} to {}", + sourcePresentationFile.getAbsolutePath(), + newPresentation.getAbsolutePath()); + e.printStackTrace(); + } + } - File pres = new File(newFilePath); processUploadedFile(destinationMeetingId, presId, "default-" - + presentationSlide.toString() + "." + filenameExt, pres); + + presentationSlide.toString() + "." + filenameExt, + newPresentation); } } -- GitLab