use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class ProjectDetailsDisplayController method doFileDelivery.
private void doFileDelivery(UserRequest ureq, final Project project, final CourseEnvironment courseEnv, final CourseNode cNode) {
// Create a mapper to deliver the auto-download of the file. We have to
// create a dedicated mapper here
// and can not reuse the standard briefcase way of file delivering, some
// very old fancy code
// Mapper is cleaned up automatically by basic controller
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(projectBrokerManager.getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
VFSItem item = rootFolder.resolve(project.getAttachmentFileName());
if (item instanceof VFSLeaf) {
VFSLeaf attachment = (VFSLeaf) item;
MediaResource resource = new VFSMediaResource(attachment);
ureq.getDispatchResult().setResultingMediaResource(resource);
}
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class BinderPageListController method doExportBinderAsCP.
private void doExportBinderAsCP(UserRequest ureq) {
MediaResource resource = new ExportBinderAsCPResource(binder, ureq, getLocale());
ureq.getDispatchResult().setResultingMediaResource(resource);
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class QuestionListController method doExecuteExport.
private void doExecuteExport(UserRequest ureq, StepsRunContext runContext) {
ExportFormatOptions format = (ExportFormatOptions) runContext.get("format");
@SuppressWarnings("unchecked") List<QuestionItemShort> items = (List<QuestionItemShort>) runContext.get("itemsToExport");
MediaResource mr = qpoolService.export(items, format, getLocale());
if (mr != null) {
ureq.getDispatchResult().setResultingMediaResource(mr);
}
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class FileArtefactDetailsController method initFileView.
private void initFileView(VFSItem file, UserRequest ureq) {
vC = createVelocityContainer("fileDetails");
DownloadComponent downlC = new DownloadComponent("download", (VFSLeaf) file);
vC.put("download", downlC);
vC.contextPut("filename", fArtefact.getFilename());
if (file instanceof MetaTagged) {
MetaInfo meta = ((MetaTagged) file).getMetaInfo();
vC.contextPut("meta", meta);
// show a preview thumbnail if possible
if (meta.isThumbnailAvailable()) {
VFSLeaf thumb = meta.getThumbnail(200, 200, false);
if (thumb != null) {
mr = new VFSMediaResource(thumb);
}
if (mr != null) {
String thumbMapper = registerMapper(ureq, new Mapper() {
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
return mr;
}
});
vC.contextPut("thumbMapper", thumbMapper);
}
}
}
if (!readOnlyMode) {
// allow to delete
delLink = LinkFactory.createLink("delete.file", vC, this);
delLink.setUserObject(file);
}
viewPanel.setContent(vC);
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class RepositoryEntryRuntimeController method doDownload.
private void doDownload(UserRequest ureq) {
if (handler == null) {
StringBuilder sb = new StringBuilder(translate("error.download"));
sb.append(": No download handler for repository entry: ").append(re.getKey());
showError(sb.toString());
return;
}
RepositoryEntry entry = repositoryService.loadByKey(re.getKey());
OLATResourceable ores = entry.getOlatResource();
if (ores == null) {
showError("error.download");
return;
}
boolean isAlreadyLocked = handler.isLocked(ores);
try {
lockResult = handler.acquireLock(ores, ureq.getIdentity());
if (lockResult == null || (lockResult != null && lockResult.isSuccess() && !isAlreadyLocked)) {
MediaResource mr = handler.getAsMediaResource(ores, false);
if (mr != null) {
repositoryService.incrementDownloadCounter(entry);
ureq.getDispatchResult().setResultingMediaResource(mr);
} else {
showError("error.export");
fireEvent(ureq, Event.FAILED_EVENT);
}
} else if (lockResult != null && lockResult.isSuccess() && isAlreadyLocked) {
String fullName = userManager.getUserDisplayName(lockResult.getOwner());
showInfo("warning.course.alreadylocked.bySameUser", fullName);
// invalid lock, it was already locked
lockResult = null;
} else {
String fullName = userManager.getUserDisplayName(lockResult.getOwner());
showInfo("warning.course.alreadylocked", fullName);
}
} finally {
if ((lockResult != null && lockResult.isSuccess() && !isAlreadyLocked)) {
handler.releaseLock(lockResult);
lockResult = null;
}
}
}
Aggregations