Search in sources :

Example 71 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class ResumeController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    savePreferences(ureq, "auto");
    fireEvent(ureq, Event.DONE_EVENT);
    HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
    if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
        List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
        BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(cloneCes);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        try {
            // make the resume secure. If something fail, don't generate a red screen
            NewControllerFactory.getInstance().launch(ureq, bwControl);
        } catch (Exception e) {
            logError("Error while resumging", e);
        }
    }
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 72 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

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);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) Roles(org.olat.core.id.Roles) FOCourseNodeRunController(org.olat.course.nodes.fo.FOCourseNodeRunController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) Forum(org.olat.modules.fo.Forum) ForumModule(org.olat.modules.fo.ForumModule) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) ForumCallback(org.olat.modules.fo.ForumCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 73 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class ValidatingVisitor method appendDispatchDebugInfos.

private void appendDispatchDebugInfos(Component target, StringBuilder debugMsg) {
    Controller c = target.getLatestDispatchedController();
    if (c != null) {
        WindowControl wCo = null;
        try {
            wCo = c.getWindowControlForDebug();
        } catch (Exception e) {
        // getWindowControl throw an Assertion if wControl = null
        }
        if (wCo != null) {
            String coInfo = "";
            WindowControlInfo wci = wCo.getWindowControlInfo();
            while (wci != null) {
                String cName = wci.getControllerClassName();
                coInfo = cName + ":" + coInfo;
                wci = wci.getParentWindowControlInfo();
            }
            BusinessControl bc = wCo.getBusinessControl();
            String businessPath = bc == null ? "n/a" : bc.getAsString();
            String compName = target.getComponentName();
            String msg = "wci:" + coInfo + "%%" + compName + "%%" + businessPath + "%%";
            // allowed for debugging, dispatching is already over
            Event ev = target.getAndClearLatestFiredEvent();
            if (ev != null) {
                msg += ev.getClass().getName() + ":" + ev.getCommand() + "%%";
            }
            String targetInfo = target.getExtendedDebugInfo();
            msg += targetInfo + "%%";
            debugMsg.append(msg).append(LOG_SEPARATOR);
        } else {
        // no windowcontrol -> ignore
        }
    }
// else: a component with -no- controller as listener, makes no sense in 99.99% of the cases; ignore in those rare cases
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) Event(org.olat.core.gui.control.Event) ChiefController(org.olat.core.gui.control.ChiefController) Controller(org.olat.core.gui.control.Controller) WindowControl(org.olat.core.gui.control.WindowControl) AssertException(org.olat.core.logging.AssertException) JSONException(org.json.JSONException) InvalidRequestParameterException(org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) IOException(java.io.IOException) WindowControlInfo(org.olat.core.gui.control.info.WindowControlInfo)

Example 74 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class DisposedCourseRestartController method event.

/**
 * @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
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == restartLink) {
        OLATResourceable ores = OLATResourceManager.getInstance().findResourceable(courseRepositoryEntry.getOlatResource().getResourceableId(), courseRepositoryEntry.getOlatResource().getResourceableTypeName());
        if (ores == null) {
            // course was deleted!
            MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.deleted.title"), translate("course.deleted.text"));
            panel.setContent(msgController.getInitialComponent());
        } else {
            OLATResourceable reOres = OresHelper.clone(courseRepositoryEntry);
            DTabs dtabs = getWindowControl().getWindowBackOffice().getWindow().getDTabs();
            if (dtabs != null) {
                DTab dt = dtabs.getDTab(reOres);
                if (dt != null) {
                    dtabs.removeDTab(ureq, dt);
                }
            }
            List<ContextEntry> entries = null;
            List<HistoryPoint> stacks = ureq.getUserSession().getHistoryStack();
            for (int i = stacks.size(); i-- > 0; ) {
                HistoryPoint point = stacks.get(i);
                if (point != null && point.getEntries() != null && point.getEntries().size() > 0) {
                    ContextEntry entry = point.getEntries().get(0);
                    if (reOres.equals(entry.getOLATResourceable())) {
                        entries = point.getEntries();
                        break;
                    }
                }
            }
            WindowControl bwControl;
            if (entries == null) {
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(getWindowControl(), reOres);
            } else {
                BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(entries);
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
            }
            NewControllerFactory.getInstance().launch(ureq, bwControl);
            dispose();
        }
    }
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) MessageController(org.olat.core.gui.control.generic.messages.MessageController) OLATResourceable(org.olat.core.id.OLATResourceable) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 75 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class EfficiencyStatementAssessmentController method openConfiguration.

private void openConfiguration(UserRequest ureq) {
    String resourceUrl = "[RepositoryEntry:" + courseEntry.getKey() + "][CertificationSettings:0]";
    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
    NewControllerFactory.getInstance().launch(ureq, bwControl);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl)

Aggregations

BusinessControl (org.olat.core.id.context.BusinessControl)80 WindowControl (org.olat.core.gui.control.WindowControl)56 OLATResourceable (org.olat.core.id.OLATResourceable)24 ContextEntry (org.olat.core.id.context.ContextEntry)22 RepositoryEntry (org.olat.repository.RepositoryEntry)16 ArrayList (java.util.ArrayList)14 Controller (org.olat.core.gui.control.Controller)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 Window (org.olat.core.gui.components.Window)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 CourseNode (org.olat.course.nodes.CourseNode)6 Date (java.util.Date)4 UserRequest (org.olat.core.gui.UserRequest)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)4 Identity (org.olat.core.id.Identity)4 Roles (org.olat.core.id.Roles)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 IOException (java.io.IOException)3