- can now handle PDF

- need to figure out why office doc throws SI exception

git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@3154 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
Richard Alam 2009-12-29 20:29:17 +00:00
parent 7e2a0b5b2e
commit 310e330b97
18 changed files with 212 additions and 460 deletions

View File

@ -25,8 +25,8 @@
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]
grails.config.locations = [ "classpath:bigbluebutton.properties","file:${userHome}/.grails/${appName}-config.properties"]
//grails.config.locations = [ "classpath:bigbluebutton.properties","file:${userHome}/.grails/${appName}-config.properties"]
grails.config.locations = [ "classpath:bigbluebutton.properties"]
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }

View File

@ -24,11 +24,11 @@ dataSource {
password = "secret"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
//hibernate {
// cache.use_second_level_cache=true
// cache.use_query_cache=true
// cache.provider_class='org.hibernate.cache.EhCacheProvider'
//}
// environment specific settings
environments {
@ -41,7 +41,7 @@ environments {
test {
dataSource {
dbCreate = 'create'
url = "jdbc:hsqldb:mem:testDb"
url = "jdbc:mysql://localhost/bigbluebutton_test"
}
}
production {

View File

@ -4,6 +4,7 @@
dataSource.url=jdbc:mysql://localhost/bigbluebutton_dev
dataSource.username=bbb
dataSource.password=secret
dataSource.driverClassName =com.mysql.jdbc.Driver
# Directory where BigBlueButton stores uploaded slides
presentationDir=/var/bigbluebutton
@ -31,14 +32,7 @@ BLANK_THUMBNAIL=/var/bigbluebutton/blank/blank-thumb.png
# more than this time, cancel the conversion process.
maxConversionTime=5
# Inject the above properties into the PresentationService bean
beans.presentationService.swfToolsDir=${swfToolsDir}
beans.presentationService.imageMagickDir=${imageMagickDir}
beans.presentationService.presentationDir=${presentationDir}
beans.presentationService.ghostScriptExec=${ghostScriptExec}
beans.presentationService.noPdfMarkWorkaround=${noPdfMarkWorkaround}
beans.presentationService.BLANK_THUMBNAIL=${BLANK_THUMBNAIL}
beans.presentationService.BLANK_SLIDE=${BLANK_SLIDE}
beans.adhocConferenceService.serviceEnabled=true
beans.dynamicConferenceService.serviceEnabled=true

View File

@ -2,14 +2,49 @@
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
<!--beans:bean id="documentConversionServiceGateway" class="org.bigbluebutton.presentation.DocumentConversionServiceGateway">
<beans:property name="presentationService" ref="presentationService"/>
<beans:property name="documentConversionService" ref="documentConversionService"/>
</beans:bean-->
<gateway id="documentConversionService" service-interface="org.bigbluebutton.presentation.DocumentConversionService"/>
<channel id="convertChannel"/>
<filter method="isSupported" input-channel="convertChannel" output-channel="docRouterChannel" discard-channel="discardChannel">
<beans:bean class="org.bigbluebutton.presentation.SupportedDocumentFilter">
<beans:property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
</beans:bean>
</filter>
<channel id="docRouterChannel"/>
<router input-channel="docRouterChannel">
<beans:bean class="org.bigbluebutton.presentation.FileTypeRouter"/>
</router>
<channel id="officeFileChannel"/>
<channel id="pdfFileChannel"/>
<gateway id="conversionProgressNotifier" service-interface="org.bigbluebutton.presentation.ConversionProgressNotifier"/>
<service-activator input-channel="officeFileChannel" method="convertOfficeToPdf">
<beans:bean class="rg.bigbluebutton.presentation.imp.OfficeToPdfConversionService"/>
</service-activator>
<service-activator input-channel="pdfFileChannel" ref="slidesGenerationService" method="generateSlides"/>
<channel id="discardChannel"/>
<channel id="conversionProgressChannel"/>
<jms:outbound-channel-adapter id="jmsOut" destination="UpdatesQueue" channel="conversionProgressChannel"/>
<beans:bean id="pageExtractor" class="org.bigbluebutton.presentation.imp.GhostscriptPageExtractor">
<beans:property name="ghostscriptExec" value="${ghostScriptExec}"/>
<beans:property name="noPdfMarkWorkaround" value="${noPdfMarkWorkaround}"/>
@ -53,6 +88,7 @@
<beans:property name="thumbnailCreator" ref="thumbCreator"/>
<beans:property name="blankSlide" value="${BLANK_SLIDE}"/>
<beans:property name="maxConversionTime" value="${maxConversionTime}"/>
<beans:property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
</beans:bean>
</beans:beans>

View File

@ -29,5 +29,9 @@ beans = {
jmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = jmsFactory
}
}
jmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = jmsFactory
}
}

View File

@ -17,7 +17,8 @@
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd
">
<bean class="org.asteriskjava.fastagi.AgiServerThread"
init-method="startup" destroy-method="shutdown">
<property name="agiServer" ref="agiServer"/>
@ -38,7 +39,9 @@
</bean>
<bean id="asteriskAgi" class="org.bigbluebutton.pbx.asterisk.AsteriskAgiService" />
<bean id="test123" class="org.bigbluebutton.presentation.imp.Testing123" />
<!-- Spring Integration / JMS gateways -->
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
@ -71,5 +74,82 @@
<!-- <stream:stdout-channel-adapter id="stdout" channel="jmsinToStdoutChannel" append-newline="true"/>-->
<import resource="doc-conversion.xml" />
<!--import resource="doc-conversion.xml" /-->
<integration:gateway id="documentConversionService" service-interface="org.bigbluebutton.presentation.DocumentConversionService"/>
<integration:channel id="convertChannel"/>
<integration:filter ref="supportedDocumentFilter" method="isSupported" input-channel="convertChannel"
output-channel="docRouterChannel"/>
<bean id="supportedDocumentFilter" class="org.bigbluebutton.presentation.SupportedDocumentFilter">
<property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
</bean>
<integration:channel id="docRouterChannel"/>
<integration:router ref="fileTypeRouter" input-channel="docRouterChannel"/>
<bean id="fileTypeRouter" class="org.bigbluebutton.presentation.FileTypeRouter"/>
<integration:channel id="officeFileChannel"/>
<integration:channel id="pdfFileChannel"/>
<integration:channel id="conversionProgressChannel"/>
<integration:gateway id="conversionProgressNotifier" service-interface="org.bigbluebutton.presentation.ConversionProgressNotifier"/>
<integration:service-activator input-channel="officeFileChannel" ref="officeToPdfConversionService" method="convertOfficeToPdf"/>
<bean id="officeToPdfConversionService" class="org.bigbluebutton.presentation.imp.OfficeToPdfConversionService"/>
<integration:service-activator input-channel="pdfFileChannel" ref="slidesGenerationService" method="generateSlides"/>
<integration:channel id="discardChannel"/>
<jms:outbound-channel-adapter id="jmsOut" destination-name="UpdatesQueue" channel="conversionProgressChannel"/>
<bean id="pageExtractor" class="org.bigbluebutton.presentation.imp.GhostscriptPageExtractor">
<property name="ghostscriptExec" value="${ghostScriptExec}"/>
<property name="noPdfMarkWorkaround" value="${noPdfMarkWorkaround}"/>
</bean>
<bean id="imageMagickPageConverter" class="org.bigbluebutton.presentation.imp.ImageMagickPageConverter">
<property name="imageMagickDir" value="${imageMagickDir}"/>
</bean>
<bean id="png2SwfConverter" class="org.bigbluebutton.presentation.imp.Png2SwfPageConverter">
<property name="swfToolsDir" value="${swfToolsDir}"/>
</bean>
<bean id="pageCounter" class="org.bigbluebutton.presentation.imp.Pdf2SwfPageCounter">
<property name="swfToolsDir" value="${swfToolsDir}"/>
</bean>
<bean id="pageCounterService" class="org.bigbluebutton.presentation.imp.PageCounterService">
<property name="pageCounter" ref="pageCounter"/>
</bean>
<bean id="pdf2SwfPageConverter" class="org.bigbluebutton.presentation.imp.Pdf2SwfPageConverter">
<property name="swfToolsDir" value="${swfToolsDir}"/>
</bean>
<bean id="imageConvSvc" class="org.bigbluebutton.presentation.imp.PdfPageToImageConversionService">
<property name="pageExtractor" ref="pageExtractor"/>
<property name="pdfToImageConverter" ref="imageMagickPageConverter"/>
<property name="imageToSwfConverter" ref="png2SwfConverter"/>
</bean>
<bean id="thumbCreator" class="org.bigbluebutton.presentation.imp.ThumbnailCreatorImp">
<property name="imageMagickDir" value="${imageMagickDir}"/>
<property name="blankThumbnail" value="${BLANK_THUMBNAIL}"/>
</bean>
<bean id="generatedSlidesInfoHelper" class="org.bigbluebutton.presentation.GeneratedSlidesInfoHelperImp"/>
<bean id="slidesGenerationService" class="org.bigbluebutton.presentation.imp.PdfToSwfSlidesGenerationService">
<property name="counterService" ref="pageCounterService"/>
<property name="pageConverter" ref="pdf2SwfPageConverter"/>
<property name="pdfPageToImageConversionService" ref="imageConvSvc"/>
<property name="thumbnailCreator" ref="thumbCreator"/>
<property name="blankSlide" value="${BLANK_SLIDE}"/>
<property name="maxConversionTime" value="${maxConversionTime}"/>
<property name="conversionProgressNotifier" ref="conversionProgressNotifier"/>
<property name="generatedSlidesInfoHelper" ref="generatedSlidesInfoHelper"/>
</bean>
</beans>

View File

@ -29,11 +29,13 @@ import org.springframework.util.FileCopyUtils
import grails.converters.*
import org.bigbluebutton.web.services.PresentationService
import org.bigbluebutton.presentation.UploadedPresentation
import org.bigbluebutton.presentation.imp.Testing123
class PresentationController {
PresentationService presentationService
static transactional = true
// static transactional = false
def test123
def index = {
println 'in PresentationController index'
render(view:'upload-file')
@ -89,7 +91,7 @@ class PresentationController {
UploadedPresentation uploadedPres = new UploadedPresentation(params.conference, params.room, presentationName);
uploadedPres.setUploadedFile(pres);
// test123.testtest();
presentationService.processUploadedPresentation(uploadedPres)
}
else {

View File

@ -22,38 +22,27 @@
*/
package org.bigbluebutton.web.services
import javax.jms.Message
import javax.jms.Session
import javax.jms.JMSException
import javax.jms.MapMessage
import org.springframework.jms.core.JmsTemplate
import java.util.*;
import java.util.concurrent.*;
import java.lang.InterruptedException
import org.springframework.util.FileCopyUtils
import org.bigbluebutton.presentation.imp.*
import org.bigbluebutton.presentation.*
import org.bigbluebutton.presentation.DocumentConversionServiceGateway
import org.bigbluebutton.presentation.imp.Testing123
class PresentationService {
boolean transactional = false
def jmsTemplate
def imageMagickDir
def ghostScriptExec
def swfToolsDir
def presentationDir
def BLANK_SLIDE = '/var/bigbluebutton/blank/blank-slide.swf'
def BLANK_THUMBNAIL = '/var/bigbluebutton/blank/blank-thumb.png'
static transactional = false
// DocumentConversionServiceGateway documentConversionServiceGateway
def documentConversionService
def presentationDir
def test123
public PresentationService() {
println "Start Presetnation Service"
}
/*
* This is a workaround for this problem.
* http://groups.google.com/group/comp.lang.postscript/browse_thread/thread/c2e264ca76534ce0?pli=1
*/
def noPdfMarkWorkaround
private static String JMS_UPDATES_Q = 'UpdatesQueue'
def deletePresentation = {conf, room, filename ->
def directory = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + filename)
deleteDirectory(directory)
@ -105,275 +94,12 @@ class PresentationService {
return dir
}
public File prepareFileType(String conference, String room, String presentationName, File presentationFile, String ext) {
log.debug "Preparing file $ext"
println "Preparing file $ext"
switch(ext)
{
/* OFFICE FILE */
case 'xls':
case 'xlsx':
case 'doc':
case 'docx':
case 'ppt':
case 'pptx':
case 'odt':
case 'rtf':
case 'txt':
case 'ods':
case 'odp':
log.debug "Office File " + ext + ", converting to PDF..."
println "Office File " + ext + ", converting to PDF..."
try {
PageConverter converter = new Office2PdfPageConverter()
File output = new File(presentationFile.getAbsolutePath().substring(0, presentationFile.getAbsolutePath().lastIndexOf(".")) + ".pdf")
println presentationFile.getAbsolutePath().substring(0, presentationFile.getAbsolutePath().lastIndexOf(".")) + ".pdf"
Boolean convertion = converter.convert(presentationFile, output, 0)
println convertion
if (convertion)
return (output);
else
throw new Exception("");
} catch (Exception ex) {
println("Error converting FileType " + ext + " to PDF...")
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SOFFICE")
}
break;
case 'avi':
case 'mpg':
/* Testing requirements - ffmpeg */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_NOT_SUPPORTED")
break;
case 'mp3':
/* Testing requirements - ffmpeg */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_NOT_SUPPORTED")
break;
/* DEFAULT SUPPORTED FILES - NO PREPARATION NEEDED*/
case 'pdf':
case 'jpg':
case 'jpeg':
case 'png':
return (presentationFile);
break;
default:
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_NOT_SUPPORTED")
break;
}
return (null);
}
public boolean convertFileType(String conference, String room, String presentationName, File presentationFile, String ext, int numPages) {
log.debug "Converting uploaded presentation $presentationFile.absolutePath"
switch(ext)
{
/* OFFICE FILE CONVERTED TO PDF in prepareFileType */
/* PDF FILE */
case 'xls':
case 'xlsx':
case 'doc':
case 'docx':
case 'ppt':
case 'pptx':
case 'pdf':
case 'odt':
case 'rtf':
case 'txt':
case 'ods':
case 'odp':
try {
for (int page = 1; page <= numPages; page++)
{
log.debug "Converting page $page of $presentationFile.absolutePath"
convertPage(presentationFile, page)
sendConversionUpdateMessage(conference, room, presentationName, numPages, page)
}
return (true);
} catch (Exception ex) {
println("Error converting File " + ext + " to PDF...")
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SWF_PDF")
}
break;
case 'jpg':
case 'jpeg':
case 'png':
try {
PageConverter converter;
if (ext == 'png')
converter = new Png2SwfPageConverter()
else if (ext == 'jpg' || ext == 'jpeg')
converter = new Jpeg2SwfPageConverter()
else
return (false);
converter.setSwfToolsDir(swfToolsDir)
File output = new File(presentationFile.getParent() + File.separatorChar + "slide-1.swf")
if (!converter.convert(presentationFile, output, 1))
generateBlankSlide(output.getAbsolutePath());
sendConversionUpdateMessage(conference, room, presentationName, numPages, 1)
return (true);
} catch (Exception ex) {
println("Error converting File " + ext + " to PDF...")
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SWF_IMAGE")
}
break;
case 'avi':
case 'mpg':
/* Conversion to flv using ffmpeg */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SWF")
break;
case 'mp3':
/* Conversion to flv using ffmpeg */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SWF")
break;
default:
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_SWF")
break;
}
return (false);
}
public int getnumPages(String conference, String room, String presentationName, File presentationFile, String ext) {
log.debug "Determining number of pages"
switch(ext)
{
/* OFFICE FILE CONVERTED TO PDF IN prepareFileType */
/* PDF FILE */
case 'xls':
case 'xlsx':
case 'doc':
case 'docx':
case 'ppt':
case 'pptx':
case 'pdf':
case 'odt':
case 'rtf':
case 'txt':
case 'ods':
case 'odp':
try
{
PageCounter pageCounter = new Pdf2SwfPageCounter()
pageCounter.setSwfToolsDir(swfToolsDir)
int numPages = pageCounter.countNumberOfPages(presentationFile)
if (numPages > 100)
{
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_MAXNBPAGE_REACH")
return (0);
}
else if (numPages > 0)
return (numPages);
else
throw new Exception("");
} catch (Exception ex) {
println("Error getting number of pages")
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_NBPAGE")
}
break;
case 'avi':
case 'mpg':
case 'mp3':
case 'jpg':
case 'jpeg':
case 'png':
return (1);
break;
default:
/* Problem getting number of pages "Error while getting number of pages" */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_NBPAGE")
break;
}
return (0);
}
public boolean createThumbnails(String conference, String room, String presentationName, File presentationFile, String ext, int numPages) {
log.debug "Creating thumbnails for presentation.absolutePath"
// Send twice...seem to be loosing messages...need to understand some more
// how to set JMS producer-consumer
sendCreatingThumbnailsUpdateMessage(conference, room, presentationName)
sendCreatingThumbnailsUpdateMessage(conference, room, presentationName)
switch(ext)
{
/* OFFICE FILE CONVERTED TO PDF in prepareFileType */
/* PDF FILE */
case 'xls':
case 'xlsx':
case 'doc':
case 'docx':
case 'ppt':
case 'pptx':
case 'pdf':
case 'jpg':
case 'jpeg':
case 'png':
case 'odt':
case 'rtf':
case 'txt':
case 'ods':
case 'odp':
try
{
ThumbnailCreatorImp tc = new ThumbnailCreatorImp()
tc.imageMagickDir = imageMagickDir
tc.blankThumbnail = BLANK_THUMBNAIL
tc.createThumbnails(presentationFile, numPages)
return (true);
} catch (Exception ex) {
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_THUMBNAIL")
}
break;
case 'avi':
case 'mpg':
case 'mp3':
/* TODO ADD SUPPORT */
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_THUMBNAIL")
break;
default:
sendConvertErrorMessage(conference, room, presentationName, presentationFile, "FAILED_CONVERT_THUMBNAIL")
break;
}
return (false);
}
def processUploadedPresentation = {uploadedPres ->
// Run conversion on another thread.
new Timer().runAfter(1000)
{
/* Getting file extension - Perhaps try to rely on smth more accurate than an extension type ? */
String ext = presentationFile.getName().toLowerCase().substring(presentationFile.getName().toLowerCase().lastIndexOf('.') + 1)
if (ext)
{
/* Prepare file convertion depending on filetype (OFFICE -> PDF) */
File ConvertedPresentationFile = prepareFileType(conf, room, presentationName, presentationFile, ext)
log.debug ConvertedPresentationFile
if (ConvertedPresentationFile)
{
/* Getting number of pages, if available */
int numPages = getnumPages(conf, room, presentationName, ConvertedPresentationFile, ext)
log.info "There is/are $numPages slide(s) for $presentationFile.absolutePath"
if (numPages)
{
/* Convert File to Presentation Pages */
if (convertFileType(conf, room, presentationName, ConvertedPresentationFile, ext, numPages))
{
/* Create thumbnails for each pages */
if (createThumbnails(conf, room, presentationName, ConvertedPresentationFile, ext, numPages))
{
/* We're done */
sendConversionCompletedMessage(conf, room, presentationName, numPages)
}
}
}
}
}
else /* Problem with fileformat "Unable to determine file format" */
sendConvertErrorMessage(conf, room, presentationName, presentationFile, "FAILED_CONVERT_FORMAT")
documentConversionService.processDocument(uploadedPres)
test123.testtest();
}
}
@ -401,143 +127,8 @@ class PresentationService {
def roomDirectory = {conf, room ->
return new File(presentationDir + File.separatorChar + conf + File.separatorChar + room)
}
public boolean convertPage(File presentationFile, int page) {
PageConverter converter = new Pdf2SwfPageConverter()
converter.setSwfToolsDir(swfToolsDir)
File output = new File(presentationFile.getParent() + File.separatorChar + "slide-" + page + ".swf")
if (! converter.convert(presentationFile, output, page)) {
log.info "cannot create ${output.absolutePath}"
println "cannot create ${output.absolutePath}"
convertPageAsAnImage(presentationFile, output, page)
} else {
println "The size of the swf file is " + output.size()
// If the resulting swf file is greater than 500K, it probably contains a lot of objects
// that it becomes very slow to render on the client. Take an image snapshot instead and
// use it to generate the SWF file. (ralam Sept 2, 2009)
if (output.size() > 500000) {
convertPageAsAnImage(presentationFile, output, page)
}
}
// If all fails, generate a blank slide.
if (! output.exists()) {
println "Creating blank slide for ${output.absolutePath}"
generateBlankSlide(output.getAbsolutePath())
}
return true
}
private boolean convertPageAsAnImage(File presentationFile, File output, int page) {
PageExtractor extractor = new GhostscriptPageExtractor()
extractor.setGhostscriptExec(ghostScriptExec)
extractor.setNoPdfMarkWorkaround(noPdfMarkWorkaround)
def tempDir = new File(presentationFile.parent + File.separatorChar + "temp")
tempDir.mkdir()
File tempPdfFile = new File(tempDir.absolutePath + File.separator + "temp-${page}.pdf")
if (extractor.extractPage(presentationFile, tempPdfFile, page)) {
log.info "created using ghostscript ${tempPdfFile.absolutePath}"
println "created using ghostscript ${tempPdfFile.absolutePath}"
File tempPngFile = new File(tempDir.getAbsolutePath() + "/temp-${page}.png")
PageConverter imConverter = new ImageMagickPageConverter()
imConverter.setImageMagickDir(imageMagickDir)
if (imConverter.convert(tempPdfFile, tempPngFile, 1)) {
log.info "created using imagemagick ${tempPngFile.absolutePath}"
println "created using imagemagick ${tempPngFile.absolutePath}"
PageConverter pngConverter = new Png2SwfPageConverter()
pngConverter.setSwfToolsDir(swfToolsDir)
if (pngConverter.convert(tempPngFile, output, 1)) {
log.info "converted ${tempPngFile.absolutePath} to ${output.absolutePath} "
println "converted ${tempPngFile.absolutePath} to ${output.absolutePath}"
}
}
}
}
private void generateBlankSlide(String dest) {
File slide = new File(dest);
FileCopyUtils.copy(new File(BLANK_SLIDE), slide);
}
private void sendConvertErrorMessage(String conference, String room, String presName, File presentationFile, String returnCode) {
def msg = new HashMap()
msg.put("room", room)
msg.put("returnCode", returnCode)
msg.put("presentationName", presName)
log.debug "Failed to convert $presentationFile.absolutePath to presentation file : " + returnCode
println "Failed to convert $presentationFile.absolutePath to presentation file : " + returnCode
sendJmsMessage(msg)
}
private void sendConversionUpdateMessage(String conference, String room, String presName, int totalSlides, int slidesCompleted) {
def msg = new HashMap()
msg.put("room", room)
msg.put("returnCode", "CONVERT")
msg.put("presentationName", presName)
msg.put("totalSlides", new Integer(totalSlides))
msg.put("slidesCompleted", new Integer(slidesCompleted))
sendJmsMessage(msg)
}
private void sendCreatingThumbnailsUpdateMessage(String conference, String room, String presName) {
def msg = new HashMap()
msg.put("room", room)
msg.put("returnCode", "THUMBNAILS")
msg.put("presentationName", presName)
sendJmsMessage(msg)
}
private void sendConversionCompletedMessage(String conference, String room, String presName, int numberOfPages) {
String xml = generateUploadedPresentationInfo(conference, room, presName, numberOfPages)
println xml
def msg = new HashMap()
msg.put("room", room)
msg.put("returnCode", "SUCCESS")
msg.put("presentationName", presName)
msg.put("message", xml)
log.debug "Sending presentation conversion success for ${room} ${presName}."
sendJmsMessage(msg)
log.debug "Send another success message...looks like bbb-apps at Red5 sometimes miss the message...need to investigate"
sendJmsMessage(msg)
}
private String generateUploadedPresentationInfo(String conf, String confRoom, String presName, int numberOfPages) {
def writer = new java.io.StringWriter()
def builder = new groovy.xml.MarkupBuilder(writer)
def uploadedpresentation = builder.uploadedpresentation {
conference(id:conf, room:confRoom) {
presentation(name:presName) {
slides(count:numberOfPages) {
for (def i = 1; i <= numberOfPages; i++) {
slide(number:"${i}", name:"slide/${i}", thumb:"thumbnail/${i}")
}
}
}
}
}
return writer.toString()
}
private sendJmsMessage(HashMap message) {
def msg = message.toString()
log.debug "Send Jms message $msg"
jmsTemplate.convertAndSend(JMS_UPDATES_Q, message)
}
}
/*** Helper classes **/

View File

@ -8,10 +8,10 @@ public class GeneratedSlidesInfoHelperImp implements GeneratedSlidesInfoHelper {
def builder = new groovy.xml.MarkupBuilder(writer)
def uploadedpresentation = builder.uploadedpresentation {
conference(id:conf, room:confRoom) {
presentation(name:presName) {
slides(count:numberOfPages) {
for (def i = 1; i <= numberOfPages; i++) {
conference(id:pres.conference, room:pres.room) {
presentation(name:pres.name) {
slides(count:pres.numberOfPages) {
for (def i = 1; i <= pres.numberOfPages; i++) {
slide(number:"${i}", name:"slide/${i}", thumb:"thumbnail/${i}")
}
}

View File

@ -28,6 +28,6 @@ import org.springframework.integration.annotation.Gateway;
public interface ConversionProgressNotifier {
@Gateway(requestChannel="conversionProgressChannel")
@Gateway(requestChannel=ChannelNameConstants.conversionProgressChannel)
void sendConversionProgress(Map<String, Object> message);
}

View File

@ -0,0 +1,22 @@
package org.bigbluebutton.presentation;
public class DocumentConversionServiceGateway {
private DocumentConversionService documentConversionService;
private PresentationService presentationService;
public void convertDocument(UploadedPresentation pres) {
documentConversionService.processDocument(pres);
}
public void setDocumentConversionService(
DocumentConversionService documentConversionService) {
this.documentConversionService = documentConversionService;
}
public void setPresentationService(PresentationService presentationService) {
this.presentationService = presentationService;
System.out.println("Setting PresentationService");
presentationService.setDocumentConversionServiceGateway(this);
}
}

View File

@ -22,9 +22,11 @@
*/
package org.bigbluebutton.presentation;
import org.springframework.integration.annotation.Router;
public class FileTypeRouter {
@Router
public String route(UploadedPresentation pres) {
String fileType = pres.getFileType();

View File

@ -0,0 +1,6 @@
package org.bigbluebutton.presentation;
public interface PresentationService {
void setDocumentConversionServiceGateway(DocumentConversionServiceGateway service);
}

View File

@ -26,8 +26,11 @@ import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SupportedDocumentFilter {
private static Logger log = LoggerFactory.getLogger(SupportedDocumentFilter.class);
private ConversionProgressNotifier notifier;
public boolean isSupported(UploadedPresentation pres) {
@ -39,6 +42,7 @@ public class SupportedDocumentFilter {
boolean supported = SupportedFileTypes.isFileSupported(ext);
notifyProgressListener(supported, pres);
if (supported) {
log.info("Received supported file " + pres.getUploadedFile().getAbsolutePath());
pres.setFileType(ext);
}
return supported;

View File

@ -28,9 +28,11 @@ import org.bigbluebutton.presentation.ChannelNameConstants;
import org.bigbluebutton.presentation.PageConverter;
import org.bigbluebutton.presentation.SupportedFileTypes;
import org.bigbluebutton.presentation.UploadedPresentation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OfficeToPdfConversionService {
private static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionService.class);
/*
* Converts the Office document to Pdf.
* Returns
@ -46,6 +48,7 @@ public class OfficeToPdfConversionService {
boolean success = converter.convert(presentationFile, pdfOutput, 0);
if (success) {
log.info("Successfully converted office file to pdf.");
return makePdfTheUploadedFileAndSendForProcessing(pres, pdfOutput);
}
}

View File

@ -99,7 +99,7 @@ public class PdfToSwfSlidesGenerationService {
}
}
slideGenerated++;
sendConversionUpdateMessage(slideGenerated++, pres);
sendConversionUpdateMessage(slideGenerated, pres);
}
}

View File

@ -0,0 +1,8 @@
package org.bigbluebutton.presentation.imp;
public class Testing123 {
public void testtest() {
System.out.print("THIS IS A TEST ********");
}
}

View File

@ -37,8 +37,8 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
private static final Pattern PAGE_NUMBER_PATTERN = Pattern.compile("(.+-thumb)-([0-9]+)(.png)");
private String imageMagickDir;
private String blankThumbnail;
private String IMAGEMAGICK_DIR;
private String BLANK_THUMBNAIL;
private static String TEMP_THUMB_NAME = "temp-thumb";
@ -68,7 +68,7 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
String source = presentationFile.getAbsolutePath();
String dest = thumbsDir.getAbsolutePath() + File.separator + TEMP_THUMB_NAME + ".png";
String COMMAND = imageMagickDir + "/convert -thumbnail 150x150 " + source + " " + dest;
String COMMAND = IMAGEMAGICK_DIR + "/convert -thumbnail 150x150 " + source + " " + dest;
Process p;
try {
@ -137,7 +137,7 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
private void copyBlankThumbnail(File thumb) {
try {
FileUtils.copyFile(new File(blankThumbnail), thumb);
FileUtils.copyFile(new File(BLANK_THUMBNAIL), thumb);
} catch (IOException e) {
log.error("IOException while copying blank thumbnail.");
}
@ -151,11 +151,11 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
}
public void setImageMagickDir(String imageMagickDir) {
this.imageMagickDir = imageMagickDir;
IMAGEMAGICK_DIR = imageMagickDir;
}
public void setBlankThumbnail(String blankThumbnail) {
this.blankThumbnail = blankThumbnail;
BLANK_THUMBNAIL = blankThumbnail;
}
}