use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.
the class BinderTemplateHandler method importResource.
@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
try {
// create resource
OLATResource resource = portfolioService.createBinderTemplateResource();
OlatRootFolderImpl fResourceRootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
File fResourceFileroot = fResourceRootContainer.getBasefile();
File zipRoot = new File(fResourceFileroot, FileResourceManager.ZIPDIR);
FileResource.copyResource(file, filename, zipRoot);
// create repository entry
RepositoryEntry re = repositoryService.create(initialAuthor, initialAuthorAlt, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
// import binder
File binderFile = new File(zipRoot, BinderTemplateResource.BINDER_XML);
Binder transientBinder = BinderXStream.fromPath(binderFile.toPath());
File posterImage = null;
if (StringHelper.containsNonWhitespace(transientBinder.getImagePath())) {
posterImage = new File(zipRoot, transientBinder.getImagePath());
}
portfolioService.importBinder(transientBinder, re, posterImage);
RepositoryEntryImportExport rei = new RepositoryEntryImportExport(re, zipRoot);
if (rei.anyExportedPropertiesAvailable()) {
re = rei.importContent(re, fResourceRootContainer.createChildContainer("media"));
}
// delete the imported files
FileUtils.deleteDirsAndFiles(zipRoot, true, true);
return re;
} catch (IOException e) {
log.error("", e);
return null;
}
}
use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.
the class PortfolioCourseNode method importNode.
@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
if (withReferences && rie.anyExportedPropertiesAvailable()) {
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(EPTemplateMapResource.TYPE_NAME);
RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
if (re != null) {
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
PortfolioStructure map = ePFMgr.loadPortfolioStructure(re.getOlatResource());
PortfolioCourseNodeEditController.setReference(re, map, getModuleConfiguration());
} else {
PortfolioCourseNodeEditController.removeReference(getModuleConfiguration());
}
} else {
PortfolioCourseNodeEditController.removeReference(getModuleConfiguration());
}
}
use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.
the class ScormCourseNode method importNode.
@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
if (withReferences && rie.anyExportedPropertiesAvailable()) {
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(ScormCPFileResource.TYPE_NAME);
RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
ScormEditController.setScormCPReference(re, getModuleConfiguration());
} else {
CPEditController.removeCPReference(getModuleConfiguration());
}
}
use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.
the class ScormCourseNode method exportNode.
@Override
public void exportNode(File exportDirectory, ICourse course) {
RepositoryEntry re = CPEditController.getCPReference(getModuleConfiguration(), false);
if (re == null)
return;
File fExportDirectory = new File(exportDirectory, getIdent());
fExportDirectory.mkdirs();
RepositoryEntryImportExport reie = new RepositoryEntryImportExport(re, fExportDirectory);
reie.exportDoExport();
}
use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.
the class VideoCourseNode method exportNode.
@Override
public void exportNode(File exportDirectory, ICourse course) {
RepositoryEntry re = VideoEditController.getVideoReference(getModuleConfiguration(), false);
if (re == null)
return;
File fExportDirectory = new File(exportDirectory, getIdent());
fExportDirectory.mkdirs();
RepositoryEntryImportExport reie = new RepositoryEntryImportExport(re, fExportDirectory);
reie.exportDoExport();
}
Aggregations