Search in sources :

Example 11 with MediaResource

use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.

the class TableOfContentController method doExportBinderAsCP.

private void doExportBinderAsCP(UserRequest ureq) {
    MediaResource resource = new ExportBinderAsCPResource(binder, ureq, getLocale());
    ureq.getDispatchResult().setResultingMediaResource(resource);
}
Also used : ExportBinderAsCPResource(org.olat.modules.portfolio.ui.export.ExportBinderAsCPResource) MediaResource(org.olat.core.gui.media.MediaResource)

Example 12 with MediaResource

use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.

the class DirectoryController method doBulkdownload.

private void doBulkdownload(UserRequest ureq) {
    MediaResource mdr = new ZippedDirectoryMediaResource(zipName, documentsDir);
    ureq.getDispatchResult().setResultingMediaResource(mdr);
}
Also used : ZippedDirectoryMediaResource(org.olat.fileresource.ZippedDirectoryMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) ZippedDirectoryMediaResource(org.olat.fileresource.ZippedDirectoryMediaResource)

Example 13 with MediaResource

use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.

the class DirectoryController method doDownload.

private void doDownload(UserRequest ureq, File file) {
    if (file.getName().endsWith(".html")) {
        previewCtrl = new SinglePageController(ureq, getWindowControl(), documentsContainer, file.getName(), false);
        listenTo(previewCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), previewCtrl.getInitialComponent(), true, file.getName());
        listenTo(cmc);
        cmc.activate();
    } else {
        MediaResource mdr = new FileMediaResource(file, true);
        ureq.getDispatchResult().setResultingMediaResource(mdr);
    }
}
Also used : SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) ZippedDirectoryMediaResource(org.olat.fileresource.ZippedDirectoryMediaResource)

Example 14 with MediaResource

use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.

the class GTAAssignedTaskController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (downloadLink == source) {
        if (taskFile.getName().endsWith(".html")) {
            doPreview(ureq);
        } else {
            MediaResource mdr = new FileMediaResource(taskFile, true);
            ureq.getDispatchResult().setResultingMediaResource(mdr);
        }
    } else if (downloadButton == source) {
        MediaResource mdr;
        if (taskFile.getName().endsWith(".html")) {
            File taskDir = gtaManager.getTasksDirectory(courseEnv, gtaNode);
            mdr = new HTMLZippedMediaResource(taskFile.getName(), taskDir);
        } else {
            mdr = new FileMediaResource(taskFile, true);
        }
        ureq.getDispatchResult().setResultingMediaResource(mdr);
    }
}
Also used : FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) File(java.io.File)

Example 15 with MediaResource

use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.

the class WikiWebServiceHelper method serve.

/**
 * exports the wiki-Resource and serves the zip file. The given
 * OLATResourceable can be the repository-entry of the wiki or the
 * businessGroup (if it is a group-wiki)
 *
 * @param wikiResource
 * @param request
 * @param response
 * @return
 */
public static Response serve(OLATResourceable wikiResource, HttpServletRequest request, HttpServletResponse response) {
    Identity ident = RestSecurityHelper.getIdentity(request);
    Translator translator = Util.createPackageTranslator(WikiMainController.class, new Locale(ident.getUser().getPreferences().getLanguage()));
    // make mediaResource
    MediaResource cpMediaResource = new WikiToCPResource(wikiResource, ident, translator);
    // use servletUtil, so file gets deleted afterwards
    ServletUtil.serveResource(request, response, cpMediaResource);
    return Response.ok().build();
}
Also used : Locale(java.util.Locale) WikiToCPResource(org.olat.modules.wiki.WikiToCPResource) Translator(org.olat.core.gui.translator.Translator) MediaResource(org.olat.core.gui.media.MediaResource) Identity(org.olat.core.id.Identity)

Aggregations

MediaResource (org.olat.core.gui.media.MediaResource)141 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)36 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)32 NotFoundMediaResource (org.olat.core.gui.media.NotFoundMediaResource)30 Identity (org.olat.core.id.Identity)18 VFSItem (org.olat.core.util.vfs.VFSItem)18 File (java.io.File)16 ArrayList (java.util.ArrayList)16 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)16 IOException (java.io.IOException)13 FileMediaResource (org.olat.core.gui.media.FileMediaResource)12 List (java.util.List)10 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)10 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)10 StringMediaResource (org.olat.core.gui.media.StringMediaResource)8 AssertException (org.olat.core.logging.AssertException)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)8 InputStream (java.io.InputStream)6 OLATResourceable (org.olat.core.id.OLATResourceable)6