Search in sources :

Example 31 with LocalFileImpl

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

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)

Example 32 with LocalFileImpl

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

the class VideoTranscodingJob method updateStatus.

private boolean updateStatus(VideoTranscoding videoTranscoding, File transcodedFile, int exitCode) {
    VideoManager videoManager = CoreSpringFactory.getImpl(VideoManager.class);
    MovieService movieService = CoreSpringFactory.getImpl(MovieService.class);
    videoTranscoding = videoManager.getVideoTranscoding(videoTranscoding.getKey());
    Size videoSize = movieService.getSize(new LocalFileImpl(transcodedFile), VideoManagerImpl.FILETYPE_MP4);
    if (videoSize != null) {
        videoTranscoding.setWidth(videoSize.getWidth());
        videoTranscoding.setHeight(videoSize.getHeight());
    } else {
        videoTranscoding.setWidth(0);
        videoTranscoding.setHeight(0);
    }
    if (transcodedFile.exists()) {
        videoTranscoding.setSize(transcodedFile.length());
    } else {
        videoTranscoding.setSize(0);
    }
    if (exitCode == 0) {
        videoTranscoding.setStatus(VideoTranscoding.TRANSCODING_STATUS_DONE);
    } else {
        log.error("Exit code " + videoTranscoding + ":" + exitCode);
        videoTranscoding.setStatus(VideoTranscoding.TRANSCODING_STATUS_ERROR);
    }
    videoTranscoding = videoManager.updateVideoTranscoding(videoTranscoding);
    DBFactory.getInstance().commitAndCloseSession();
    return exitCode == 0;
}
Also used : MovieService(org.olat.core.commons.services.video.MovieService) Size(org.olat.core.commons.services.image.Size) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) VideoManager(org.olat.modules.video.VideoManager)

Example 33 with LocalFileImpl

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

the class ProjectEditDetailsFormController method uploadFiles.

private void uploadFiles(FileElement attachmentFileElement) {
    VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile());
    projectBrokerManager.saveAttachedFile(project, attachmentFileElement.getUploadFileName(), uploadedItem, courseEnv, courseNode);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl)

Example 34 with LocalFileImpl

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

the class FileDocumentFactoryTest method getVFSFile.

private VFSLeaf getVFSFile(String filename) {
    try {
        URL url = FileDocumentFactoryTest.class.getResource(filename);
        File file = new File(url.toURI());
        return new LocalFileImpl(file);
    } catch (URISyntaxException e) {
        log.error("", e);
        return null;
    }
}
Also used : LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URL(java.net.URL)

Example 35 with LocalFileImpl

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

the class FeedFileStorge method loadItemMedia.

/**
 * Load the media file of the item.
 *
 * @param item
 * @return
 */
public File loadItemMedia(Item item) {
    File file = null;
    Enclosure enclosure = item.getEnclosure();
    VFSContainer mediaDir = getOrCreateItemMediaContainer(item);
    if (mediaDir != null && enclosure != null) {
        VFSLeaf mediaFile = (VFSLeaf) mediaDir.resolve(enclosure.getFileName());
        if (mediaFile != null && mediaFile instanceof LocalFileImpl) {
            file = ((LocalFileImpl) mediaFile).getBasefile();
        }
    }
    return file;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) Enclosure(org.olat.modules.webFeed.Enclosure) File(java.io.File)

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