Skip to content
Snippets Groups Projects
Commit fcdf5c1c authored by srosse's avatar srosse
Browse files

OO-5065: stream export of share folder in course completly

parent b06c13dc
No related branches found
No related tags found
No related merge requests found
......@@ -235,7 +235,7 @@ public class CourseExportMediaResource implements MediaResource, StreamingOutput
// export shared folder
CourseConfig config = sourceCourse.getCourseConfig();
if (config.hasCustomSharedFolder()) {
exportSharedFolder(config, sourceCourse, fExportedDataDir, zout);
exportSharedFolder(config, sourceCourse, zout);
}
// export glossary
if (config.hasGlossary()) {
......@@ -301,24 +301,20 @@ public class CourseExportMediaResource implements MediaResource, StreamingOutput
}
}
private void exportSharedFolder(CourseConfig config, PersistingCourseImpl sourceCourse, File fExportedDataDir, ZipOutputStream zout) {
File sharedFolderExportDataDir = new File(fExportedDataDir, "sharedfolder");
private void exportSharedFolder(CourseConfig config, PersistingCourseImpl sourceCourse, ZipOutputStream zout) {
try {
sharedFolderExportDataDir.mkdir();
log.info("exportToFilesystem: exporting shared folder course: {}", sourceCourse);
if (!SharedFolderManager.getInstance().exportSharedFolder(config.getSharedFolderSoftkey(), sharedFolderExportDataDir)) {
String exportPath = ICourse.EXPORTED_DATA_FOLDERNAME + "/" + "sharedfolder";
if (!SharedFolderManager.getInstance().exportSharedFolder(config.getSharedFolderSoftkey(), exportPath, zout)) {
// export failed, delete reference to shared folder in the course config
log.info("exportToFilesystem: export of shared folder failed.");
config.setSharedFolderSoftkey(CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY);
CoreSpringFactory.getImpl(CourseConfigManager.class).saveConfigTo(sourceCourse, config);
}
log.info("exportToFilesystem: exporting shared folder course done: {}", sourceCourse);
ZipUtil.addDirectoryToZip(sharedFolderExportDataDir.toPath(), ICourse.EXPORTED_DATA_FOLDERNAME, zout);
} catch (Exception e) {
log.error("", e);
} finally {
FileUtils.deleteDirsAndFiles(sharedFolderExportDataDir, true, true);
DBFactory.getInstance().commitAndCloseSession();
}
}
......
......@@ -26,6 +26,7 @@
package org.olat.modules.sharedfolder;
import java.io.File;
import java.util.zip.ZipOutputStream;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.services.webdav.servlets.RequestUtil;
......@@ -96,19 +97,17 @@ public class SharedFolderManager {
return new ZippedContainerMediaResource(exportFileName, sharedFolder, true);
}
public boolean exportSharedFolder(String sharedFolderSoftkey, File exportedDataDir) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(
sharedFolderSoftkey, false);
public boolean exportSharedFolder(String sharedFolderSoftkey, String path, ZipOutputStream zout) {
RepositoryEntry re = RepositoryManager.getInstance()
.lookupRepositoryEntryBySoftkey(sharedFolderSoftkey, false);
if (re == null) return false;
File fExportBaseDirectory = new File(exportedDataDir, "sharedfolder");
if (!fExportBaseDirectory.mkdir()) return false;
// do intermediate commit to avoid transaction timeout
DBFactory.getInstance().intermediateCommit();
// export properties
RepositoryEntryImportExport reImportExport = new RepositoryEntryImportExport(re, fExportBaseDirectory);
return reImportExport.exportDoExport();
RepositoryEntryImportExport reImportExport = new RepositoryEntryImportExport(re, null);
return reImportExport.exportDoExport(path, zout);
}
public RepositoryEntryImportExport getRepositoryImportExport(File importDataDir) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment