use of org.olat.core.id.context.BusinessControlFactory in project OpenOLAT by OpenOLAT.
the class EPArtefactViewController method createLinkToArtefactSource.
private String createLinkToArtefactSource(UserRequest ureq, String businessPath) {
BusinessControlFactory bCF = BusinessControlFactory.getInstance();
List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
boolean valid = (ceList.size() > 0) && NewControllerFactory.getInstance().validateCEWithContextControllerCreator(ureq, getWindowControl(), ceList.get(0));
String busLink = bCF.getAsURIString(ceList, true);
if (valid && StringHelper.containsNonWhitespace(busLink)) {
return "<a href=\"" + busLink + "\">" + translate("artefact.open.source") + "</a>";
} else
return translate("artefact.no.source");
}
use of org.olat.core.id.context.BusinessControlFactory in project OpenOLAT by OpenOLAT.
the class SendDocumentsByEMailController method appendBusinessPath.
protected void appendBusinessPath(VFSContainer rootContainer, VFSLeaf file, StringBuilder sb) {
BusinessControlFactory bCF = BusinessControlFactory.getInstance();
String businnessPath = getWindowControl().getBusinessControl().getAsString();
String relPath = getRelativePath(rootContainer, file);
businnessPath += "[path=" + relPath + "]";
List<ContextEntry> ces = bCF.createCEListFromString(businnessPath);
String uri = bCF.getAsURIString(ces, true);
this.appendMetadata("mf.url", uri, sb);
}
use of org.olat.core.id.context.BusinessControlFactory in project OpenOLAT by OpenOLAT.
the class InfoPeekViewController method getUrl.
public String getUrl(String businessPath) {
BusinessControlFactory bCF = BusinessControlFactory.getInstance();
List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
StringBuilder retVal = new StringBuilder();
retVal.append(Settings.getServerContextPathURI()).append("/url/");
for (ContextEntry contextEntry : ceList) {
String ceStr = contextEntry.toString();
ceStr = ceStr.replace(':', '/');
ceStr = ceStr.replaceFirst("\\]", "/");
ceStr = ceStr.replaceFirst("\\[", "");
retVal.append(ceStr);
}
return retVal.substring(0, retVal.length() - 1);
}
use of org.olat.core.id.context.BusinessControlFactory in project OpenOLAT by OpenOLAT.
the class ForumNodeForumCallback method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Roles roles = ureq.getUserSession().getRoles();
Forum theForum = loadOrCreateForum(userCourseEnv.getCourseEnvironment());
boolean isOlatAdmin = roles.isOLATAdmin();
boolean isGuestOnly = roles.isGuestOnly();
// Add message id to business path if nodemcd is available
if (nodecmd != null) {
try {
Long messageId = Long.valueOf(nodecmd);
BusinessControlFactory bcf = BusinessControlFactory.getInstance();
BusinessControl businessControl = bcf.createFromString("[Message:" + messageId + "]");
wControl = bcf.createBusinessWindowControl(businessControl, wControl);
} catch (NumberFormatException e) {
// ups, nodecmd is not a message, what the heck is it then?
log.warn("Could not create message ID from given nodemcd::" + nodecmd, e);
}
}
// for guests, check if posting is allowed
boolean pseudonymPostAllowed = false;
boolean defaultPseudonym = false;
boolean guestPostAllowed = false;
if (roles.isGuestOnly()) {
String config = getModuleConfiguration().getStringValue(FOCourseNodeEditController.GUEST_POST_ALLOWED);
guestPostAllowed = "true".equals(config);
} else {
ForumModule forumModule = CoreSpringFactory.getImpl(ForumModule.class);
String config = getModuleConfiguration().getStringValue(FOCourseNodeEditController.PSEUDONYM_POST_ALLOWED);
pseudonymPostAllowed = forumModule.isAnonymousPostingWithPseudonymEnabled() && "true".equals(config);
if (pseudonymPostAllowed) {
defaultPseudonym = getModuleConfiguration().getBooleanSafe(FOCourseNodeEditController.PSEUDONYM_POST_DEFAULT, forumModule.isPseudonymForMessageEnabledByDefault());
}
}
// Create subscription context and run controller
SubscriptionContext forumSubContext = CourseModule.createSubscriptionContext(userCourseEnv.getCourseEnvironment(), this);
ForumCallback foCallback = userCourseEnv.isCourseReadOnly() ? new ReadOnlyForumCallback(ne, isOlatAdmin, isGuestOnly) : new ForumNodeForumCallback(ne, isOlatAdmin, isGuestOnly, guestPostAllowed, pseudonymPostAllowed, defaultPseudonym, forumSubContext);
FOCourseNodeRunController forumC = new FOCourseNodeRunController(ureq, wControl, theForum, foCallback, this);
return new NodeRunConstructionResult(forumC);
}
use of org.olat.core.id.context.BusinessControlFactory in project OpenOLAT by OpenOLAT.
the class ProjectBrokerCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
// Do not allow guests to access tasks
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
String title = trans.translate(NLS_GUESTNOACCESS_TITLE);
String message = trans.translate(NLS_GUESTNOACCESS_MESSAGE);
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// Add message id to business path if nodemcd is available
if (nodecmd != null) {
try {
Long projectId = Long.valueOf(nodecmd);
BusinessControlFactory bcf = BusinessControlFactory.getInstance();
BusinessControl businessControl = bcf.createFromString("[Project:" + projectId + "]");
wControl = bcf.createBusinessWindowControl(businessControl, wControl);
} catch (NumberFormatException e) {
// ups, nodecmd is not a message, what the heck is it then?
log.warn("Could not create message ID from given nodemcd::" + nodecmd, e);
}
}
controller = ProjectBrokerControllerFactory.createRunController(ureq, wControl, userCourseEnv, this);
}
Controller wrapperCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_projectbroker_icon");
return new NodeRunConstructionResult(wrapperCtrl);
}
Aggregations