Search in sources :

Example 1 with CleanupAfterDeliveryFileMediaResource

use of org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource in project OpenOLAT by OpenOLAT.

the class CourseHandler method getAsMediaResource.

@Override
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(res, true);
    String exportFileName = StringHelper.transformDisplayNameToFileSystemName(re.getDisplayname()) + ".zip";
    File fExportZIP = new File(WebappHelper.getTmpDir(), exportFileName);
    CourseFactory.exportCourseToZIP(res, fExportZIP, false, backwardsCompatible);
    return new CleanupAfterDeliveryFileMediaResource(fExportZIP);
}
Also used : CleanupAfterDeliveryFileMediaResource(org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 2 with CleanupAfterDeliveryFileMediaResource

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

the class CourseHandler method getAsMediaResource.

@Override
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(res, true);
    String exportFileName = StringHelper.transformDisplayNameToFileSystemName(re.getDisplayname()) + ".zip";
    File fExportZIP = new File(WebappHelper.getTmpDir(), exportFileName);
    CourseFactory.exportCourseToZIP(res, fExportZIP, false, backwardsCompatible);
    return new CleanupAfterDeliveryFileMediaResource(fExportZIP);
}
Also used : CleanupAfterDeliveryFileMediaResource(org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 3 with CleanupAfterDeliveryFileMediaResource

use of org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource in project OpenOLAT by OpenOLAT.

the class SharedFolderManager method getAsMediaResource.

public MediaResource getAsMediaResource(OLATResourceable res) {
    String exportFileName = res.getResourceableId() + ".zip";
    File fExportZIP = new File(WebappHelper.getTmpDir() + "/" + exportFileName);
    VFSContainer sharedFolder = getSharedFolder(res);
    // OLAT-5368: do intermediate commit to avoid transaction timeout
    // discussion intermediatecommit vs increased transaction timeout:
    // pro intermediatecommit: not much
    // pro increased transaction timeout: would fix OLAT-5368 but only move the problem
    // @TODO OLAT-2597: real solution is a long-running background-task concept...
    DBFactory.getInstance().intermediateCommit();
    ZipUtil.zip(sharedFolder.getItems(), new LocalFileImpl(fExportZIP), false);
    return new CleanupAfterDeliveryFileMediaResource(fExportZIP);
}
Also used : CleanupAfterDeliveryFileMediaResource(org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) File(java.io.File)

Example 4 with CleanupAfterDeliveryFileMediaResource

use of org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource in project OpenOLAT by OpenOLAT.

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;
    }
}
Also used : CleanupAfterDeliveryFileMediaResource(org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) IOException(java.io.IOException) File(java.io.File)

Example 5 with CleanupAfterDeliveryFileMediaResource

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

the class SharedFolderManager method getAsMediaResource.

public MediaResource getAsMediaResource(OLATResourceable res) {
    String exportFileName = res.getResourceableId() + ".zip";
    File fExportZIP = new File(WebappHelper.getTmpDir() + "/" + exportFileName);
    VFSContainer sharedFolder = getSharedFolder(res);
    // OLAT-5368: do intermediate commit to avoid transaction timeout
    // discussion intermediatecommit vs increased transaction timeout:
    // pro intermediatecommit: not much
    // pro increased transaction timeout: would fix OLAT-5368 but only move the problem
    // @TODO OLAT-2597: real solution is a long-running background-task concept...
    DBFactory.getInstance().intermediateCommit();
    ZipUtil.zip(sharedFolder.getItems(), new LocalFileImpl(fExportZIP), false);
    return new CleanupAfterDeliveryFileMediaResource(fExportZIP);
}
Also used : CleanupAfterDeliveryFileMediaResource(org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) File(java.io.File)

Aggregations

File (java.io.File)6 CleanupAfterDeliveryFileMediaResource (org.olat.core.gui.media.CleanupAfterDeliveryFileMediaResource)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 IOException (java.io.IOException)2