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

Merge remote-tracking branch 'origin/OpenOLAT_15.2' into OpenOLAT_15.3

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