Search in sources :

Example 1 with SharedFolderFileResource

use of org.olat.fileresource.types.SharedFolderFileResource in project OpenOLAT by OpenOLAT.

the class SharedFolderManager method createSharedFolder.

public SharedFolderFileResource createSharedFolder() {
    SharedFolderFileResource resource = new SharedFolderFileResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer.createChildContainer(FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

Example 2 with SharedFolderFileResource

use of org.olat.fileresource.types.SharedFolderFileResource 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 3 with SharedFolderFileResource

use of org.olat.fileresource.types.SharedFolderFileResource in project openolat by klemens.

the class SharedFolderManager method createSharedFolder.

public SharedFolderFileResource createSharedFolder() {
    SharedFolderFileResource resource = new SharedFolderFileResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer.createChildContainer(FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

Example 4 with SharedFolderFileResource

use of org.olat.fileresource.types.SharedFolderFileResource in project OpenOLAT by OpenOLAT.

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 5 with SharedFolderFileResource

use of org.olat.fileresource.types.SharedFolderFileResource in project OpenOLAT by OpenOLAT.

the class SharedFolderHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    SharedFolderFileResource folderResource = SharedFolderManager.getInstance().createSharedFolder();
    OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(folderResource);
    RepositoryEntry re = repositoryService.create(initialAuthor, null, SharedFolderFileResource.RESOURCE_NAME, displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryService(org.olat.repository.RepositoryService)

Aggregations

SharedFolderFileResource (org.olat.fileresource.types.SharedFolderFileResource)6 OLATResource (org.olat.resource.OLATResource)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 RepositoryService (org.olat.repository.RepositoryService)4 File (java.io.File)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 CourseConfig (org.olat.course.config.CourseConfig)2 SharedFolderManager (org.olat.modules.sharedfolder.SharedFolderManager)2 RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)2 OLATResourceManager (org.olat.resource.OLATResourceManager)2 ReferenceManager (org.olat.resource.references.ReferenceManager)2