use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method deployCourseFromZIP.
/**
* Deploys a course from an exported course ZIP file. This process is unatended and
* therefore relies on some default assumptions on how to setup the entry and add
* any referenced resources to the repository.
*
* @param exportedCourseZIPFile
*/
public static RepositoryEntry deployCourseFromZIP(File exportedCourseZIPFile, String softKey, int access) {
RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(exportedCourseZIPFile);
if (!StringHelper.containsNonWhitespace(softKey)) {
softKey = importExport.getSoftkey();
}
RepositoryEntry existingEntry = repositoryManager.lookupRepositoryEntryBySoftkey(softKey, false);
if (existingEntry != null) {
log.info("RepositoryEntry with softkey " + softKey + " already exists. Course will not be deployed.");
return existingEntry;
}
RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
RepositoryEntry re = courseHandler.importResource(null, importExport.getInitialAuthor(), importExport.getDisplayName(), importExport.getDescription(), true, Locale.ENGLISH, exportedCourseZIPFile, exportedCourseZIPFile.getName());
re.setSoftkey(softKey);
repositoryService.update(re);
ICourse course = loadCourse(re);
publishCourse(course, access, false, null, Locale.ENGLISH);
return re;
}
use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode 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()) {
File file = rie.importGetExportedFile();
RepositoryHandler handlerQTI21 = RepositoryHandlerFactory.getInstance().getRepositoryHandler(ImsQTI21Resource.TYPE_NAME);
RepositoryEntry re;
if (handlerQTI21.acceptImport(file, "repo.zip").isValid()) {
re = handlerQTI21.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
getModuleConfiguration().set(IQEditController.CONFIG_KEY_TYPE_QTI, IQEditController.CONFIG_VALUE_QTI21);
} else {
RepositoryHandler handlerQTI = RepositoryHandlerFactory.getInstance().getRepositoryHandler(TestFileResource.TYPE_NAME);
re = handlerQTI.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
}
IQEditController.setIQReference(re, getModuleConfiguration());
} else {
IQEditController.removeIQReference(getModuleConfiguration());
}
}
use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.
the class VideoCourseNode 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()) {
// TODO: test
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(VideoFileResource.TYPE_NAME);
RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
VideoEditController.setVideoReference(re, getModuleConfiguration());
} else {
VideoEditController.removeVideoReference(getModuleConfiguration());
}
}
use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.
the class WikiCourseNode 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(WikiResource.TYPE_NAME);
RepositoryEntry re = handler.importResource(owner, rie.getInitialAuthor(), rie.getDisplayName(), rie.getDescription(), false, locale, rie.importGetExportedFile(), null);
WikiEditController.setWikiRepoReference(re, getModuleConfiguration());
} else {
WikiEditController.removeWikiReference(getModuleConfiguration());
}
}
use of org.olat.repository.handlers.RepositoryHandler in project OpenOLAT by OpenOLAT.
the class CourseNodeFactory method launchReferencedRepoEntryEditor.
/**
* Launch an editor for the repository entry which is referenced in the given
* course node. The editor is launched in a new tab.
*
* @param ureq
* @param node
*/
public boolean launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) {
RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
if (repositoryEntry == null) {
// do nothing
return false;
}
RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no) {
log.error("Trying to edit repository entry which has no associated editor: " + typeToEdit);
return false;
}
try {
String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, wControl);
return true;
} catch (CorruptedCourseException e) {
log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e);
return false;
}
}
Aggregations