Skip to content
Snippets Groups Projects
Commit 4d544090 authored by srosse's avatar srosse
Browse files

OO-1336: check if the resource can be launched or show an error message

parent fd22901f
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,6 @@ import org.olat.NewControllerFactory; ...@@ -37,7 +37,6 @@ import org.olat.NewControllerFactory;
import org.olat.core.CoreSpringFactory; import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.logging.AssertException;
import org.olat.core.logging.OLog; import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.course.CorruptedCourseException; import org.olat.course.CorruptedCourseException;
...@@ -128,23 +127,26 @@ public class CourseNodeFactory { ...@@ -128,23 +127,26 @@ public class CourseNodeFactory {
* @param ureq * @param ureq
* @param node * @param node
*/ */
public void launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) { public boolean launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) {
RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry(); RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
if (repositoryEntry == null) { if (repositoryEntry == null) {
// do nothing // do nothing
return; return false;
} }
RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry); RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no){ if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no){
throw new AssertException("Trying to edit repository entry which has no assoiciated editor: "+ typeToEdit); log.error("Trying to edit repository entry which has no associated editor: "+ typeToEdit);
return false;
} }
try { try {
String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]"; String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, wControl); NewControllerFactory.getInstance().launch(businessPath, ureq, wControl);
return true;
} catch (CorruptedCourseException e) { } catch (CorruptedCourseException e) {
log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e); log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e);
return false;
} }
} }
......
...@@ -214,16 +214,11 @@ public abstract class FeedNodeEditController extends ActivateableTabbableDefault ...@@ -214,16 +214,11 @@ public abstract class FeedNodeEditController extends ActivateableTabbableDefault
} }
} }
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override @Override
protected void event(UserRequest ureq, Component source, Event event) { protected void event(UserRequest ureq, Component source, Event event) {
if (source == chooseButton || source == changeButton) { if (source == chooseButton || source == changeButton) {
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, resourceTypeName, translate(BUTTON_CHOOSE_FEED)); searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, resourceTypeName, translate(BUTTON_CHOOSE_FEED));
this.listenTo(searchController); listenTo(searchController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true,
translate(BUTTON_CREATE_FEED)); translate(BUTTON_CREATE_FEED));
cmc.activate(); cmc.activate();
...@@ -232,27 +227,30 @@ public abstract class FeedNodeEditController extends ActivateableTabbableDefault ...@@ -232,27 +227,30 @@ public abstract class FeedNodeEditController extends ActivateableTabbableDefault
RepositoryEntry re = node.getReferencedRepositoryEntry(); RepositoryEntry re = node.getReferencedRepositoryEntry();
if (re == null) { if (re == null) {
// The repository entry has been deleted meanwhile. // The repository entry has been deleted meanwhile.
this.showError("error.repoentrymissing"); showError("error.repoentrymissing");
} else { } else {
FeedSecurityCallback callback = new FeedPreviewSecurityCallback(); FeedSecurityCallback callback = new FeedPreviewSecurityCallback();
feedController = uiFactory.createMainController(re.getOlatResource(), ureq, getWindowControl(), callback, course feedController = uiFactory.createMainController(re.getOlatResource(), ureq, getWindowControl(), callback, course
.getResourceableId(), node.getIdent()); .getResourceableId(), node.getIdent());
cmcFeedCtr = new CloseableModalController(getWindowControl(), translate("command.close"), feedController.getInitialComponent()); cmcFeedCtr = new CloseableModalController(getWindowControl(), translate("command.close"), feedController.getInitialComponent());
this.listenTo(cmcFeedCtr); listenTo(cmcFeedCtr);
// cmcFeedCtr.insertHeaderCss();
cmcFeedCtr.activate(); cmcFeedCtr.activate();
} }
} else if (source == editLink) { } else if (source == editLink) {
CourseNodeFactory.getInstance().launchReferencedRepoEntryEditor(ureq, getWindowControl(), node); boolean launched = CourseNodeFactory.getInstance().launchReferencedRepoEntryEditor(ureq, getWindowControl(), node);
if(!launched) {
RepositoryEntry re = node.getReferencedRepositoryEntry();
if (re == null) {
showError("error.repoentrymissing");
} else {
showError("error.wrongtype");
}
}
} }
} }
/** @Override
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest urequest, Controller source, Event event) { public void event(UserRequest urequest, Controller source, Event event) {
if (source == moderatroCtr) { if (source == moderatroCtr) {
if (event == Event.CHANGED_EVENT) { if (event == Event.CHANGED_EVENT) {
......
...@@ -16,6 +16,8 @@ help.hover.feed.r=Hilfe, um den lesenden Zugang zu konfigurieren ...@@ -16,6 +16,8 @@ help.hover.feed.r=Hilfe, um den lesenden Zugang zu konfigurieren
help.hover.feed.rw=Hilfe, um den schreibenden Zugang zu konfigurieren help.hover.feed.rw=Hilfe, um den schreibenden Zugang zu konfigurieren
heip.hover.choose.feed=Hilfe zur Auswahl eines Feeds heip.hover.choose.feed=Hilfe zur Auswahl eines Feeds
error.repoentrymissing=Das Feed (Blog oder Podcast), das Sie anzeigen m\u00F6chten, wurde in der Zwischenzeit in der Ablage der Lernressourcen gel\u00F6scht.
error.wrongtype=Der Lernressourcen hat wahrscheinlich nicht den richtigen Typ. Pr\u00FCfen Sie dass Sie ein Podcast oder ein Blog an diesem Kursbaustein verbunden haben
chelp.feed.p1=Wenn Sie noch keinen Feed (Blog oder Podcast) ausgew\u00E4hlt haben, wird dies angezeigt. chelp.feed.p1=Wenn Sie noch keinen Feed (Blog oder Podcast) ausgew\u00E4hlt haben, wird dies angezeigt.
chelp.feed.p2=Erstellen Sie erst den Feed (Blog oder Podcast) in den Lernressourcen. Klicken Sie dann auf die Schaltfläche "Blog/Podcast wählen, erstellen oder importieren", um in der Ablage der Lernressourcen den gew\u00FCnschten Inhalt auszuw\u00E4hlen. chelp.feed.p2=Erstellen Sie erst den Feed (Blog oder Podcast) in den Lernressourcen. Klicken Sie dann auf die Schaltfläche "Blog/Podcast wählen, erstellen oder importieren", um in der Ablage der Lernressourcen den gew\u00FCnschten Inhalt auszuw\u00E4hlen.
......
...@@ -9,6 +9,8 @@ command.preview=Display preview ...@@ -9,6 +9,8 @@ command.preview=Display preview
condition.accessModerator.title=Moderate condition.accessModerator.title=Moderate
condition.accessPoster.title=Read and write condition.accessPoster.title=Read and write
condition.accessReader.title=Read only condition.accessReader.title=Read only
error.repoentrymissing=This Feed (blog or podcast) has been deleted in the meantime within the storage folder of learning resources.
error.wrongtype=The learning resource has probably the wrong type. Please, make sure that you have linked a podcast or a blog to this course element.
heip.hover.choose.feed=Help regarding your feed selection heip.hover.choose.feed=Help regarding your feed selection
help.hover.feed.mo=Help regarding the access configuration as moderator help.hover.feed.mo=Help regarding the access configuration as moderator
help.hover.feed.r=Help regarding the access configuration as reader help.hover.feed.r=Help regarding the access configuration as reader
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment