Search in sources :

Example 6 with ProcessResult

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());
    }
}
Also used : ProcessResult(org.apache.openmeetings.util.process.ProcessResult) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) StoredFile(org.apache.openmeetings.util.StoredFile)

Example 7 with ProcessResult

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();
        }
    }
}
Also used : ProcessResult(org.apache.openmeetings.util.process.ProcessResult) File(java.io.File)

Example 8 with ProcessResult

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);
        }
    }
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) ProcessResult(org.apache.openmeetings.util.process.ProcessResult) FileUpload(org.apache.wicket.markup.html.form.upload.FileUpload) ProcessResultList(org.apache.openmeetings.util.process.ProcessResultList)

Aggregations

ProcessResult (org.apache.openmeetings.util.process.ProcessResult)8 File (java.io.File)5 IOException (java.io.IOException)2 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)2 StoredFile (org.apache.openmeetings.util.StoredFile)2 ProcessResultList (org.apache.openmeetings.util.process.ProcessResultList)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 FileUtils.copyInputStreamToFile (org.apache.commons.io.FileUtils.copyInputStreamToFile)1 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)1 FileItem (org.apache.openmeetings.db.entity.file.FileItem)1 Recording (org.apache.openmeetings.db.entity.record.Recording)1 RecordingMetaData (org.apache.openmeetings.db.entity.record.RecordingMetaData)1 OmFileHelper.getRecordingMetaData (org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData)1 Metadata (org.apache.tika.metadata.Metadata)1 ParseContext (org.apache.tika.parser.ParseContext)1 Parser (org.apache.tika.parser.Parser)1 ImageParser (org.apache.tika.parser.image.ImageParser)1