use of org.olat.course.CorruptedCourseException in project openolat by klemens.
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;
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class EditorMainController method requestForClose.
@Override
public boolean requestForClose(UserRequest ureq) {
boolean immediateClose = true;
try {
ICourse course = CourseFactory.loadCourse(ores.getResourceableId());
if (hasPublishableChanges(course)) {
doQuickPublish(ureq, course);
immediateClose = false;
}
} catch (CorruptedCourseException | NullPointerException e) {
logError("Error request on close: " + ores, e);
}
return immediateClose;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class CertificatesManagerImpl method isCertificationAllowed.
@Override
public boolean isCertificationAllowed(Identity identity, RepositoryEntry entry) {
boolean allowed = false;
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
if (config.isRecertificationEnabled()) {
Certificate certificate = getLastCertificate(identity, entry.getOlatResource().getKey());
if (certificate == null) {
allowed = true;
} else {
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
Date nextCertificationDate = getDateNextRecertification(certificate, config);
allowed = (nextCertificationDate != null ? nextCertificationDate.before(now) : false);
}
} else {
allowed = !hasCertificate(identity, entry.getOlatResource().getKey());
}
} catch (CorruptedCourseException e) {
log.error("", e);
}
return allowed;
}
Aggregations