Search in sources :

Example 96 with MediaResource

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

the class QuestionPoolServiceImpl method export.

@Override
public MediaResource export(List<QuestionItemShort> items, ExportFormatOptions format, Locale locale) {
    MediaResource mr = null;
    if (DefaultExportFormat.ZIP_EXPORT_FORMAT.equals(format)) {
        List<Long> keys = toKeys(items);
        List<QuestionItemFull> fullItems = questionItemDao.loadByIds(keys);
        mr = new ExportQItemsZipResource("UTF-8", locale, fullItems);
    // make a zip with all items
    } else {
        QPoolSPI selectedSp = null;
        List<QPoolSPI> sps = qpoolModule.getQuestionPoolProviders();
        for (QPoolSPI sp : sps) {
            if (sp.getTestExportFormats().contains(format)) {
                selectedSp = sp;
                break;
            }
        }
        if (selectedSp != null) {
            mr = selectedSp.exportTest(items, format, locale);
        }
    }
    return mr;
}
Also used : QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QPoolSPI(org.olat.modules.qpool.QPoolSPI) MediaResource(org.olat.core.gui.media.MediaResource)

Example 97 with MediaResource

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

the class DisplayPortraitManager method getPortraitResource.

/**
 * Get the portrait media resource by identity name (username)
 * @param identity
 * @return imageResource portrait
 */
private MediaResource getPortraitResource(String username, String portraitName) {
    MediaResource imageResource = null;
    File imgFile = getPortraitFile(username, portraitName);
    if (imgFile != null && imgFile.exists()) {
        imageResource = new FileMediaResource(imgFile);
    }
    return imageResource;
}
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 98 with MediaResource

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

the class UserAvatarMapper method handle.

@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
    MediaResource rsrc = null;
    if (relPath != null && relPath.endsWith(POSTFIX_LARGE) || relPath.endsWith(POSTFIX_SMALL)) {
        if (relPath.startsWith("/")) {
            relPath = relPath.substring(1, relPath.length());
        }
        int endKeyIndex = relPath.indexOf('/');
        if (endKeyIndex > 0) {
            String idKey = relPath.substring(0, endKeyIndex);
            Long key = Long.parseLong(idKey);
            String username = userManager.getUsername(key);
            if (useLarge) {
                rsrc = portraitManager.getBigPortraitResource(username);
            } else {
                rsrc = portraitManager.getSmallPortraitResource(username);
                if (rsrc == null) {
                    rsrc = portraitManager.getBigPortraitResource(username);
                }
            }
        }
    }
    return rsrc;
}
Also used : MediaResource(org.olat.core.gui.media.MediaResource)

Example 99 with MediaResource

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

the class TableOfContentController method doExportBinderAsPdf.

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

Example 100 with MediaResource

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

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)

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