From 15dacab49ea6152055809789e42cd662db0afd81 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Thu, 13 Aug 2015 21:32:14 +0200
Subject: [PATCH] OO-1629: add a more explicit error message, add reference
 links in details view of the resource

---
 .../qti/repository/handlers/QTIHandler.java   | 11 +++----
 .../_i18n/LocalStrings_de.properties          |  4 +--
 .../_i18n/LocalStrings_en.properties          |  4 +--
 .../_i18n/LocalStrings_fr.properties          |  4 +--
 .../_i18n/LocalStrings_it.properties          |  4 +--
 .../_i18n/LocalStrings_pt_PT.properties       |  4 +--
 .../olat/repository/handlers/BlogHandler.java |  7 +++--
 .../repository/handlers/CourseHandler.java    | 10 +++----
 .../olat/repository/handlers/FileHandler.java |  7 +++--
 .../repository/handlers/GlossaryHandler.java  |  7 +++--
 .../repository/handlers/PodcastHandler.java   |  7 +++--
 .../repository/handlers/PortfolioHandler.java |  9 +++---
 .../handlers/RepositoryHandler.java           |  2 +-
 .../handlers/SharedFolderHandler.java         |  7 +++--
 .../olat/repository/handlers/WikiHandler.java |  6 ++--
 .../manager/RepositoryServiceImpl.java        |  2 +-
 .../ui/author/ConfirmDeleteController.java    | 29 ++++++++++++++++---
 .../RepositoryEntryDetailsController.java     | 25 +++++++++++++---
 .../repository/ui/list/_content/details.html  |  8 +++--
 .../resource/references/ReferenceManager.java | 17 +++++++++--
 .../_i18n/LocalStrings_de.properties          |  4 +--
 .../_i18n/LocalStrings_en.properties          |  4 +--
 .../_i18n/LocalStrings_fr.properties          |  4 +--
 23 files changed, 124 insertions(+), 62 deletions(-)

diff --git a/src/main/java/org/olat/ims/qti/repository/handlers/QTIHandler.java b/src/main/java/org/olat/ims/qti/repository/handlers/QTIHandler.java
index bc687eb2cc5..316c03fb296 100644
--- a/src/main/java/org/olat/ims/qti/repository/handlers/QTIHandler.java
+++ b/src/main/java/org/olat/ims/qti/repository/handlers/QTIHandler.java
@@ -135,18 +135,19 @@ public abstract class QTIHandler extends FileHandler {
 	public abstract MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl);
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
-		if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(res, null)) {
+		if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(entry.getOlatResource(), null)) {
 			Translator translator = Util.createPackageTranslator(RepositoryManager.class, locale);
-			errors.setError(translator.translate("details.delete.error.editor"));
+			errors.setError(translator.translate("details.delete.error.editor",
+					new String[] { entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties
index b02c996f3fc..3b2822b2343 100644
--- a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties
@@ -287,8 +287,8 @@ details.copy.confirm.warning=<div class="o_warning">Bei einigen der ausgew\u00E4
 details.copy.success={0} Lernressourcen wurden kopiert.
 details.delete=L\u00F6schen 
 details.delete.alt={0} l\u00F6schen
-details.delete.error.editor=Lernressource kann nicht gel\u00F6scht werden. Die Lernressource wird momentan von einem Benutzer im Editor verwendet.
-details.delete.error.references=Lernressource kann nicht gel\u00F6scht werden. Es bestehen aktive Referenzen auf die gew\u00E4hlte Lernressource innerhalb von OpenOLAT.<br /><br /><font color\="red">{0}</font>
+details.delete.error.editor=Lernressource kann "{0}" nicht gel\u00F6scht werden. Die Lernressource wird momentan von einem Benutzer im Editor verwendet.
+details.delete.error.references=Lernressource "{1}" kann nicht gel\u00F6scht werden. Es bestehen aktive Referenzen auf die gew\u00E4hlte Lernressource innerhalb von OpenOLAT: <em>{0}</em>
 details.delete.entries=Lernressourcen
 details.delete.acknowledge=Best\u00E4tigung
 details.delete.acknowledge.msg=Alle Dateien werden definitiv gel\u00F6scht und k\u00F6nnen nicht mehr wiederhergestellt werden.
diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties
index c2a778f0ada..848d4a916a9 100644
--- a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties
+++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties
@@ -290,8 +290,8 @@ details.delete.acknowledge=Confirmation
 details.delete.acknowledge.error=Please confirm.
 details.delete.acknowledge.msg=All files will be permanently removed and cannot be recovered.
 details.delete.entries=Learning resources
-details.delete.error.editor=This learning resource cannot be deleted. This learning resource is currently used by another user in the editor.
-details.delete.error.references=This learning resource cannot be deleted. There are active references to this resource within OpenOLAT.<br /><br /><font color\="red">{0}</font>
+details.delete.error.editor=This learning resource "{0}" cannot be deleted. This learning resource is currently used by another user in the editor.
+details.delete.error.references=This learning resource "{1}" cannot be deleted. There are active references to this resource within OpenOLAT: {0}.
 details.delete.references=Do you want delete the references too?
 details.delete.notOrphan=still referenced
 details.delete.notOwner=not owner
diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties
index 0e455b243d4..295c95698fa 100644
--- a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties
+++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties
@@ -292,8 +292,8 @@ details.delete.acknowledge.error=Vous devez le confirmer.
 details.delete.acknowledge.msg=Toutes les donn\u00E9es seront d\u00E9finitivement effac\u00E9es et ne pourront pas \u00EAtre r\u00E9cup\u00E9r\u00E9es.
 details.delete.alt=Supprimer le {0}
 details.delete.entries=Ressources didactiques
-details.delete.error.editor=La ressource didactique ne peut pas \u00EAtre supprim\u00E9e. La ressource est actuellement utilis\u00E9e par un autre utilisateur dans l'\u00E9diteur.
-details.delete.error.references=La ressource didactique ne peut pas \u00EAtre supprim\u00E9e. Il y a des r\u00E9f\u00E9rences actives sur cette ressource dans OpenOLAT.<br /><br /><font color\="red">{0}</font>
+details.delete.error.editor=La ressource didactique "{0}" ne peut pas \u00EAtre supprim\u00E9e. La ressource est actuellement utilis\u00E9e par un autre utilisateur dans l'\u00E9diteur.
+details.delete.error.references=La ressource didactique "{1}" ne peut pas \u00EAtre supprim\u00E9e. Il y a des r\u00E9f\u00E9rences actives sur cette ressource dans OpenOLAT.<br /><br /><font color\="red">{0}</font>
 details.delete.managed=managed
 details.delete.notOrphan=encore r\u00E9f\u00E9renc\u00E9
 details.delete.notOwner=pas propri\u00E9taire
diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties
index 47cdb2be121..1bb9a3a1b8b 100644
--- a/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties
+++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties
@@ -218,8 +218,8 @@ details.close=Chiudere visione dettagliata
 details.close.ressoure=Terminare
 details.copy=Copiare
 details.delete=Eliminare
-details.delete.error.editor=La risorsa didattica non pu\u00F2 essere eliminata. La risorsa \u00E8 attualmente utilizzata da un altro utente nell'editore.
-details.delete.error.references=La risorsa didattica non pu\u00F2 essere eliminata. Esistono riferimenti attivi a questa risorsa didattica in OpenOLAT.<br /><br /><font color\="red">{0}</font>
+details.delete.error.editor=La risorsa didattica "{0}" non pu\u00F2 essere eliminata. La risorsa \u00E8 attualmente utilizzata da un altro utente nell'editore.
+details.delete.error.references=La risorsa didattica "{1}" non pu\u00F2 essere eliminata. Esistono riferimenti attivi a questa risorsa didattica in OpenOLAT.<br /><br /><font color\="red">{0}</font>
 details.description=Descrizione della risorsa didattica
 details.download=Esportare contenuto
 details.edit=Modificare
diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_PT.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_PT.properties
index 3e0f8d1c542..6c88fd18f4b 100644
--- a/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_PT.properties
+++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_PT.properties
@@ -191,8 +191,8 @@ details.chprop=Modificar propriedades
 details.close=Fechar detalhes
 details.copy=Copiar
 details.delete=Apagar
-details.delete.error.editor=Recurso did\u00E1tico n\u00E3o pode ser apagado. Este recurso did\u00E1tico est\u00E1 sendo editado por outro usu\u00E1rio.
-details.delete.error.references=Recurso did\u00E1tico n\u00E3o pode ser apagado. Existem refer\u00EAncias ativas para este recurso no OpenOLAT.<br /><br /><font color\="red">{0}</font>
+details.delete.error.editor=Recurso did\u00E1tico "{0}" n\u00E3o pode ser apagado. Este recurso did\u00E1tico est\u00E1 sendo editado por outro usu\u00E1rio.
+details.delete.error.references=Recurso did\u00E1tico "{1}" n\u00E3o pode ser apagado. Existem refer\u00EAncias ativas para este recurso no OpenOLAT.<br /><br /><font color\="red">{0}</font>
 details.description=Descri\u00E7\u00E3o do recurso did\u00E1tico
 details.download=Exportar
 details.edit=Modificar
diff --git a/src/main/java/org/olat/repository/handlers/BlogHandler.java b/src/main/java/org/olat/repository/handlers/BlogHandler.java
index 989d07fd05c..c8108b44faa 100644
--- a/src/main/java/org/olat/repository/handlers/BlogHandler.java
+++ b/src/main/java/org/olat/repository/handlers/BlogHandler.java
@@ -192,12 +192,13 @@ public class BlogHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+			errors.setError(translator.translate("details.delete.error.references",
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/CourseHandler.java b/src/main/java/org/olat/repository/handlers/CourseHandler.java
index 66d898da5f0..35c1a28f708 100644
--- a/src/main/java/org/olat/repository/handlers/CourseHandler.java
+++ b/src/main/java/org/olat/repository/handlers/CourseHandler.java
@@ -574,13 +574,13 @@ public class CourseHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		/*
@@ -589,9 +589,9 @@ public class CourseHandler implements RepositoryHandler {
 		UserManager um = UserManager.getInstance();
 		String charset = um.getUserCharset(identity);
 		try {
-			CourseFactory.archiveCourse(res,charset, locale, identity, roles);
+			CourseFactory.archiveCourse(entry.getOlatResource(),charset, locale, identity, roles);
 		} catch (CorruptedCourseException e) {
-			log.error("The course is corrupted, cannot archive it: " + res, e);
+			log.error("The course is corrupted, cannot archive it: " + entry, e);
 		}
 		return true;
 	}
diff --git a/src/main/java/org/olat/repository/handlers/FileHandler.java b/src/main/java/org/olat/repository/handlers/FileHandler.java
index e3e5dbbc76d..a1a784b46d9 100644
--- a/src/main/java/org/olat/repository/handlers/FileHandler.java
+++ b/src/main/java/org/olat/repository/handlers/FileHandler.java
@@ -70,12 +70,13 @@ public abstract class FileHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
-		String referencesSummary = CoreSpringFactory.getImpl(ReferenceManager.class).getReferencesToSummary(res, locale);
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+		String referencesSummary = CoreSpringFactory.getImpl(ReferenceManager.class)
+				.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 }));
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/GlossaryHandler.java b/src/main/java/org/olat/repository/handlers/GlossaryHandler.java
index c864bdce077..d1df5840269 100644
--- a/src/main/java/org/olat/repository/handlers/GlossaryHandler.java
+++ b/src/main/java/org/olat/repository/handlers/GlossaryHandler.java
@@ -233,12 +233,13 @@ public class GlossaryHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+			errors.setError(translator.translate("details.delete.error.references",
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/PodcastHandler.java b/src/main/java/org/olat/repository/handlers/PodcastHandler.java
index 6513dc7dc23..50bd4aa6e93 100644
--- a/src/main/java/org/olat/repository/handlers/PodcastHandler.java
+++ b/src/main/java/org/olat/repository/handlers/PodcastHandler.java
@@ -186,12 +186,13 @@ public class PodcastHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+			errors.setError(translator.translate("details.delete.error.references",
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/PortfolioHandler.java b/src/main/java/org/olat/repository/handlers/PortfolioHandler.java
index fcf427f7e3c..c1b8ced8a4d 100644
--- a/src/main/java/org/olat/repository/handlers/PortfolioHandler.java
+++ b/src/main/java/org/olat/repository/handlers/PortfolioHandler.java
@@ -174,9 +174,9 @@ public class PortfolioHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
-		PortfolioStructure map = ePFMgr.loadPortfolioStructure(res);
+		PortfolioStructure map = ePFMgr.loadPortfolioStructure(entry.getOlatResource());
 		if(map instanceof EPStructuredMapTemplate) {
 			EPStructuredMapTemplate exercise = (EPStructuredMapTemplate)map;
 			if (ePFMgr.isTemplateInUse(exercise, null, null, null)) {
@@ -185,10 +185,11 @@ public class PortfolioHandler implements RepositoryHandler {
 		}
 
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+			errors.setError(translator.translate("details.delete.error.references",
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/RepositoryHandler.java b/src/main/java/org/olat/repository/handlers/RepositoryHandler.java
index daeda3195e9..6f0aaf1399c 100644
--- a/src/main/java/org/olat/repository/handlers/RepositoryHandler.java
+++ b/src/main/java/org/olat/repository/handlers/RepositoryHandler.java
@@ -189,7 +189,7 @@ public interface RepositoryHandler {
 	 * @param errors
 	 * @return true if ressource is ready to delete, false if not.
 	 */
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors);
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors);
 	
 
 	public String archive(Identity archiveOnBehalfOf, String archivFilePath, RepositoryEntry repoEntry);
diff --git a/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java b/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java
index 92cad2fa46b..70109f1bd1d 100644
--- a/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java
+++ b/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java
@@ -219,12 +219,13 @@ public class SharedFolderHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+			errors.setError(translator.translate("details.delete.error.references",
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/handlers/WikiHandler.java b/src/main/java/org/olat/repository/handlers/WikiHandler.java
index 92d0869acf7..310c8d62612 100644
--- a/src/main/java/org/olat/repository/handlers/WikiHandler.java
+++ b/src/main/java/org/olat/repository/handlers/WikiHandler.java
@@ -284,13 +284,13 @@ public class WikiHandler implements RepositoryHandler {
 	}
 
 	@Override
-	public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors) {
+	public boolean readyToDelete(RepositoryEntry entry, Identity identity, Roles roles, Locale locale, ErrorList errors) {
 		ReferenceManager refM = CoreSpringFactory.getImpl(ReferenceManager.class);
-		String referencesSummary = refM.getReferencesToSummary(res, locale);
+		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 }));
+					new String[] { referencesSummary, entry.getDisplayname() }));
 			return false;
 		}
 		return true;
diff --git a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java
index a7ae5209b4d..94318e706ed 100644
--- a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java
+++ b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java
@@ -301,7 +301,7 @@ public class RepositoryServiceImpl implements RepositoryService {
 		RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(entry);
 		OLATResource resource = entry.getOlatResource();
 		//delete old context
-		if (!handler.readyToDelete(resource, identity, roles, locale, errors)) {
+		if (!handler.readyToDelete(entry, identity, roles, locale, errors)) {
 			return errors;
 		}
 
diff --git a/src/main/java/org/olat/repository/ui/author/ConfirmDeleteController.java b/src/main/java/org/olat/repository/ui/author/ConfirmDeleteController.java
index 59a4dcf0f9c..061196abad3 100644
--- a/src/main/java/org/olat/repository/ui/author/ConfirmDeleteController.java
+++ b/src/main/java/org/olat/repository/ui/author/ConfirmDeleteController.java
@@ -232,7 +232,8 @@ public class ConfirmDeleteController extends FormBasicController {
 	}
 	
 	private void doCompleteDelete(UserRequest ureq) {
-		boolean allOk = deleteEntries(ureq, rows) ;
+		List<ErrorList> errorList = new ArrayList<>();
+		boolean allOk = deleteEntries(ureq, rows, errorList) ;
 		
 		if(allOk && deleteReferencesEl.isVisible() && deleteReferencesEl.isEnabled()
 				&& deleteReferencesEl.isOneSelected() && deleteReferencesEl.isSelected(0)) {
@@ -250,17 +251,36 @@ public class ConfirmDeleteController extends FormBasicController {
 					referencesToDelete.add(referencesMap.get(key).getEntry());
 				}
 			}
-			allOk &= deleteEntries(ureq, referencesToDelete);
+			allOk &= deleteEntries(ureq, referencesToDelete, errorList);
 		}
 		
 		if(allOk) {
 			showInfo("info.entry.deleted");
 		} else {
-			showWarning("info.could.not.delete.entry");
+			List<String> msgs = new ArrayList<>();
+			for(ErrorList error:errorList) {
+				if(StringHelper.containsNonWhitespace(error.getFirstError())) {
+					msgs.add(error.getFirstError());
+				}
+			}
+			
+			if(msgs.size() == 1) {
+				getWindowControl().setWarning(msgs.get(0));
+			} else if(msgs.size() > 1) {
+				StringBuilder sb = new StringBuilder();
+				sb.append("<ul>");
+				for(String msg:msgs) {
+					sb.append("<li>").append(msg).append("</li>");
+				}
+				sb.append("</ul>");
+				getWindowControl().setWarning(sb.toString());
+			} else {
+				showWarning("info.could.not.delete.entry");
+			}
 		}
 	}
 	
-	private boolean deleteEntries(UserRequest ureq, List<RepositoryEntry> entries) {
+	private boolean deleteEntries(UserRequest ureq, List<RepositoryEntry> entries, List<ErrorList> errorList) {
 		boolean allOk = true;
 		Roles roles = ureq.getUserSession().getRoles();
 		for(RepositoryEntry entry:entries) {
@@ -269,6 +289,7 @@ public class ConfirmDeleteController extends FormBasicController {
 				ErrorList errors = repositoryService.delete(reloadedEntry, getIdentity(), roles, getLocale());
 				if (errors.hasErrors()) {
 					allOk = false;
+					errorList.add(errors);
 				} else {
 					fireEvent(ureq, new EntryChangedEvent(reloadedEntry, getIdentity(), Change.deleted));
 				}
diff --git a/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java b/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java
index 9e84e11ab2d..259edbbe7f7 100644
--- a/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java
+++ b/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java
@@ -448,10 +448,20 @@ public class RepositoryEntryDetailsController extends FormBasicController {
             
             // Where is it in use
             if(isAuthor || roles.isOLATAdmin() || roles.isInstitutionalResourceManager()) {
-	            String referenceDetails = referenceManager.getReferencesToSummary(entry.getOlatResource(), getLocale());
-	            if (referenceDetails != null) {
-	            	layoutCont.contextPut("referenceDetails", referenceDetails);
-	            }
+				List<RepositoryEntry> refs = referenceManager.getRepositoryReferencesTo(entry.getOlatResource());
+				if(refs.size() > 0) {
+					List<String> refLinks = new ArrayList<>(refs.size());
+					int count = 0;
+					for(RepositoryEntry ref:refs) {
+						String name = "ref-" + count++;
+						FormLink refLink = uifactory
+								.addFormLink(name, "ref", ref.getDisplayname(), null, formLayout, Link.NONTRANSLATED);
+						refLink.setUserObject(ref.getKey());
+						refLink.setIconLeftCSS("o_icon o_icon-fw " + RepositoyUIFactory.getIconCssClass(ref));
+						refLinks.add(name);
+					}
+	            	layoutCont.contextPut("referenceLinks", refLinks);
+				}
             }
             
             // Link to bookmark entry
@@ -548,6 +558,8 @@ public class RepositoryEntryDetailsController extends FormBasicController {
 				doOpenVisitCard(ureq, ownerKey);
 			} else if("leave".equals(cmd)) {
 				doConfirmLeave(ureq);
+			} else if("ref".equals(cmd)) {
+				doOpenReference(ureq, (Long)link.getUserObject());
 			}
 		} else if(ratingEl == source && event instanceof RatingFormEvent) {
 			RatingFormEvent ratingEvent = (RatingFormEvent)event;
@@ -592,6 +604,11 @@ public class RepositoryEntryDetailsController extends FormBasicController {
 		}
 	}
 	
+	protected void doOpenReference(UserRequest ureq, Long entryKey) {
+		String businessPath = "[RepositoryEntry:" + entryKey + "]";
+		NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
+	}
+	
 	protected void doOpenCategory(UserRequest ureq, Long categoryKey) {
 		String businessPath = "[CatalogEntry:" + categoryKey + "]";
 		NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
diff --git a/src/main/java/org/olat/repository/ui/list/_content/details.html b/src/main/java/org/olat/repository/ui/list/_content/details.html
index 1e828ecd799..3eaf0b4bad0 100644
--- a/src/main/java/org/olat/repository/ui/list/_content/details.html
+++ b/src/main/java/org/olat/repository/ui/list/_content/details.html
@@ -268,7 +268,7 @@
 				/* ]]> */
 			</script>
 
-			#if ($referenceDetails)
+			#if ($referenceLinks && $referenceLinks.size() > 0)
 			<div class="panel panel-default o_usagepanel">
 				<div class="panel-heading" data-toggle="collapse" data-target="#collapseUsage">
 			    	<h3 class="panel-title">
@@ -281,7 +281,11 @@
 					<table class="table table-condensed table-striped"><tbody>
 						<tr>
 							<th>$r.translate("details.referenceinfo")</th>
-							<td>$referenceDetails</td>
+							<td>
+								#foreach($referenceLink in $referenceLinks)
+									#if($velocityCount != 1), #end$r.render($referenceLink)
+								#end
+							</td>
 						</tr>
 						<tr><th>$r.translate("cif.lastusage")</th><td>$r.formatDateAndTime($v.getStatistics().getLastUsage())</td></tr>
 						<tr><th>$r.translate("cif.usedbycnt")</th><td>$numUsers</td></tr>
diff --git a/src/main/java/org/olat/resource/references/ReferenceManager.java b/src/main/java/org/olat/resource/references/ReferenceManager.java
index 5ea6b3dcecb..2b385ec7179 100644
--- a/src/main/java/org/olat/resource/references/ReferenceManager.java
+++ b/src/main/java/org/olat/resource/references/ReferenceManager.java
@@ -133,6 +133,18 @@ public class ReferenceManager {
 				.getResultList();
 	}
 	
+	public List<RepositoryEntry> getRepositoryReferencesTo(OLATResourceable target) {
+		Long targetKey = getResourceKey(target);
+		StringBuilder sb = new StringBuilder();
+		sb.append("select v from ").append(RepositoryEntry.class.getName()).append(" as v")
+		  .append(" where v.olatResource in (select ref.source from references as ref where ref.target.key=:targetKey)");
+		
+		return dbInstance.getCurrentEntityManager()
+				.createQuery(sb.toString(), RepositoryEntry.class)
+				.setParameter("targetKey", targetKey)
+				.getResultList();
+	}
+	
 	public List<ReferenceInfos> getReferencesInfos(List<RepositoryEntry> res, Identity identity, Roles roles) {
 		if(res == null || res.isEmpty()) return Collections.emptyList();
 		
@@ -226,6 +238,8 @@ public class ReferenceManager {
 		List<Reference> refs = getReferencesTo(target);
 		if (refs.size() == 0) return null;
 		for (Reference ref:refs) {
+			if(result.length() > 0) result.append(", ");
+			
 			OLATResource source = ref.getSource();
 			// special treatment for referenced courses: find out the course title
 			if (source.getResourceableTypeName().equals(CourseModule.getCourseTypeName())) {
@@ -237,9 +251,8 @@ public class ReferenceManager {
 					result.append(translator.translate("ref.course", new String[] { "<strike>" + source.getKey().toString() + "</strike>" }));
 				}
 			} else {
-				result.append(translator.translate("ref.generic", new String[] { source.getKey().toString() }));
+				result.append(source.getKey().toString());
 			}
-			result.append("<br />");
 		}
 		return result.toString();
 	}
diff --git a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_de.properties
index a7d77f0aa07..7132100307d 100644
--- a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_de.properties
@@ -1,3 +1,3 @@
 #Mon Mar 02 09:54:04 CET 2009
-ref.course=Wird im Kurs "{0}" eingesetzt
-ref.generic=Wird im Objekt "{0}" eingesetzt
+ref.course=im Kurs "{0}"
+ref.generic=im Objekt "{0}"
diff --git a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_en.properties
index 532baaf9aff..1e87c900917 100644
--- a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_en.properties
+++ b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_en.properties
@@ -1,3 +1,3 @@
 #Mon Mar 02 09:54:18 CET 2009
-ref.course=Used in course "{0}"
-ref.generic=Used in object "{0}"
+ref.course=in course "{0}"
+ref.generic=in object "{0}"
diff --git a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_fr.properties
index a2753180110..1dffba6efec 100644
--- a/src/main/java/org/olat/resource/references/_i18n/LocalStrings_fr.properties
+++ b/src/main/java/org/olat/resource/references/_i18n/LocalStrings_fr.properties
@@ -1,3 +1,3 @@
 #Tue Dec 21 13:16:42 CET 2010
-ref.course=Utilis\u00E9e dans le cours "{0}"
-ref.generic=Utilis\u00E9e dans l'objet "{0}"
+ref.course=dans le cours "{0}"
+ref.generic=dans l'objet "{0}"
-- 
GitLab