Search in sources :

Example 46 with LocalFolderImpl

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

the class ImsCPRepositoryIndexer method doIndex.

/**
 * @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
 */
@Override
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    if (isLogDebugEnabled())
        logDebug("Analyse IMS CP RepositoryEntry...");
    resourceContext.setDocumentType(TYPE);
    if (repositoryEntry != null) {
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(repositoryEntry.getOlatResource());
        if (cpRoot != null) {
            SearchResourceContext cpContext = new SearchResourceContext(resourceContext);
            VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
            doIndexVFSContainer(cpContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 47 with LocalFolderImpl

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

the class CPCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
    indexWriter.addDocument(document);
    RepositoryEntry re = CPEditController.getCPReference(courseNode.getModuleConfiguration(), false);
    if (re != null) {
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
        if (cpRoot != null) {
            VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
            doIndexVFSContainer(courseNodeResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 48 with LocalFolderImpl

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

the class ScormDirectoryHelper method getScormRootFolder.

/**
 * Return the SCORM Root folder
 */
public static VFSContainer getScormRootFolder() {
    VFSContainer canonicalRoot = new LocalFolderImpl(new File(FolderConfig.getCanonicalRoot()));
    VFSContainer scormContainer = (VFSContainer) canonicalRoot.resolve("scorm");
    if (scormContainer == null) {
        scormContainer = canonicalRoot.createChildContainer("scorm");
    }
    return scormContainer;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 49 with LocalFolderImpl

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

the class VideoManagerImpl method getVideoExportMediaResource.

@Override
public VideoExportMediaResource getVideoExportMediaResource(RepositoryEntry repoEntry) {
    OLATResource videoResource = repoEntry.getOlatResource();
    OlatRootFolderImpl baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    // 1) dump repo entry metadata to resource folder
    LocalFolderImpl repoentryContainer = (LocalFolderImpl) VFSManager.resolveOrCreateContainerFromPath(baseContainer, DIRNAME_REPOENTRY);
    RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(repoEntry, repoentryContainer.getBasefile());
    importExport.exportDoExportProperties();
    // 2) package everything in resource folder to streaming zip resource
    VideoExportMediaResource exportResource = new VideoExportMediaResource(baseContainer, repoEntry.getDisplayname());
    return exportResource;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) OLATResource(org.olat.resource.OLATResource) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 50 with LocalFolderImpl

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

the class VideoTranscodingJob method forkTranscodingProcess.

/**
 * Internal helper to fork a process with handbrake and read the values from the process
 * @param videoTranscoding
 * @return true: all ok; false: an error happend along the way
 */
private boolean forkTranscodingProcess(VideoTranscoding videoTranscoding) {
    OLATResource video = videoTranscoding.getVideoResource();
    VideoModule videoModule = CoreSpringFactory.getImpl(VideoModule.class);
    VideoManager videoManager = CoreSpringFactory.getImpl(VideoManager.class);
    File masterFile = videoManager.getVideoFile(video);
    File transcodingFolder = ((LocalFolderImpl) videoManager.getTranscodingContainer(video)).getBasefile();
    File transcodedFile = new File(transcodingFolder, Integer.toString(videoTranscoding.getResolution()) + masterFile.getName());
    // mark this as beeing transcoded by this local transcoder
    videoTranscoding.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL);
    videoTranscoding = videoManager.updateVideoTranscoding(videoTranscoding);
    String resolution = Integer.toString(videoTranscoding.getResolution());
    // Legacy fallback
    String profile = "Normal";
    if (resolutionsWithProfile.contains(resolution)) {
        profile = videoModule.getVideoTranscodingProfile() + " " + resolution + "p30";
    }
    ArrayList<String> cmd = new ArrayList<>();
    String tasksetConfig = videoModule.getTranscodingTasksetConfig();
    if (tasksetConfig != null && !"Mac OS X".equals(System.getProperty("os.name"))) {
        cmd.add("taskset");
        cmd.add("-c");
        cmd.add(tasksetConfig);
    }
    cmd.add("HandBrakeCLI");
    cmd.add("-i");
    cmd.add(masterFile.getAbsolutePath());
    cmd.add("-o");
    cmd.add(transcodedFile.getAbsolutePath());
    // add video infos to header for web "fast start"
    cmd.add("--optimize");
    cmd.add("--preset");
    cmd.add(profile);
    cmd.add("--height");
    cmd.add(resolution);
    // do not crop
    cmd.add("--crop");
    cmd.add("0:0:0:0");
    Process process = null;
    try {
        if (log.isDebug()) {
            log.debug(cmd.toString());
        }
        ProcessBuilder builder = new ProcessBuilder(cmd);
        process = builder.start();
        return updateVideoTranscodingFromProcessOutput(process, videoTranscoding, transcodedFile);
    } catch (IOException e) {
        log.error("Could not spawn convert sub process", e);
        return false;
    } finally {
        if (process != null) {
            process.destroy();
            process = null;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource) IOException(java.io.IOException) VideoManager(org.olat.modules.video.VideoManager) File(java.io.File) VideoModule(org.olat.modules.video.VideoModule) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)122 File (java.io.File)82 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 VFSItem (org.olat.core.util.vfs.VFSItem)38 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)30 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 Document (org.dom4j.Document)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)8 OLATResource (org.olat.resource.OLATResource)8 Date (java.util.Date)6 Document (org.apache.lucene.document.Document)6 Element (org.dom4j.Element)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)6 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)6 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6