use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class QTIEditorMainController method doExportDocx.
private void doExportDocx(UserRequest ureq) {
AssessmentNode rootNode = (AssessmentNode) menuTreeModel.getRootNode();
VFSContainer editorContainer = qtiPackage.getBaseDir();
exportLatch = new CountDownLatch(1);
MediaResource mr = new QTIWordExport(rootNode, editorContainer, getLocale(), "UTF-8", exportLatch);
ureq.getDispatchResult().setResultingMediaResource(mr);
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class PageRunController method doExportBinderAsPdf.
private void doExportBinderAsPdf(UserRequest ureq) {
MediaResource resource = new ExportBinderAsPDFResource(page, ureq, getLocale());
ureq.getDispatchResult().setResultingMediaResource(resource);
}
use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.
the class CourseWebService method getRepoFileById.
/**
* Export the course
* @response.representation.200.mediaType application/zip
* @response.representation.200.doc The course as a ZIP file
* @response.representation.401.doc Not authorized to export the course
* @response.representation.404.doc The course not found
* @return It returns the <code>CourseVO</code> object representing the course.
*/
@GET
@Path("file")
@Produces({ "application/zip", MediaType.APPLICATION_OCTET_STREAM })
public Response getRepoFileById(@Context HttpServletRequest request) {
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (re == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
RepositoryHandler typeToDownload = RepositoryHandlerFactory.getInstance().getRepositoryHandler(re);
if (typeToDownload == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity identity = getIdentity(request);
boolean canDownload = re.getCanDownload() && typeToDownload.supportsDownload();
if (isAdmin(request) || RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identity, re)) {
canDownload = true;
} else if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
if (!canDownload) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
OLATResource ores = OLATResourceManager.getInstance().findResourceable(re.getOlatResource());
if (ores == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
boolean isAlreadyLocked = typeToDownload.isLocked(ores);
LockResult lockResult = null;
try {
lockResult = typeToDownload.acquireLock(ores, identity);
if (lockResult == null || (lockResult != null && lockResult.isSuccess() && !isAlreadyLocked)) {
MediaResource mr = typeToDownload.getAsMediaResource(ores, false);
if (mr != null) {
rs.incrementDownloadCounter(re);
// success
return Response.ok(mr.getInputStream()).cacheControl(cc).build();
} else {
return Response.serverError().status(Status.NO_CONTENT).build();
}
} else {
return Response.serverError().status(Status.CONFLICT).build();
}
} finally {
if ((lockResult != null && lockResult.isSuccess() && !isAlreadyLocked)) {
typeToDownload.releaseLock(lockResult);
}
}
}
use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.gui.media.MediaResource in project OpenOLAT by OpenOLAT.
the class FeedManagerImpl method createFeedFile.
@Override
public MediaResource createFeedFile(OLATResourceable ores, Identity identity, Long courseId, String nodeId) {
MediaResource media = null;
Feed feed = loadFeed(ores);
if (feed != null) {
SyndFeed rssFeed = new RSSFeed(feed, identity, courseId, nodeId);
media = new SyndFeedMediaResource(rssFeed);
}
return media;
}
Aggregations