Search in sources :

Example 1 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

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

Example 2 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

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);
    }
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) RepositoryEntryStatus(org.olat.repository.RepositoryEntryStatus) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssertException(org.olat.core.logging.AssertException) CorruptedCourseException(org.olat.course.CorruptedCourseException) StartupException(org.olat.core.logging.StartupException) IOException(java.io.IOException)

Example 3 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method createReferenceesMsg.

/**
 * helper method to create the message about qti resource stakeholders and
 * from where the qti resource is referenced.
 *
 * @return
 */
private String createReferenceesMsg(UserRequest ureq) {
    /*
		 * problems: A tries to reference this test, after test editor has been
		 * started
		 */
    changeEmail = new ContactMessage(ureq.getIdentity());
    // the owners of this qtiPkg
    RepositoryEntry myEntry = repositoryManager.lookupRepositoryEntry(qtiPackage.getRepresentingResourceable(), false);
    // add qti resource owners as group
    ContactList cl = new ContactList("qtiPkgOwners");
    cl.addAllIdentites(repositoryService.getMembers(myEntry, GroupRoles.owner.name()));
    changeEmail.addEmailTo(cl);
    StringBuilder result = new StringBuilder();
    result.append(translate("qti.restricted.leading"));
    for (Iterator<Reference> iter = referencees.iterator(); iter.hasNext(); ) {
        Reference element = iter.next();
        if ("CourseModule".equals(element.getSource().getResourceableTypeName())) {
            ICourse course = null;
            try {
                course = CourseFactory.loadCourse(element.getSource().getResourceableId());
                if (course == null) {
                    continue;
                }
            } catch (CorruptedCourseException ex) {
                logError("", ex);
                continue;
            }
            CourseNode cn = course.getEditorTreeModel().getCourseNode(element.getUserdata());
            if (cn == null) {
                logError("Cannot find course element " + element.getUserdata() + " in course " + course, null);
                continue;
            }
            String courseTitle = course.getCourseTitle();
            StringBuilder stakeHolders = new StringBuilder();
            // the course owners
            RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course, false);
            if (entry != null) {
                // OO-1300
                List<Identity> stakeHoldersIds = repositoryService.getMembers(entry, GroupRoles.owner.name());
                if (stakeHoldersIds != null && stakeHoldersIds.size() > 0) {
                    // add stakeholders as group
                    cl = new ContactList(courseTitle);
                    cl.addAllIdentites(stakeHoldersIds);
                    changeEmail.addEmailTo(cl);
                    for (Identity stakeHoldersId : stakeHoldersIds) {
                        if (stakeHolders.length() > 0)
                            stakeHolders.append(", ");
                        User user = stakeHoldersId.getUser();
                        stakeHolders.append(user.getProperty(UserConstants.FIRSTNAME, getLocale())).append(" ").append(user.getProperty(UserConstants.LASTNAME, getLocale()));
                    }
                }
            }
            String courseNodeTitle = cn.getShortTitle();
            result.append(translate("qti.restricted.course", StringHelper.escapeHtml(courseTitle)));
            result.append(translate("qti.restricted.node", StringHelper.escapeHtml(courseNodeTitle)));
            result.append(translate("qti.restricted.owners", stakeHolders.toString()));
        }
    }
    return result.toString();
}
Also used : User(org.olat.core.id.User) Reference(org.olat.resource.references.Reference) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) ContactList(org.olat.core.util.mail.ContactList) ContactMessage(org.olat.core.util.mail.ContactMessage) CorruptedCourseException(org.olat.course.CorruptedCourseException) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 4 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_0_0 method upgradeEfficiencyStatementTable.

private boolean upgradeEfficiencyStatementTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    boolean allOk = true;
    if (!uhd.getBooleanDataValue(EFFICIENCY_STATEMENT_DATAS)) {
        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 {
                    convertUserEfficiencyStatemen(course);
                } catch (CorruptedCourseException e) {
                    log.error("Corrupted course: " + course.getKey(), e);
                }
            }
            counter += courses.size();
            log.audit("Efficiency statement data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (courses.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(EFFICIENCY_STATEMENT_DATAS, allOk);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return allOk;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) CorruptedCourseException(org.olat.course.CorruptedCourseException) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 5 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

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)

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