Search in sources :

Example 26 with RepositoryEntryImportExport

use of org.olat.repository.RepositoryEntryImportExport in project openolat by klemens.

the class AbstractFeedCourseNode method importFeed.

public void importFeed(RepositoryHandler handler, File importDirectory, Identity owner, Locale locale) {
    RepositoryEntryImportExport rie = new RepositoryEntryImportExport(importDirectory, getIdent());
    if (rie.anyExportedPropertiesAvailable()) {
        RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        FeedNodeEditController.setReference(re, getModuleConfiguration());
    } else {
        FeedNodeEditController.removeReference(getModuleConfiguration());
    }
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 27 with RepositoryEntryImportExport

use of org.olat.repository.RepositoryEntryImportExport in project openolat by klemens.

the class CPCourseNode 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(ImsCPFileResource.TYPE_NAME);
        RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
        CPEditController.setCPReference(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 28 with RepositoryEntryImportExport

use of org.olat.repository.RepositoryEntryImportExport in project openolat by klemens.

the class CPCourseNode 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 29 with RepositoryEntryImportExport

use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.

the class VideoManagerImpl method getVideoExportMediaResource.

@Override
public VideoExportMediaResource getVideoExportMediaResource(RepositoryEntry repoEntry) {
    OLATResource videoResource = repoEntry.getOlatResource();
    OlatRootFolderImpl baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    // 1) dump repo entry metadata to resource folder
    LocalFolderImpl repoentryContainer = (LocalFolderImpl) VFSManager.resolveOrCreateContainerFromPath(baseContainer, DIRNAME_REPOENTRY);
    RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(repoEntry, repoentryContainer.getBasefile());
    importExport.exportDoExportProperties();
    // 2) package everything in resource folder to streaming zip resource
    VideoExportMediaResource exportResource = new VideoExportMediaResource(baseContainer, repoEntry.getDisplayname());
    return exportResource;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) OLATResource(org.olat.resource.OLATResource) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 30 with RepositoryEntryImportExport

use of org.olat.repository.RepositoryEntryImportExport in project OpenOLAT by OpenOLAT.

the class VideoManagerImpl method importFromExportArchive.

@Override
public boolean importFromExportArchive(RepositoryEntry repoEntry, VFSLeaf exportArchive) {
    OLATResource videoResource = repoEntry.getOlatResource();
    // 1) unzip archive
    VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    ZipUtil.unzip(exportArchive, baseContainer);
    exportArchive.delete();
    // 2) update metadata from the repo entry export
    LocalFolderImpl repoentryContainer = (LocalFolderImpl) baseContainer.resolve(DIRNAME_REPOENTRY);
    if (repoentryContainer != null) {
        RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(repoentryContainer.getBasefile());
        importExport.setRepoEntryPropertiesFromImport(repoEntry);
        // now delete the import folder, not used anymore
        repoentryContainer.delete();
    }
    // 3) Set poster image for repo entry
    VFSContainer masterContainer = getMasterContainer(videoResource);
    VFSLeaf posterImage = (VFSLeaf) masterContainer.resolve(FILENAME_POSTER_JPG);
    if (posterImage != null) {
        repositoryManager.setImage(posterImage, repoEntry);
    }
    return true;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResource(org.olat.resource.OLATResource) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

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