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;
}
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);
}
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;
}
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);
}
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;
}
Aggregations