Search in sources :

Example 56 with MediaResource

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

the class QTI21AssessmentRunController method doDownloadSignature.

private void doDownloadSignature(UserRequest ureq) {
    MediaResource resource = null;
    if (courseNode instanceof IQTESTCourseNode) {
        IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
        AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
        AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
        File signature = qtiService.getAssessmentResultSignature(session);
        if (signature.exists()) {
            resource = new DownloadeableMediaResource(signature);
        }
    }
    if (resource == null) {
        resource = new NotFoundMediaResource();
    }
    ureq.getDispatchResult().setResultingMediaResource(resource);
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

Example 57 with MediaResource

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

the class IQIdentityListCourseNodeController method doExportResults.

private void doExportResults(UserRequest ureq) {
    List<Identity> identities = getIdentities();
    if (identities != null && !identities.isEmpty()) {
        MediaResource resource;
        CourseEnvironment courseEnv = getCourseEnvironment();
        if (isTestQTI21()) {
            resource = new QTI21ResultsExportMediaResource(courseEnv, identities, (IQTESTCourseNode) courseNode, getLocale());
        } else {
            resource = new QTI12ResultsExportMediaResource(courseEnv, getLocale(), identities, (IQTESTCourseNode) courseNode);
        }
        ureq.getDispatchResult().setResultingMediaResource(resource);
    } else {
        showWarning("error.no.assessed.users");
    }
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) Identity(org.olat.core.id.Identity) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource)

Example 58 with MediaResource

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

the class OAuthAuthenticationController method redirect.

private void redirect(UserRequest ureq, OAuthSPI provider) {
    HttpSession session = ureq.getHttpReq().getSession();
    MediaResource redirectResource = new OAuthResource(provider, session);
    ureq.getDispatchResult().setResultingMediaResource(redirectResource);
}
Also used : HttpSession(javax.servlet.http.HttpSession) MediaResource(org.olat.core.gui.media.MediaResource) OAuthResource(org.olat.login.oauth.OAuthResource)

Example 59 with MediaResource

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

the class MessageListController method doDeliverAttachment.

private void doDeliverAttachment(UserRequest ureq, String cmd) {
    MediaResource res = null;
    try {
        int index = cmd.lastIndexOf("_");
        String attachmentPosition = cmd.substring(cmd.indexOf("_") + 1, index);
        String messageKey = cmd.substring(index + 1);
        int position = Integer.parseInt(attachmentPosition);
        Long key = new Long(messageKey);
        for (MessageView view : backupViews) {
            if (view.getKey().equals(key)) {
                List<VFSItem> attachments = view.getAttachments();
                // velocity counter start with 1
                VFSLeaf attachment = (VFSLeaf) attachments.get(position - 1);
                VFSMediaResource fileResource = new VFSMediaResource(attachment);
                // prevent XSS attack
                fileResource.setDownloadable(true);
                res = fileResource;
            }
        }
    } catch (Exception e) {
        logError("Cannot deliver message attachment", e);
    }
    if (res == null) {
        res = new NotFoundMediaResource();
    }
    ureq.getDispatchResult().setResultingMediaResource(res);
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSItem(org.olat.core.util.vfs.VFSItem) MediaResource(org.olat.core.gui.media.MediaResource) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource)

Example 60 with MediaResource

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

the class MapperDispatcher method execute.

/**
 * @param hreq
 * @param hres
 */
@Override
public void execute(HttpServletRequest hreq, HttpServletResponse hres) throws IOException {
    String pathInfo = DispatcherModule.subtractContextPath(hreq);
    // e.g. non-cacheable: 	23423/bla/blu.html
    // e.g. cacheable: 		my.mapper.path/bla/blu.html
    String subInfo = pathInfo.substring(DispatcherModule.PATH_MAPPED.length());
    int slashPos = subInfo.indexOf('/');
    String smappath;
    if (slashPos == -1) {
        smappath = subInfo;
    } else {
        smappath = subInfo.substring(0, slashPos);
    }
    // legacy???
    DBFactory.getInstance().commitAndCloseSession();
    // e.g. non-cacheable: 	23423
    // e.g. cacheable: 		my.mapper.path
    UserSession usess = CoreSpringFactory.getImpl(UserSessionManager.class).getUserSession(hreq);
    Mapper m = CoreSpringFactory.getImpl(MapperService.class).getMapperById(usess, smappath);
    if (m == null) {
        // an anonymous mapper?
        m = CoreSpringFactory.getImpl(MapperService.class).getMapperById(null, smappath);
        if (m == null) {
            logWarn("Call to mapped resource, but mapper does not exist for path::" + smappath, null);
            DispatcherModule.sendNotFound(pathInfo, hres);
            return;
        }
    }
    String mod = slashPos > 0 ? subInfo.substring(slashPos) : "";
    if (mod.indexOf("..") != -1) {
        logWarn("Illegal mapper path::" + mod + " contains '..'", null);
        DispatcherModule.sendForbidden(pathInfo, hres);
        return;
    }
    // /bla/blu.html
    MediaResource mr = m.handle(mod, hreq);
    ServletUtil.serveResource(hreq, hres, mr);
}
Also used : UserSessionManager(org.olat.core.util.session.UserSessionManager) UserSession(org.olat.core.util.UserSession) 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