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;
}
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);
}
}
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();
}
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;
}
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;
}
Aggregations