use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class ImportRepositoryEntryController method doAnalyseUpload.
private void doAnalyseUpload() {
File uploadedFile = uploadFileEl.getUploadFile();
if (uploadedFile == null) {
// OO-1320
typeEl.setVisible(false);
selectType.setVisible(false);
uploadFileEl.reset();
importButton.setEnabled(false);
} else {
String uploadedFilename = uploadFileEl.getUploadFileName();
List<ResourceHandler> handlers = new ArrayList<>(3);
for (String type : repositoryHandlerFactory.getSupportedTypes()) {
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(type);
ResourceEvaluation eval = handler.acceptImport(uploadedFile, uploadedFilename);
if (eval != null && eval.isValid()) {
handlers.add(new ResourceHandler(handler, eval));
}
}
updateResourceInfos(handlers);
validLimitationOnType(handlers);
}
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class ImportRepositoryEntryController method doImport.
private void doImport() {
RepositoryHandler handler;
if (handlerForUploadedResources == null || handlerForUploadedResources.isEmpty()) {
handler = null;
} else if (handlerForUploadedResources.size() == 1) {
handler = handlerForUploadedResources.get(0).getHandler();
} else if (selectType.isOneSelected()) {
String type = selectType.getSelectedKey();
handler = repositoryHandlerFactory.getRepositoryHandler(type);
} else {
handler = null;
}
if (handler != null) {
String displayname = displaynameEl.getValue();
File uploadedFile = uploadFileEl.getUploadFile();
String uploadedFilename = uploadFileEl.getUploadFileName();
boolean withReferences = referencesEl.isAtLeastSelected(1);
importedEntry = handler.importResource(getIdentity(), null, displayname, "", withReferences, getLocale(), uploadedFile, uploadedFilename);
if (importedEntry == null) {
showWarning("error.import");
} else {
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_CREATE, getClass(), LoggingResourceable.wrap(importedEntry, OlatResourceableType.genRepoEntry));
repositoryManager.triggerIndexer(importedEntry);
}
}
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class JunitTestHelper method deployDemoCourse.
/**
* Deploys/imports the "Demo Course".
* @return the created RepositoryEntry
*/
public static RepositoryEntry deployDemoCourse(Identity initialAuthor) {
String displayname = "Demo-Kurs-7.1";
String description = "";
RepositoryEntry re = null;
try {
URL courseUrl = JunitTestHelper.class.getResource("file_resources/Demo-Kurs-7.1.zip");
File courseFile = new File(courseUrl.toURI());
RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
ICourse course = CourseFactory.loadCourse(re);
CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
} catch (Exception e) {
log.error("", e);
}
return re;
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class JunitTestHelper method deployBasicCourse.
/**
* Deploy a course with only a single page.
* @param initialAuthor
* @return
*/
public static RepositoryEntry deployBasicCourse(Identity initialAuthor) {
String displayname = "Basic course (" + CodeHelper.getForeverUniqueID() + ")";
String description = "A course with only a single page";
RepositoryEntry re = null;
try {
URL courseUrl = JunitTestHelper.class.getResource("file_resources/Basic_course.zip");
File courseFile = new File(courseUrl.toURI());
RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
ICourse course = CourseFactory.loadCourse(re);
CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
} catch (Exception e) {
log.error("", e);
}
return re;
}
use of org.olat.repository.handlers.RepositoryHandler in project openolat by klemens.
the class JunitTestHelper method deployCourse.
/**
* Deploy a course with only a single page.
* @param initialAuthor
* @return
*/
public static RepositoryEntry deployCourse(Identity initialAuthor, String displayname, File courseFile) {
String description = "A course";
RepositoryEntry re = null;
try {
RepositoryHandler courseHandler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(CourseModule.getCourseTypeName());
re = courseHandler.importResource(initialAuthor, null, displayname, description, true, Locale.ENGLISH, courseFile, null);
ICourse course = CourseFactory.loadCourse(re);
CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, initialAuthor, Locale.ENGLISH);
} catch (Exception e) {
log.error("", e);
}
return re;
}
Aggregations