use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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;
}
use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.
the class AssessmentModeListModel method getValueAt.
@Override
public Object getValueAt(AssessmentMode mode, int col) {
switch(Cols.values()[col]) {
case status:
{
List<String> warnings = null;
Status status = mode.getStatus();
try {
if (StringHelper.containsNonWhitespace(mode.getStartElement())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
CourseNode node = course.getRunStructure().getNode(mode.getStartElement());
if (node == null) {
warnings = new ArrayList<>(2);
warnings.add(translator.translate("warning.missing.start.element"));
}
}
if (StringHelper.containsNonWhitespace(mode.getElementList())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
String elements = mode.getElementList();
for (String element : elements.split(",")) {
CourseNode node = course.getRunStructure().getNode(element);
if (node == null) {
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("warning.missing.element"));
break;
}
}
}
} catch (CorruptedCourseException e) {
log.error("", e);
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("cif.error.corrupted"));
}
return new EnhancedStatus(status, warnings);
}
case course:
return mode.getRepositoryEntry().getDisplayname();
case externalId:
return mode.getRepositoryEntry().getExternalId();
case externalRef:
return mode.getRepositoryEntry().getExternalRef();
case name:
return mode.getName();
case begin:
return mode.getBegin();
case end:
return mode.getEnd();
case leadTime:
return mode.getLeadTime();
case followupTime:
return mode.getFollowupTime();
case target:
return mode.getTargetAudience();
case start:
{
boolean canStart = mode.isManualBeginEnd();
if (canStart) {
canStart = coordinationService.canStart(mode);
}
return canStart;
}
case stop:
{
boolean canStop = mode.isManualBeginEnd();
if (canStop) {
canStop = coordinationService.canStop(mode);
}
return canStop;
}
}
return null;
}
use of org.olat.course.CorruptedCourseException in project openolat by klemens.
the class CourseHandler method readyToDelete.
@Override
public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
String referencesSummary = refM.getReferencesToSummary(entry.getOlatResource(), locale);
if (referencesSummary != null) {
Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
errors.setError(translator.translate("details.delete.error.references", new String[] { referencesSummary, entry.getDisplayname() }));
return false;
}
/*
* make an archive of the course nodes with valuable data
*/
UserManager um = UserManager.getInstance();
String charset = um.getUserCharset(identity);
try {
CourseFactory.archiveCourse(entry.getOlatResource(), charset, locale, identity, roles);
} catch (CorruptedCourseException e) {
log.error("The course is corrupted, cannot archive it: " + entry, e);
}
return true;
}
Aggregations