Search in sources :

Example 1 with RepositoryEntryImportExport

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;
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) PortfolioService(org.olat.modules.portfolio.PortfolioService) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) IOException(java.io.IOException) File(java.io.File) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with RepositoryEntryImportExport

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());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 3 with RepositoryEntryImportExport

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());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 4 with RepositoryEntryImportExport

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();
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 5 with RepositoryEntryImportExport

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();
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Aggregations

RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)60 RepositoryEntry (org.olat.repository.RepositoryEntry)54 File (java.io.File)40 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)18 OLATResource (org.olat.resource.OLATResource)16 RepositoryService (org.olat.repository.RepositoryService)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 CourseConfig (org.olat.course.config.CourseConfig)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)4 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)4 ICourse (org.olat.course.ICourse)4 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)4 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)4 Binder (org.olat.modules.portfolio.Binder)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 ReferenceManager (org.olat.resource.references.ReferenceManager)4 XStream (com.thoughtworks.xstream.XStream)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2