From e1a4767b517f15298b47e82bdfcb27fee1578233 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Fri, 8 May 2015 10:28:12 +0200
Subject: [PATCH] OO-1544: better check of the validity of the last history
 point used in the "close" method of the course tab

---
 .../ui/RepositoryEntryRuntimeController.java    | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java b/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java
index 1ea2a850189..9e4406023df 100644
--- a/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java
+++ b/src/main/java/org/olat/repository/ui/RepositoryEntryRuntimeController.java
@@ -635,14 +635,17 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController
 	
 	protected final void doClose(UserRequest ureq) {
 		// Now try to go back to place that is attacked to (optional) root back business path
-		if (launchedFromPoint != null && StringHelper.containsNonWhitespace(launchedFromPoint.getBusinessPath())) {
+		if (launchedFromPoint != null && StringHelper.containsNonWhitespace(launchedFromPoint.getBusinessPath())
+				&& launchedFromPoint.getEntries() != null && launchedFromPoint.getEntries().size() > 0) {
 			BusinessControl bc = BusinessControlFactory.getInstance().createFromPoint(launchedFromPoint);
-			WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
-			try {
-				//make the resume secure. If something fail, don't generate a red screen
-				NewControllerFactory.getInstance().launch(ureq, bwControl);
-			} catch (Exception e) {
-				logError("Error while resuming with root leve back business path::" + launchedFromPoint.getBusinessPath(), e);
+			if(bc.hasContextEntry()) {
+				WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
+				try {
+					//make the resume secure. If something fail, don't generate a red screen
+					NewControllerFactory.getInstance().launch(ureq, bwControl);
+				} catch (Exception e) {
+					logError("Error while resuming with root level back business path::" + launchedFromPoint.getBusinessPath(), e);
+				}
 			}
 		}
 		
-- 
GitLab