use of org.olat.fileresource.types.GlossaryResource in project openolat by klemens.
the class CourseHandler method importGlossary.
private void importGlossary(ICourse course, Identity owner) {
GlossaryManager gm = GlossaryManager.getInstance();
RepositoryEntryImportExport importExport = gm.getRepositoryImportExport(course.getCourseExportDataDir().getBasefile());
GlossaryResource resource = gm.createGlossary();
if (resource == null) {
log.error("Error adding glossary directry during repository reference import: " + importExport.getDisplayName());
return;
}
// unzip contents
VFSContainer glossaryContainer = gm.getGlossaryRootFolder(resource);
File fExportedFile = importExport.importGetExportedFile();
if (fExportedFile.exists()) {
ZipUtil.unzip(new LocalFileImpl(fExportedFile), glossaryContainer);
} else {
log.warn("The actual contents of the glossary 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 glossary reference
CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
courseConfig.setGlossarySoftKey(importedRepositoryEntry.getSoftkey());
CoreSpringFactory.getImpl(ReferenceManager.class).addReference(course, importedRepositoryEntry.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
use of org.olat.fileresource.types.GlossaryResource in project openolat by klemens.
the class GlossaryHandler 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);
GlossaryResource glossaryResource = GlossaryManager.getInstance().createGlossary();
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(glossaryResource);
// copy resources
File glossyPath = GlossaryManager.getInstance().getGlossaryRootFolder(glossaryResource).getBasefile();
FileResource.copyResource(file, filename, glossyPath);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
return re;
}
use of org.olat.fileresource.types.GlossaryResource in project openolat by klemens.
the class GlossaryHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
GlossaryResource glossaryResource = GlossaryManager.getInstance().createGlossary();
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(glossaryResource);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
return re;
}
Aggregations