Search in sources :

Example 11 with CorruptedCourseException

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");
    }
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) OrderedRepositoryHandler(org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler)

Example 12 with CorruptedCourseException

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;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) CorruptedCourseException(org.olat.course.CorruptedCourseException) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) CorruptedCourseException(org.olat.course.CorruptedCourseException)

Example 13 with CorruptedCourseException

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;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse)

Example 14 with CorruptedCourseException

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");
        }
    }
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 15 with CorruptedCourseException

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);
            }
        }
    }
}
Also used : OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CorruptedCourseException(org.olat.course.CorruptedCourseException) CorruptedCourseException(org.olat.course.CorruptedCourseException) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) HashSet(java.util.HashSet)

Aggregations

CorruptedCourseException (org.olat.course.CorruptedCourseException)38 ICourse (org.olat.course.ICourse)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 Roles (org.olat.core.id.Roles)10 CourseNode (org.olat.course.nodes.CourseNode)10 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)10 Identity (org.olat.core.id.Identity)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 GroupRoles (org.olat.basesecurity.GroupRoles)4 CourseConfig (org.olat.course.config.CourseConfig)4 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)4 OLATResource (org.olat.resource.OLATResource)4 IOException (java.io.IOException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 List (java.util.List)2 Test (org.junit.Test)2 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)2 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)2