use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class AuthorListController method doOverrideCloseResource.
private void doOverrideCloseResource(UserRequest ureq, AuthoringEntryRow row) {
try {
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(row.getResourceType());
if (handler != null) {
String businessPath = "[RepositoryEntry:" + row.getKey() + "]";
ureq.getUserSession().putEntry("override_readonly_" + row.getKey(), Boolean.TRUE);
if (!NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl())) {
tableEl.reloadData();
}
}
} catch (CorruptedCourseException e) {
logError("Course corrupted: " + row.getKey() + " (" + row.getOLATResourceable().getResourceableId() + ")", e);
showError("cif.error.corrupted");
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_8_2_0 method upgradeCourseConditions.
private boolean upgradeCourseConditions(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CONDITIONS)) {
int counter = 0;
List<RepositoryEntry> entries;
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.addResourceTypes("CourseModule");
do {
entries = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, REPO_ENTRIES_BATCH_SIZE, true);
for (RepositoryEntry entry : entries) {
try {
ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
CourseEnvironmentMapper envMapper = getCourseEnvironmentMapper(entry);
course.postImport(null, envMapper);
} catch (CorruptedCourseException e) {
log.error("Course seems corrupt: " + entry.getOlatResource().getResourceableId());
} catch (Exception e) {
log.error("Course seems highly corrupt: " + entry.getOlatResource().getResourceableId());
}
}
dbInstance.intermediateCommit();
counter += entries.size();
log.audit("Processed repository entries: " + entries.size());
} while (entries.size() == REPO_ENTRIES_BATCH_SIZE);
uhd.setBooleanDataValue(TASK_CONDITIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_11_0_6 method upgradeRecertificationDates.
private boolean upgradeRecertificationDates(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(RECERTIFICATION_DATE)) {
List<OLATResource> resources = certificatesManager.getResourceWithCertificates();
for (OLATResource resource : resources) {
if (resource == null)
continue;
try {
ICourse course = CourseFactory.loadCourse(resource);
if (course.getCourseConfig().isRecertificationEnabled()) {
processCourse(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
}
dbInstance.commitAndCloseSession();
} catch (CorruptedCourseException e) {
log.error("", e);
}
}
uhd.setBooleanDataValue(RECERTIFICATION_DATE, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class CertificateAndEfficiencyStatementListController method doLaunchCourse.
private void doLaunchCourse(UserRequest ureq, Long resourceKey) {
RepositoryEntry entry = repositoryService.loadByResourceKey(resourceKey);
if (entry == null) {
showWarning("efficiencyStatements.course.noexists");
} else if (!repositoryManager.isAllowedToLaunch(ureq, entry)) {
showWarning("efficiencyStatements.course.noaccess");
} else {
try {
String businessPath = "[RepositoryEntry:" + entry.getKey() + "]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
} catch (CorruptedCourseException e) {
logError("Course corrupted: " + entry.getKey() + " (" + entry.getResourceableId() + ")", e);
showError("cif.error.corrupted");
}
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class HomeCalendarManager method appendCourseCalendars.
private void appendCourseCalendars(UserRequest ureq, WindowControl wControl, List<KalendarRenderWrapper> calendars, Map<CalendarKey, CalendarUserConfiguration> configMap) {
if (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar()) {
// add course calendars
List<Object[]> resources = getCourses(ureq.getIdentity());
Set<OLATResource> editoredResources = getEditorGrants(ureq.getIdentity());
Set<Long> duplicates = new HashSet<>();
for (Object[] resource : resources) {
RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
if (duplicates.contains(courseEntry.getKey())) {
continue;
}
duplicates.add(courseEntry.getKey());
String role = (String) resource[1];
Long courseResourceableID = courseEntry.getOlatResource().getResourceableId();
try {
ICourse course = CourseFactory.loadCourse(courseEntry);
if (isCourseCalendarEnabled(course)) {
// calendar course aren't enabled per default but course node of type calendar are always possible
// REVIEW if (!course.getCourseEnvironment().getCourseConfig().isCalendarEnabled()) continue;
// add course calendar
KalendarRenderWrapper courseCalendarWrapper = calendarManager.getCourseCalendar(course);
boolean isPrivileged = GroupRoles.owner.name().equals(role) || editoredResources.contains(courseEntry.getOlatResource());
if (isPrivileged) {
courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
} else {
courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
}
if (role != null && (GroupRoles.owner.name().equals(role) || GroupRoles.coach.name().equals(role) || GroupRoles.participant.name().equals(role))) {
courseCalendarWrapper.setPrivateEventsVisible(true);
}
CalendarUserConfiguration config = configMap.get(courseCalendarWrapper.getCalendarKey());
if (config != null) {
courseCalendarWrapper.setConfiguration(config);
}
courseCalendarWrapper.setLinkProvider(new CourseLinkProviderController(course, Collections.singletonList(course), ureq, wControl));
calendars.add(courseCalendarWrapper);
}
} catch (CorruptedCourseException e) {
OLATResource olatResource = courseEntry.getOlatResource();
log.error("Corrupted course: " + olatResource.getResourceableTypeName() + " :: " + courseResourceableID, null);
} catch (Exception e) {
OLATResource olatResource = courseEntry.getOlatResource();
log.error("Cannor read calendar of course: " + olatResource.getResourceableTypeName() + " :: " + courseResourceableID, null);
}
}
}
}
Aggregations