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);
}
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");
}
}
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);
}
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);
}
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);
}
Aggregations