Search in sources :

Example 41 with LocalFileImpl

use of org.olat.core.util.vfs.LocalFileImpl in project openolat by klemens.

the class PdfExternalExtractor method extract.

@Override
public void extract(VFSLeaf document, File bufferFile) throws IOException, DocumentAccessException {
    if (!(document instanceof LocalFileImpl)) {
        log.warn("Can only index local file");
        return;
    }
    List<String> cmds = new ArrayList<String>();
    cmds.add(searchModule.getPdfExternalIndexerCmd());
    cmds.add(((LocalFileImpl) document).getBasefile().getAbsolutePath());
    cmds.add(bufferFile.getAbsolutePath());
    CountDownLatch doneSignal = new CountDownLatch(1);
    ProcessWorker worker = new ProcessWorker(cmds, doneSignal);
    worker.start();
    try {
        doneSignal.await(3000, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        log.error("", e);
    }
    worker.destroyProcess();
}
Also used : ArrayList(java.util.ArrayList) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 42 with LocalFileImpl

use of org.olat.core.util.vfs.LocalFileImpl in project openolat by klemens.

the class ScormAssessmentManager method getSequencerModel.

/**
 * Load the SequencerModel
 * @param username
 * @param courseEnv
 * @param node
 * @return can be null if the user hasn't visited the course
 */
public SequencerModel getSequencerModel(String username, CourseEnvironment courseEnv, ScormCourseNode node) {
    VFSContainer scoDirectory = ScormDirectoryHelper.getScoDirectory(username, courseEnv, node);
    if (scoDirectory == null)
        return null;
    VFSItem reloadSettingsFile = scoDirectory.resolve(RELOAD_SETTINGS_FILE);
    if (reloadSettingsFile instanceof LocalFileImpl) {
        LocalFileImpl fileImpl = (LocalFileImpl) reloadSettingsFile;
        return new SequencerModel(fileImpl.getBasefile(), null);
    } else if (reloadSettingsFile != null) {
        throw new OLATRuntimeException(this.getClass(), "Programming error, SCORM results must be file based", null);
    }
    return null;
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) SequencerModel(org.olat.modules.scorm.server.servermodels.SequencerModel) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl)

Example 43 with LocalFileImpl

use of org.olat.core.util.vfs.LocalFileImpl in project openolat by klemens.

the class ScormExportManager method collectData.

private void collectData(String username, VFSContainer scoFolder, ScormExportVisitor visitor) {
    List<VFSItem> contents = scoFolder.getItems(new XMLFilter());
    for (VFSItem file : contents) {
        ScoDocument document = new ScoDocument(null);
        try {
            if (file instanceof LocalFileImpl) {
                document.loadDocument(((LocalFileImpl) file).getBasefile());
            } else {
                logger.warn("Cannot use this type of VSFItem to load a SCO Datamodel: " + file.getClass().getName(), null);
                continue;
            }
            String[][] scoModel = document.getScoModel();
            ScoDatas parsedDatas = parseScoModel(file.getName(), username, scoModel);
            visitor.visit(parsedDatas);
        } catch (Exception e) {
            logger.error("Cannot load a SCO Datamodel", e);
        }
    }
}
Also used : VFSItem(org.olat.core.util.vfs.VFSItem) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument)

Example 44 with LocalFileImpl

use of org.olat.core.util.vfs.LocalFileImpl in project openolat by klemens.

the class VideoManagerImpl method hasVideoFile.

@Override
public boolean hasVideoFile(OLATResource videoResource) {
    VFSContainer masterContainer = getMasterContainer(videoResource);
    LocalFileImpl videoFile = (LocalFileImpl) masterContainer.resolve(FILENAME_VIDEO_MP4);
    return videoFile != null && videoFile.exists();
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl)

Example 45 with LocalFileImpl

use of org.olat.core.util.vfs.LocalFileImpl in project openolat by klemens.

the class VideoManagerImpl method getVideoFile.

/**
 * get the File of the videoresource
 */
@Override
public File getVideoFile(OLATResource videoResource) {
    VFSContainer masterContainer = getMasterContainer(videoResource);
    LocalFileImpl videoFile = (LocalFileImpl) masterContainer.resolve(FILENAME_VIDEO_MP4);
    return videoFile.getBasefile();
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl)

Aggregations

LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)126 File (java.io.File)70 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)52 VFSContainer (org.olat.core.util.vfs.VFSContainer)32 Size (org.olat.core.commons.services.image.Size)22 ArrayList (java.util.ArrayList)20 IOException (java.io.IOException)18 VFSItem (org.olat.core.util.vfs.VFSItem)18 RandomAccessFile (java.io.RandomAccessFile)14 FileChannel (java.nio.channels.FileChannel)12 FileChannelWrapper (org.jcodec.common.FileChannelWrapper)12 CannotGenerateThumbnailException (org.olat.core.commons.services.thumbnail.CannotGenerateThumbnailException)12 OLATResource (org.olat.resource.OLATResource)10 Date (java.util.Date)8 MP4Demuxer (org.jcodec.containers.mp4.demuxer.MP4Demuxer)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 VFSCPNamedItem (org.olat.ims.cp.ui.VFSCPNamedItem)8 BufferedImage (java.awt.image.BufferedImage)6 InputStream (java.io.InputStream)6