Search in sources :

Example 11 with RepositoryEntryImportExport

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

the class IQSELFCourseNode method exportNode.

@Override
public void exportNode(File exportDirectory, ICourse course) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    // nothing to export
    if (repositorySoftKey == null)
        return;
    // self healing
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (re == null) {
        // nothing to export, but correct the module configuration
        IQEditController.removeIQReference(getModuleConfiguration());
        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 12 with RepositoryEntryImportExport

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

the class CourseHandler method importSharedFolder.

private void importSharedFolder(ICourse course, Identity owner) {
    SharedFolderManager sfm = SharedFolderManager.getInstance();
    RepositoryEntryImportExport importExport = sfm.getRepositoryImportExport(course.getCourseExportDataDir().getBasefile());
    SharedFolderFileResource resource = sfm.createSharedFolder();
    if (resource == null) {
        log.error("Error adding file resource during repository reference import: " + importExport.getDisplayName());
    }
    // unzip contents
    VFSContainer sfContainer = sfm.getSharedFolder(resource);
    File fExportedFile = importExport.importGetExportedFile();
    if (fExportedFile.exists()) {
        ZipUtil.unzip(new LocalFileImpl(fExportedFile), sfContainer);
    } else {
        log.warn("The actual contents of the shared folder were not found in the export.");
    }
    // create repository entry
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(resource);
    RepositoryEntry importedRepositoryEntry = repositoryService.create(owner, null, importExport.getResourceName(), importExport.getDisplayName(), importExport.getDescription(), ores, 0);
    // set the new shared folder reference
    CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    courseConfig.setSharedFolderSoftkey(importedRepositoryEntry.getSoftkey());
    CoreSpringFactory.getImpl(ReferenceManager.class).addReference(importedRepositoryEntry.getOlatResource(), course, SharedFolderManager.SHAREDFOLDERREF);
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) SharedFolderManager(org.olat.modules.sharedfolder.SharedFolderManager) RepositoryService(org.olat.repository.RepositoryService) CourseConfig(org.olat.course.config.CourseConfig) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 13 with RepositoryEntryImportExport

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

the class SharedFolderManager method exportSharedFolder.

public boolean exportSharedFolder(String sharedFolderSoftkey, File exportedDataDir) {
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(sharedFolderSoftkey, false);
    if (re == null)
        return false;
    File fExportBaseDirectory = new File(exportedDataDir, "sharedfolder");
    if (!fExportBaseDirectory.mkdir())
        return false;
    // OLAT-5368: do intermediate commit to avoid transaction timeout
    // discussion intermediatecommit vs increased transaction timeout:
    // pro intermediatecommit: not much
    // pro increased transaction timeout: would fix OLAT-5368 but only move the problem
    // @TODO OLAT-2597: real solution is a long-running background-task concept...
    DBFactory.getInstance().intermediateCommit();
    // export properties
    RepositoryEntryImportExport reImportExport = new RepositoryEntryImportExport(re, fExportBaseDirectory);
    return reImportExport.exportDoExport();
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 14 with RepositoryEntryImportExport

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

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 15 with RepositoryEntryImportExport

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

the class PublishProcessTest method deployRawCourseFromZIP.

/**
 * This method copy the edtiro tree model and run structure as is during the import.
 * @param exportedCourseZIPFile
 * @param softKey
 * @param access
 * @return
 */
private RepositoryEntry deployRawCourseFromZIP(File exportedCourseZIPFile, String softKey, int access) {
    // create the course instance
    OLATResource newCourseResource = olatResourceManager.createOLATResourceInstance(CourseModule.class);
    ICourse course = CourseFactory.importCourseFromZip(newCourseResource, exportedCourseZIPFile);
    // course is now also in course cache!
    if (course == null) {
        return null;
    }
    File courseExportData = course.getCourseExportDataDir().getBasefile();
    // get the export data directory
    // create the repository entry
    RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(courseExportData);
    if (!StringHelper.containsNonWhitespace(softKey)) {
        softKey = importExport.getSoftkey();
    }
    RepositoryEntry re = repositoryService.create(importExport.getInitialAuthor(), importExport.getResourceName(), importExport.getDisplayName(), importExport.getDescription(), newCourseResource);
    // ok, continue import
    re.setSoftkey(softKey);
    // set access configuration
    re.setAccess(access);
    // save the repository entry
    re = repositoryService.update(re);
    // import groups
    course = CourseFactory.openCourseEditSession(course.getResourceableId());
    // create group management
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    // import groups
    cgm.importCourseBusinessGroups(courseExportData);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    // cleanup export data
    FileUtils.deleteDirsAndFiles(courseExportData, true, true);
    return re;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) 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