Search in sources :

Example 86 with ContextEntry

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

the class AssessedBusinessGroupCourseNodeListController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    String resName = entries.get(0).getOLATResourceable().getResourceableTypeName();
    if ("BusinessGroup".equalsIgnoreCase(resName) || "Group".equalsIgnoreCase(resName)) {
        Long groupKey = entries.get(0).getOLATResourceable().getResourceableId();
        BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(groupKey);
        List<ContextEntry> subEntries = entries.subList(1, entries.size());
        doSelect(ureq, businessGroup).activate(ureq, subEntries, entries.get(0).getTransientState());
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 87 with ContextEntry

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

the class GTACoachSelectionController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    String type = entries.get(0).getOLATResourceable().getResourceableTypeName();
    Long key = entries.get(0).getOLATResourceable().getResourceableId();
    if ("Identity".equalsIgnoreCase(type)) {
        if (participantListCtrl != null && participantListCtrl.hasIdentityKey(key)) {
            Identity selectedIdentity = securityManager.loadIdentityByKey(key);
            List<ContextEntry> subEntries = entries.subList(1, entries.size());
            doSelectParticipant(ureq, selectedIdentity).activate(ureq, subEntries, entries.get(0).getTransientState());
        }
    } else if ("BusinessGroup".equalsIgnoreCase(type)) {
        if (groupListCtrl != null) {
            BusinessGroup group = groupListCtrl.getBusinessGroup(key);
            if (group != null) {
                List<ContextEntry> subEntries = entries.subList(1, entries.size());
                doSelectBusinessGroup(ureq, group).activate(ureq, subEntries, entries.get(0).getTransientState());
            }
        }
    } else if ("Solution".equals(type) && entries.size() > 1) {
        String path = BusinessControlFactory.getInstance().getPath(entries.get(1));
        String url = solutionMapperUri + "/" + path;
        solutionDownloadCmp.triggerFileDownload(url);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) List(java.util.List) Identity(org.olat.core.id.Identity) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 88 with ContextEntry

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

the class BusinessGroupArchiver method appendIdentity.

private void appendIdentity(StringBuffer buf, Identity owner, Date addedTo, Translator translator) {
    Locale loc = translator.getLocale();
    // add the identities user name
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(owner);
    String uname = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
    buf.append(uname);
    buf.append(DELIMITER);
    // add all user properties
    for (UserPropertyHandler propertyHandler : getUserPropertyHandlers()) {
        String value = propertyHandler.getUserProperty(owner.getUser(), loc);
        if (StringHelper.containsNonWhitespace(value)) {
            buf.append(value);
        }
        buf.append(DELIMITER);
    }
    // add the added-to date
    buf.append(addedTo.toString());
    buf.append(EOL);
}
Also used : Locale(java.util.Locale) ContextEntry(org.olat.core.id.context.ContextEntry) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 89 with ContextEntry

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

the class DMZDispatcher method execute.

/**
 * Main method called by OpenOLATServlet. This processess all requests for
 * users who are not authenticated.
 *
 * @param request
 * @param response
 * @param uriPrefix
 */
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
    if (rejectRequest(request, response)) {
        return;
    }
    UserRequest ureq = null;
    String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
    try {
        // upon creation URL is checked for
        ureq = new UserRequestImpl(uriPrefix, request, response);
    } catch (NumberFormatException nfe) {
        // a 404 message must be shown -> e.g. robots correct their links.
        if (log.isDebug()) {
            log.debug("Bad Request " + request.getPathInfo());
        }
        DispatcherModule.sendBadRequest(request.getPathInfo(), response);
        return;
    }
    try {
        // find out about which subdispatcher is meant
        // e.g. got here because of /dmz/...
        // maybe something like /dmz/registration/
        // 
        // add the context path to align with uriPrefix e.g. /olat/dmz/
        String pathInfo = request.getContextPath() + request.getPathInfo();
        ChiefControllerCreator subPathccc = null;
        // if /olat/dmz/
        boolean dmzOnly = pathInfo.equals(uriPrefix);
        if (!dmzOnly) {
            int sl = pathInfo.indexOf('/', uriPrefix.length());
            String sub;
            if (sl > 1) {
                // e.g. something like /registration/ or /pwchange/
                sub = pathInfo.substring(uriPrefix.length() - 1, sl + 1);
            } else {
                // e.g. something like /info.html from (/dmz/info.html)
                sub = pathInfo;
            }
            // chief controller creator for sub path, e.g.
            subPathccc = dmzServicesByPath.get(sub);
            if (subPathccc != null) {
                UserSession usess = ureq.getUserSession();
                Windows ws = Windows.getWindows(usess);
                synchronized (ws) {
                    // o_clusterOK by:fj per user session
                    ChiefController occ = subPathccc.createChiefController(ureq);
                    Window window = occ.getWindow();
                    window.setUriPrefix(uriPrefix);
                    ws.registerWindow(window);
                    window.dispatchRequest(ureq, true);
                    return;
                }
            }
        }
        // else a /olat/dmz/ request
        UserSession usess = ureq.getUserSession();
        Windows ws = Windows.getWindows(usess);
        // and make it useless under heavily load or 2 concurrent requests
        synchronized (usess) {
            // o_clusterOK by:fj per user session
            Window window;
            boolean windowHere = ws.isExisting(uriPrefix, ureq.getWindowID());
            boolean validDispatchUri = ureq.isValidDispatchURI();
            if (validDispatchUri && !windowHere) {
                // probably valid framework link from previous user && new Session(no window):
                // when a previous user logged off, and 30min later (when the httpsession is invalidated), the next user clicks e.g. on
                // the log-in link in the -same- browser window ->
                // -> there is no window -> create a new one
                window = null;
                CoreSpringFactory.getImpl(UserSessionManager.class).signOffAndClear(usess);
                usess.setLocale(LocaleNegotiator.getPreferedLocale(ureq));
                // update locale infos
                I18nManager.updateLocaleInfoToThread(usess);
                // request new windows since it is a new usersession, the old one was purged
                ws = Windows.getWindows(usess);
            } else if (validDispatchUri) {
                window = ws.getWindow(ureq);
            } else if (dmzOnly) {
                // e.g. /dmz/ -> start screen, clear previous session data
                window = null;
                CoreSpringFactory.getImpl(UserSessionManager.class).signOffAndClear(usess);
                usess.setLocale(LocaleNegotiator.getPreferedLocale(ureq));
                // update locale infos
                I18nManager.updateLocaleInfoToThread(usess);
                OAuthLoginModule oauthModule = CoreSpringFactory.getImpl(OAuthLoginModule.class);
                if (canRedirectConfigurableOAuth(request, response, oauthModule)) {
                    return;
                } else if (canRedirectOAuth(request, oauthModule)) {
                    OAuthSPI oauthSpi = oauthModule.getRootProvider();
                    HttpSession session = request.getSession();
                    OAuthResource.redirect(oauthSpi, response, session);
                    return;
                }
                // request new windows since it is a new usersession, the old one was purged
                ws = Windows.getWindows(usess);
            } else {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
                return;
            }
            if (window == null) {
                // no window found, -> start a new WorkFlow/Controller and obtain the window
                // main controller which also implements the windowcontroller for pagestatus and modal dialogs
                Object wSettings = usess.getEntry(WINDOW_SETTINGS);
                ChiefController occ = chiefControllerCreator.createChiefController(ureq);
                window = occ.getWindow();
                window.setUriPrefix(uriPrefix);
                ws.registerWindow(window);
                String businessPath = (String) usess.removeEntryFromNonClearedStore(DMZDISPATCHER_BUSINESSPATH);
                if (businessPath != null) {
                    List<ContextEntry> ces = BusinessControlFactory.getInstance().createCEListFromString(businessPath);
                    window.getDTabs().activate(ureq, null, ces);
                }
                // apply the settings forward
                usess.putEntryInNonClearedStore(WINDOW_SETTINGS, wSettings);
            }
            window.dispatchRequest(ureq);
        }
    } catch (InvalidRequestParameterException e) {
        try {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        } catch (IOException e1) {
            log.error("An exception occured while handling the invalid request parameter exception...", e1);
        }
    } catch (Throwable th) {
        try {
            ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, th);
            // the controller's window must be failsafe also
            msgcc.getWindow().dispatchRequest(ureq, true);
        // do not dispatch (render only), since this is a new Window created as
        // a result of another window's click.
        } catch (Throwable t) {
            log.error("An exception occured while handling the exception...", t);
        }
    }
}
Also used : Window(org.olat.core.gui.components.Window) OAuthLoginModule(org.olat.login.oauth.OAuthLoginModule) HttpSession(javax.servlet.http.HttpSession) Windows(org.olat.core.gui.Windows) ChiefController(org.olat.core.gui.control.ChiefController) IOException(java.io.IOException) ContextEntry(org.olat.core.id.context.ContextEntry) UserSessionManager(org.olat.core.util.session.UserSessionManager) InvalidRequestParameterException(org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException) ChiefControllerCreator(org.olat.core.gui.control.ChiefControllerCreator) UserSession(org.olat.core.util.UserSession) OAuthSPI(org.olat.login.oauth.OAuthSPI) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Example 90 with ContextEntry

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

the class QTI12StatisticsToolController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry entry = entries.get(0);
    if (entry.getOLATResourceable() != null && entry.getOLATResourceable().getResourceableTypeName() != null) {
        String nodeId = entry.getOLATResourceable().getResourceableTypeName();
        TreeNode nclr = courseTree.getTreeModel().getNodeById(nodeId);
        if (nclr != null) {
            String selNodeId = nclr.getIdent();
            courseTree.setSelectedNodeId(selNodeId);
            doSelectNode(ureq, nclr);
        }
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

ContextEntry (org.olat.core.id.context.ContextEntry)270 OLATResourceable (org.olat.core.id.OLATResourceable)78 WindowControl (org.olat.core.gui.control.WindowControl)58 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)44 ArrayList (java.util.ArrayList)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 Controller (org.olat.core.gui.control.Controller)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 List (java.util.List)22 Identity (org.olat.core.id.Identity)22 BusinessControl (org.olat.core.id.context.BusinessControl)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)18 HistoryPoint (org.olat.core.id.context.HistoryPoint)18 CollaborationTools (org.olat.collaboration.CollaborationTools)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 UserSession (org.olat.core.util.UserSession)14 CourseNode (org.olat.course.nodes.CourseNode)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)12 Translator (org.olat.core.gui.translator.Translator)12