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 bc687eb2cc5dee539ea55569b3d84e513bade90c..316c03fb296b219deb914d77d4655d5a6561406f 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 b02c996f3fce7af588d4c6d5b9c16e5e3e9dfd64..3b2822b2343db382441bceab7e7e7d6181c0382c 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 c2a778f0adaa23cb24828619d5fe776383320704..848d4a916a9c16efa35f5603a57e1c746b4c4255 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 0e455b243d4cd04a252b5ca46b0425ae71faab76..295c95698fa0cace78cee5689e4e42055dbf74a5 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 47cdb2be1217b60bff90a0d6a0b2b826e532820e..1bb9a3a1b8baccbc256a03e41bb1abadc27535d2 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 3e0f8d1c542b53d9454f63268ce7fd2ce92114fd..6c88fd18f4b780d77f36fb33522457d53ee76361 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 989d07fd05c79b21cc387734ed37af68b2dcc373..c8108b44faaba9aad877d7c1716dd707f6e87b65 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 66d898da5f05abe522903e04b2089b144f000d6e..35c1a28f708d2b293e347ec484e9db6b5fd8c805 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 e3e5dbbc76d9f0e271eb3f0c9dfb8090d152bc5b..a1a784b46d9bb225da45217d355f637b95e764ca 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 c864bdce0771e163a7074b3f5b376a6de7258eea..d1df58402696981fbada8c8b95665f3d674967a3 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 6513dc7dc23124bb169cb30e5cb4b3cafd532a2b..50bd4aa6e93ce87bab44b523362b032c8773d92e 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 fcf427f7e3c6b4acf0b806a774a68b51392d5a4a..c1b8ced8a4d22f3f9a8ed49e3eb3873a7925dd70 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 daeda3195e91257fd4c8c693c70334df08e9ef06..6f0aaf1399c2d2e09e66fdecb90c19f92528306e 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 92cad2fa46b6e3d8a500a7aeee003e80396b7299..70109f1bd1d4efa6da55c3e774886b2477c980ba 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 92d0869acf73d0b274ca3cf1e729799bf9e79935..310c8d626127470f1f46a715121d588587f7fb1c 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 a7ae5209b4d4ec0fdb0dc768f50bba211cdc529b..94318e706ed0a61b46c1021f9fca52f5ceb03c0f 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 59a4dcf0f9cc6e1942adbf931f6ec9a10819f502..061196abad3cef3579abd35098d89aec6ded4dc2 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 9e84e11ab2d0367ac886a11ce3865a48b666d2f5..259edbbe7f70cb18bcbce61e07029189a5f3f06a 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 1e828ecd799a5834e8a27a26aab9c7a6475ac76a..3eaf0b4bad0634445b1a4268faee53e204209eaf 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 5ea6b3dcecb4e2944d0743ca5f1d43071eed5242..2b385ec7179c4b9c737e0de35062dc1b2b84c3af 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 a7d77f0aa078b2fab8df04a68e11941d2f9d7121..7132100307d39af93a4d845c83139b6f305e2cae 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 532baaf9aff95faacc987d76441eb72d71e30e0b..1e87c9009179dcfd560d3871de26b91064a5b8a7 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 a2753180110cf5af846c76fa6545581a18bfdf71..1dffba6efec18e9cbd21b7652907005bea513db4 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}"