More cleanup
This commit is contained in:
parent
2d3a941f70
commit
e3b850764a
@ -16,15 +16,15 @@
|
||||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.bigbluebutton.web.services
|
||||
|
||||
import java.util.concurrent.*;
|
||||
package org.bigbluebutton.web.services
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.lang.InterruptedException
|
||||
import org.bigbluebutton.presentation.DocumentConversionService
|
||||
import org.bigbluebutton.presentation.UploadedPresentation
|
||||
|
||||
class PresentationService {
|
||||
|
||||
|
||||
class PresentationService {
|
||||
|
||||
static transactional = false
|
||||
DocumentConversionService documentConversionService
|
||||
def presentationDir
|
||||
@ -34,81 +34,81 @@ class PresentationService {
|
||||
def testUploadedPresentation
|
||||
def defaultUploadedPresentation
|
||||
def presentationBaseUrl
|
||||
|
||||
def deletePresentation = {conf, room, filename ->
|
||||
def directory = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + filename)
|
||||
deleteDirectory(directory)
|
||||
}
|
||||
|
||||
def deleteDirectory = {directory ->
|
||||
log.debug "delete = ${directory}"
|
||||
/**
|
||||
* Go through each directory and check if it's not empty.
|
||||
* We need to delete files inside a directory before a
|
||||
* directory can be deleted.
|
||||
**/
|
||||
File[] files = directory.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].isDirectory()) {
|
||||
deleteDirectory(files[i])
|
||||
} else {
|
||||
files[i].delete()
|
||||
}
|
||||
}
|
||||
// Now that the directory is empty. Delete it.
|
||||
directory.delete()
|
||||
}
|
||||
|
||||
def listPresentations = {conf, room ->
|
||||
def presentationsList = []
|
||||
def directory = roomDirectory(conf, room)
|
||||
log.debug "directory ${directory.absolutePath}"
|
||||
if( directory.exists() ){
|
||||
directory.eachFile(){ file->
|
||||
System.out.println(file.name)
|
||||
if( file.isDirectory() )
|
||||
presentationsList.add( file.name )
|
||||
}
|
||||
}
|
||||
return presentationsList
|
||||
}
|
||||
|
||||
def deletePresentation = {conf, room, filename ->
|
||||
def directory = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + filename)
|
||||
deleteDirectory(directory)
|
||||
}
|
||||
|
||||
def deleteDirectory = {directory ->
|
||||
log.debug "delete = ${directory}"
|
||||
/**
|
||||
* Go through each directory and check if it's not empty.
|
||||
* We need to delete files inside a directory before a
|
||||
* directory can be deleted.
|
||||
**/
|
||||
File[] files = directory.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].isDirectory()) {
|
||||
deleteDirectory(files[i])
|
||||
} else {
|
||||
files[i].delete()
|
||||
}
|
||||
}
|
||||
// Now that the directory is empty. Delete it.
|
||||
directory.delete()
|
||||
}
|
||||
|
||||
def listPresentations = {conf, room ->
|
||||
def presentationsList = []
|
||||
def directory = roomDirectory(conf, room)
|
||||
log.debug "directory ${directory.absolutePath}"
|
||||
if( directory.exists() ){
|
||||
directory.eachFile(){ file->
|
||||
System.out.println(file.name)
|
||||
if( file.isDirectory() )
|
||||
presentationsList.add( file.name )
|
||||
}
|
||||
}
|
||||
return presentationsList
|
||||
}
|
||||
|
||||
def getPresentationDir = {
|
||||
return presentationDir
|
||||
}
|
||||
|
||||
def processUploadedPresentation = {uploadedPres ->
|
||||
}
|
||||
|
||||
def processUploadedPresentation = {uploadedPres ->
|
||||
// Run conversion on another thread.
|
||||
Timer t = new Timer(uploadedPres.getName(), false)
|
||||
|
||||
t.runAfter(1000) {
|
||||
t.runAfter(1000) {
|
||||
try {
|
||||
documentConversionService.processDocument(uploadedPres)
|
||||
} finally {
|
||||
t.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def showSlide(String conf, String room, String presentationName, String id) {
|
||||
new File(roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar + "slide-${id}.swf")
|
||||
}
|
||||
}
|
||||
|
||||
def showSlide(String conf, String room, String presentationName, String id) {
|
||||
new File(roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar + "slide-${id}.swf")
|
||||
}
|
||||
|
||||
def showPngImage(String conf, String room, String presentationName, String id) {
|
||||
new File(roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar + "pngs" + File.separatorChar + id)
|
||||
}
|
||||
|
||||
def showPresentation = {conf, room, filename ->
|
||||
new File(roomDirectory(conf, room).absolutePath + File.separatorChar + filename + File.separatorChar + "slides.swf")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def showPresentation = {conf, room, filename ->
|
||||
new File(roomDirectory(conf, room).absolutePath + File.separatorChar + filename + File.separatorChar + "slides.swf")
|
||||
}
|
||||
|
||||
def showThumbnail = {conf, room, presentationName, thumb ->
|
||||
println "Show thumbnails request for $presentationName $thumb"
|
||||
def thumbFile = roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar +
|
||||
"thumbnails" + File.separatorChar + "thumb-${thumb}.png"
|
||||
log.debug "showing $thumbFile"
|
||||
|
||||
new File(thumbFile)
|
||||
println "Show thumbnails request for $presentationName $thumb"
|
||||
def thumbFile = roomDirectory(conf, room).absolutePath + File.separatorChar + presentationName + File.separatorChar +
|
||||
"thumbnails" + File.separatorChar + "thumb-${thumb}.png"
|
||||
log.debug "showing $thumbFile"
|
||||
|
||||
new File(thumbFile)
|
||||
}
|
||||
|
||||
def showTextfile = {conf, room, presentationName, textfile ->
|
||||
@ -118,19 +118,19 @@ class PresentationService {
|
||||
log.debug "showing $txt"
|
||||
|
||||
new File(txt)
|
||||
}
|
||||
|
||||
def numberOfThumbnails = {conf, room, name ->
|
||||
def thumbDir = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + name + File.separatorChar + "thumbnails")
|
||||
thumbDir.listFiles().length
|
||||
}
|
||||
|
||||
def numberOfThumbnails = {conf, room, name ->
|
||||
def thumbDir = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + name + File.separatorChar + "thumbnails")
|
||||
thumbDir.listFiles().length
|
||||
}
|
||||
|
||||
def numberOfTextfiles = {conf, room, name ->
|
||||
log.debug roomDirectory(conf, room).absolutePath + File.separatorChar + name + File.separatorChar + "textfiles"
|
||||
def textfilesDir = new File(roomDirectory(conf, room).absolutePath + File.separatorChar + name + File.separatorChar + "textfiles")
|
||||
textfilesDir.listFiles().length
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
def roomDirectory = {conf, room ->
|
||||
return new File(presentationDir + File.separatorChar + conf + File.separatorChar + room)
|
||||
}
|
||||
@ -160,20 +160,20 @@ 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")
|
||||
"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 **/
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.File;
|
||||
class PngFilter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
return (name.endsWith(".png"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*** Helper classes **/
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.File;
|
||||
class PngFilter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
return (name.endsWith(".png"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user