use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
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);
}
}
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class CourseIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) {
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
if (isLogDebugEnabled())
logDebug("Analyse Course... repositoryEntry=" + repositoryEntry);
try {
RepositoryEntryStatus status = RepositoryManager.getInstance().createRepositoryEntryStatus(repositoryEntry.getStatusCode());
if (status.isClosed()) {
if (isLogDebugEnabled())
logDebug("Course not indexed because it's closed: repositoryEntry=" + repositoryEntry);
return;
}
ICourse course = CourseFactory.loadCourse(repositoryEntry);
// course.getCourseTitle(); // do not index title => index root-node
parentResourceContext.setParentContextType(TYPE);
parentResourceContext.setParentContextName(course.getCourseTitle());
doIndexCourse(parentResourceContext, course, course.getRunStructure().getRootNode(), indexWriter);
} catch (CorruptedCourseException ex) {
logWarn("Can not index repositoryEntry (" + repositoryEntry.getKey() + ")", ex);
} catch (Exception ex) {
logWarn("Can not index repositoryEntry=" + repositoryEntry, ex);
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_11_2_1 method processCourse.
private boolean processCourse(RepositoryEntry entry) {
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode rootNode = course.getRunStructure().getRootNode();
final List<TACourseNode> taskNodes = new ArrayList<>();
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof TACourseNode) {
taskNodes.add((TACourseNode) node);
}
}
}, rootNode, false).visitAll();
for (TACourseNode taskNode : taskNodes) {
processTaskCourseNode(course, entry, taskNode);
}
return true;
} catch (CorruptedCourseException e) {
log.warn("Corrupted course: " + entry.getDisplayname() + " (" + entry.getKey() + ")", e);
return true;
} catch (Exception e) {
log.error("", e);
return true;
}
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_12_0_0 method upgradeLastModified.
private boolean upgradeLastModified(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(LAST_USER_MODIFICATION)) {
int counter = 0;
final Roles roles = new Roles(true, true, true, true, false, true, false);
final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(roles);
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> courses;
do {
courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
for (RepositoryEntry course : courses) {
try {
allOk &= processCourseAssessmentLastModified(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Last modifications migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(LAST_USER_MODIFICATION, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class OLATUpgrade_12_0_0 method processCourseAssessmentLastModified.
private boolean processCourseAssessmentLastModified(RepositoryEntry entry) {
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode rootNode = course.getRunStructure().getRootNode();
Set<Identity> changeSet = new HashSet<>();
processCourseNodeAssessmentLastModified(course, entry, rootNode, changeSet);
dbInstance.commitAndCloseSession();
// update structure nodes and efficiency statement if any
Set<Identity> identitiesWithEfficiencyStatements = findIdentitiesWithEfficiencyStatements(entry);
for (Identity assessedIdentity : changeSet) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createInitAndUpdateUserCourseEnvironment(assessedIdentity, course);
if (identitiesWithEfficiencyStatements.contains(assessedIdentity)) {
efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
}
dbInstance.commitAndCloseSession();
}
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + entry.getKey(), e);
} catch (Exception e) {
log.error("Unexpected error", e);
} finally {
dbInstance.commitAndCloseSession();
}
return true;
}
Aggregations