From f9f9f06fae3480aec12b34db39276692de322624 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Mon, 7 Jan 2013 14:40:51 +0100
Subject: [PATCH] OO-475: make the 8.2 upgrader more robust and the read method
 of the course too

---
 src/main/java/org/olat/course/PersistingCourseImpl.java | 9 +++++++--
 src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java   | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/olat/course/PersistingCourseImpl.java b/src/main/java/org/olat/course/PersistingCourseImpl.java
index cb75118d4a5..b1104e23f4a 100644
--- a/src/main/java/org/olat/course/PersistingCourseImpl.java
+++ b/src/main/java/org/olat/course/PersistingCourseImpl.java
@@ -425,8 +425,13 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ
 		if (vfsItem == null || !(vfsItem instanceof VFSLeaf)) {
 			throw new CorruptedCourseException("Cannot resolve file: " + fileName + " course=" + toString());
 		}
-		XStream xstream = CourseXStreamAliases.getReadCourseXStream();
-		return XStreamHelper.readObject(xstream, ((VFSLeaf)vfsItem).getInputStream());
+		try {
+			XStream xstream = CourseXStreamAliases.getReadCourseXStream();
+			return XStreamHelper.readObject(xstream, ((VFSLeaf)vfsItem).getInputStream());
+		} catch (Exception e) {
+			log.error("Cannot read course tree file: " + fileName);
+			throw new CorruptedCourseException("Cannot resolve file: " + fileName + " course=" + toString(), e);
+		}
 	}
 
 	/**
diff --git a/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java b/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
index f005503570d..a567a1f56fc 100644
--- a/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
+++ b/src/main/java/org/olat/upgrade/OLATUpgrade_8_2_0.java
@@ -176,6 +176,8 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 						course.postImport(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();
@@ -183,7 +185,7 @@ public class OLATUpgrade_8_2_0 extends OLATUpgrade {
 				log.audit("Processed repository entries: " + entries.size());
 			} while(entries.size() == REPO_ENTRIES_BATCH_SIZE);
 			
-			uhd.setBooleanDataValue(TASK_CONDITIONS, false);
+			uhd.setBooleanDataValue(TASK_CONDITIONS, true);
 			upgradeManager.setUpgradesHistory(uhd, VERSION);
 		}
 		return true;
-- 
GitLab