use of org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource in project openolat by klemens.
the class GlossaryManagerImpl method getAsMediaResource.
/**
* Export the glossary as a media resource. The resource name is set to the
* resources display name
*
* @param res
* @return
*/
@Override
public MediaResource getAsMediaResource(OLATResourceable res) {
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(res, false);
String exportFileName = repoEntry.getDisplayname();
// OO-135 check for special / illegal chars in filename
exportFileName = StringHelper.transformDisplayNameToFileSystemName(exportFileName);
try {
File tmpDir = new File(WebappHelper.getTmpDir());
File fExportZIP = File.createTempFile(exportFileName, ".zip", tmpDir);
VFSContainer glossaryRoot = getGlossaryRootFolder(res);
ZipUtil.zip(glossaryRoot.getItems(), new LocalFileImpl(fExportZIP), false);
return new CleanupAfterDeliveryFileMediaResource(fExportZIP);
} catch (IOException e) {
logError("Cannot export glossar: " + res, e);
return null;
}
}
Aggregations