Skip to content
Snippets Groups Projects
Commit 51889167 authored by rhaag's avatar rhaag
Browse files

FXOLAT-193 backport from OLAT-6163 remove links / show error where possible

--HG--
branch : uzhFixes711
parent c55f2ee6
No related branches found
No related tags found
No related merge requests found
...@@ -100,6 +100,20 @@ public class NewControllerFactory extends LogDelegator { ...@@ -100,6 +100,20 @@ public class NewControllerFactory extends LogDelegator {
return contextEntryControllerCreators.containsKey(key); return contextEntryControllerCreators.containsKey(key);
} }
/**
* Check first context entry can be launched
* a further check is mostly not possible, as it gets validated through the BC-stack while building the controller-chain
*
* return true: if this will be launchable at least for the first step.
*/
public boolean validateCEWithContextControllerCreator(final UserRequest ureq, final WindowControl wControl, ContextEntry ce){
String firstType = ce.getOLATResourceable().getResourceableTypeName();
if (canLaunch(firstType)){
return contextEntryControllerCreators.get(firstType).validateContextEntryAndShowError(ce, ureq, wControl);
}
return false;
}
/** /**
* Launch a controller in a tab or site in the given window from a user * Launch a controller in a tab or site in the given window from a user
* request url * request url
......
...@@ -303,7 +303,8 @@ public class ForumController extends BasicController implements GenericEventList ...@@ -303,7 +303,8 @@ public class ForumController extends BasicController implements GenericEventList
scrollToCurrentMessage(); scrollToCurrentMessage();
} else { } else {
// message not found, do nothing. Load normal start screen // message not found, do nothing. Load normal start screen
logDebug("Invalid messageId=" , ores.getResourceableId().toString()); showError("deleteok");
logDebug("Invalid messageId=", ores.getResourceableId().toString());
} }
} else { } else {
//FIXME:chg: Should not happen, occurs when course-node are called //FIXME:chg: Should not happen, occurs when course-node are called
......
...@@ -172,7 +172,10 @@ public class WikiMainController extends BasicController implements CloneableCont ...@@ -172,7 +172,10 @@ public class WikiMainController extends BasicController implements CloneableCont
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass()); ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass());
// init the first page either startpage or an other page identified by initial page name // init the first page either startpage or an other page identified by initial page name
if (initialPageName != null && wiki.pageExists(WikiManager.generatePageId(initialPageName))) page = wiki.getPage(initialPageName, true); if (initialPageName != null && wiki.pageExists(WikiManager.generatePageId(initialPageName))) page = wiki.getPage(initialPageName, true);
else page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE); else {
page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE);
if (initialPageName != null) showError("wiki.error.page.not.found");
}
this.pageId = page.getPageId(); this.pageId = page.getPageId();
WikiPage menuPage = getWiki().getPage(WikiPage.WIKI_MENU_PAGE); WikiPage menuPage = getWiki().getPage(WikiPage.WIKI_MENU_PAGE);
......
...@@ -26,6 +26,7 @@ import java.util.Iterator; ...@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
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.components.Component; import org.olat.core.gui.components.Component;
...@@ -211,7 +212,7 @@ public class EPArtefactViewController extends FormBasicController { ...@@ -211,7 +212,7 @@ public class EPArtefactViewController extends FormBasicController {
// build link to original source // build link to original source
if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) { if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
String sourceLink = createLinkToArtefactSource(artefact.getBusinessPath()); String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
flc.contextPut("artefactSourceLink", sourceLink); flc.contextPut("artefactSourceLink", sourceLink);
} }
...@@ -267,11 +268,12 @@ public class EPArtefactViewController extends FormBasicController { ...@@ -267,11 +268,12 @@ public class EPArtefactViewController extends FormBasicController {
return busLink; return busLink;
} }
private String createLinkToArtefactSource(String businessPath){ private String createLinkToArtefactSource(UserRequest ureq, String businessPath){
BusinessControlFactory bCF = BusinessControlFactory.getInstance(); BusinessControlFactory bCF = BusinessControlFactory.getInstance();
List<ContextEntry> ceList = bCF.createCEListFromString(businessPath); List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
boolean valid = NewControllerFactory.getInstance().validateCEWithContextControllerCreator(ureq, getWindowControl(), ceList.get(0));
String busLink = bCF.getAsURIString(ceList, true); String busLink = bCF.getAsURIString(ceList, true);
if (StringHelper.containsNonWhitespace(busLink)){ if (valid && StringHelper.containsNonWhitespace(busLink)){
return "<a href=\"" + busLink + "\">" + translate("artefact.open.source") + "</a>"; return "<a href=\"" + busLink + "\">" + translate("artefact.open.source") + "</a>";
} else return translate("artefact.no.source"); } else return translate("artefact.no.source");
} }
......
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