use of org.apache.openmeetings.util.process.ProcessResult in project openmeetings by apache.
the class FileProcessor method processFile.
private void processFile(FileItem f, StoredFile sf, File temp, ProcessResultList logs) throws Exception {
try {
File file = f.getFile(sf.getExt());
log.debug("writing file to: {}", file);
if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
logs.add(new ProcessResult("Unable to create parent for file: " + file.getCanonicalPath()));
return;
}
switch(f.getType()) {
case Presentation:
log.debug("Office document: {}", file);
copyFile(temp, file);
// convert to pdf, thumbs, swf and xml-description
docConverter.convertPDF(f, sf, logs);
break;
case PollChart:
// NOT implemented yet
log.debug("uploaded chart file");
break;
case Image:
// convert it to JPG
log.debug("##### convert it to JPG: ");
copyFile(temp, file);
imageConverter.convertImage(f, sf);
break;
case Video:
copyFile(temp, file);
videoConverter.convertVideo(f, sf.getExt(), logs);
break;
default:
break;
}
} finally {
f = fileDao.update(f);
log.debug("fileId: {}", f.getId());
}
}
use of org.apache.openmeetings.util.process.ProcessResult in project openmeetings by apache.
the class BaseConverter method postProcess.
protected void postProcess(Recording r, String mp4path, ProcessResultList logs, List<File> waveFiles) throws IOException {
convertToPng(r, mp4path, logs);
updateDuration(r);
r.setStatus(Recording.Status.PROCESSED);
logDao.delete(r);
for (ProcessResult res : logs.getJobs()) {
logDao.add("generateFFMPEG", r, res);
}
// Delete Wave Files
for (File audio : waveFiles) {
if (audio.exists()) {
audio.delete();
}
}
}
use of org.apache.openmeetings.util.process.ProcessResult in project openmeetings by apache.
the class UploadDialog method onSubmit.
@Override
protected void onSubmit(AjaxRequestTarget target) {
List<FileUpload> ful = uploadField.getFileUploads();
if (ful != null) {
boolean clean = cleanWb.getModelObject();
for (FileUpload fu : ful) {
FileItem f = new FileItem();
f.setSize(fu.getSize());
f.setName(fu.getClientFileName());
BaseFileItem parent = roomFiles.getLastSelected();
if (parent == null || !(parent instanceof FileItem)) {
f.setOwnerId(getUserId());
} else {
f.setRoomId(parent.getRoomId());
f.setOwnerId(parent.getOwnerId());
f.setGroupId(parent.getGroupId());
if (parent.getId() != null) {
f.setParentId(BaseFileItem.Type.Folder == parent.getType() ? parent.getId() : parent.getParentId());
}
}
f.setInsertedBy(getUserId());
try {
ProcessResultList logs = processor.processFile(f, fu.getInputStream());
for (ProcessResult res : logs.getJobs()) {
fileLogDao.add(res.getProcess(), f, res);
}
room.getSidebar().updateFiles(target);
if (logs.hasError()) {
form.error(getString("convert.errors.file"));
} else {
if (toWb.getModelObject()) {
room.getWb().sendFileToWb(f, clean);
clean = false;
}
}
} catch (Exception e) {
form.error(e.getMessage());
} finally {
fu.closeStreams();
fu.delete();
}
}
if (form.hasError()) {
onError(target);
} else {
close(target, null);
}
}
}
Aggregations