Search in sources :

Example 6 with UserSearchController

use of org.olat.admin.user.UserSearchController in project openolat by klemens.

the class GuiDemoFloatingPanelController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == open) {
        UserSearchController userSearch = new UserSearchController(ureq, getWindowControl(), true);
        dialog = new FloatingResizableDialogController(ureq, getWindowControl(), userSearch.getInitialComponent(), "Your title", 350, 350, 400, 200, null, "", true, false);
        dialog.addControllerListener(this);
        panelVc.put("panel", dialog.getInitialComponent());
        panel.setContent(panelVc);
    } else if (source == open2) {
        dialog = new FloatingResizableDialogController(ureq, getWindowControl(), localContent, "Your title", 350, 350, 400, 200, createVelocityContainer("localContent2"), "", true, false);
        dialog.addControllerListener(this);
        panelVc.put("panel", dialog.getInitialComponent());
        contentLink = LinkFactory.createLink("link4", localContent, this);
        panel.setContent(panelVc);
    } else if (source == contentLink) {
        getWindowControl().setInfo("Congratulations! You won a trip to Lorem Ipsum.");
    }
}
Also used : FloatingResizableDialogController(org.olat.core.gui.control.floatingresizabledialog.FloatingResizableDialogController) UserSearchController(org.olat.admin.user.UserSearchController)

Example 7 with UserSearchController

use of org.olat.admin.user.UserSearchController in project openolat by klemens.

the class LDAPAdminController 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 == syncStartLink) {
        // Start sync job
        // Disable start link during sync
        syncStartLink.setEnabled(false);
        LDAPEvent ldapEvent = new LDAPEvent(LDAPEvent.DO_SYNCHING);
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ldapEvent, LDAPLoginManager.ldapSyncLockOres);
        showInfo("admin.synchronize.started");
    } else if (source == syncOneUserLink) {
        userSearchCtrl = new UserSearchController(ureq, getWindowControl(), false);
        listenTo(userSearchCtrl);
        calloutCtr = new CloseableCalloutWindowController(ureq, getWindowControl(), userSearchCtrl.getInitialComponent(), syncOneUserLink, null, true, null);
        calloutCtr.addDisposableChildController(userSearchCtrl);
        calloutCtr.activate();
        listenTo(calloutCtr);
    } else if (source == deletStartLink) {
        // cancel if some one else is making sync or delete job
        if (!ldapLoginManager.acquireSyncLock()) {
            showError("delete.error.lock");
        } else {
            deletStartLink.setEnabled(false);
            // check and get LDAP connection
            LdapContext ctx = ldapLoginManager.bindSystem();
            if (ctx == null) {
                showError("delete.error.connection");
                return;
            }
            // get deleted users
            identitiesToDelete = ldapLoginManager.getIdentitysDeletedInLdap(ctx);
            try {
                ctx.close();
            } catch (NamingException e) {
                showError("delete.error.connection.close");
                logError("Could not close LDAP connection on manual delete sync", e);
            }
            if (identitiesToDelete != null && identitiesToDelete.size() != 0) {
                hasIdentitiesToDelete = true;
                /*
					 * start step which spawns the whole wizard
					 */
                Step start = new DeletStep00(ureq, hasIdentitiesToDelete, identitiesToDelete);
                /*
					 * wizard finish callback called after "finish" is called
					 */
                StepRunnerCallback finishCallback = new StepRunnerCallback() {

                    public Step execute(UserRequest uureq, WindowControl control, StepsRunContext runContext) {
                        hasIdentitiesToDeleteAfterRun = ((Boolean) runContext.get("hasIdentitiesToDelete")).booleanValue();
                        if (hasIdentitiesToDeleteAfterRun) {
                            @SuppressWarnings("unchecked") List<Identity> idToDelete = (List<Identity>) runContext.get("identitiesToDelete");
                            amountUsersToDelete = idToDelete.size();
                            // Delete all identities now and tell everybody that
                            // we are finished
                            ldapLoginManager.deletIdentities(idToDelete);
                            return StepsMainRunController.DONE_MODIFIED;
                        } else {
                            return StepsMainRunController.DONE_UNCHANGED;
                        }
                    // otherwise return without deleting anything
                    }
                };
                deleteStepController = new StepsMainRunController(ureq, getWindowControl(), start, finishCallback, null, translate("admin.deleteUser.title"), "o_sel_ldap_delete_user_wizard");
                listenTo(deleteStepController);
                getWindowControl().pushAsModalDialog(deleteStepController.getInitialComponent());
            } else {
                hasIdentitiesToDelete = false;
                showInfo("delete.step.noUsers");
                deletStartLink.setEnabled(true);
                ldapLoginManager.freeSyncLock();
            }
        }
    } else if (source == removeFallBackAuthsLink) {
        removeFallBackAuthsLink.setEnabled(false);
        ldapLoginManager.removeFallBackAuthentications();
        showInfo("opsuccess");
    }
}
Also used : CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) Step(org.olat.core.gui.control.generic.wizard.Step) UserSearchController(org.olat.admin.user.UserSearchController) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) LDAPEvent(org.olat.ldap.LDAPEvent) NamingException(javax.naming.NamingException) List(java.util.List) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Identity(org.olat.core.id.Identity) LdapContext(javax.naming.ldap.LdapContext) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 8 with UserSearchController

use of org.olat.admin.user.UserSearchController in project openolat by klemens.

the class ClusterAdminControllerCluster method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == syncLong) {
        // sync on a olatresourceable and hold the lock for 5 seconds.
        CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {

            public void execute() {
                sleep(5000);
            }
        });
        // the runnable is executed within the same thread->
        getWindowControl().setInfo("done syncing on the test olatresourceable for 5 seconds");
    } else if (source == syncShort) {
        // sync on a olatresourceable and hold the lock for 1 second.
        CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {

            public void execute() {
                sleep(1000);
            }
        });
        // the runnable is executed within the same thread->
        getWindowControl().setInfo("done syncing on the test olatresourceable for 1 second");
    } else if (source == testPerf) {
        // send 1000 (short) messages over the cluster bus
        int cnt = 1000;
        long start = System.nanoTime();
        for (int i = 0; i < cnt; i++) {
            clusBus.fireEventToListenersOf(new MultiUserEvent("jms-perf-test-" + i + " of " + cnt), ORES_TEST);
        }
        long stop = System.nanoTime();
        long dur = stop - start;
        double inmilis = dur / 1000000;
        double avg = dur / cnt;
        double avgmilis = avg / 1000000;
        getWindowControl().setInfo("sending " + cnt + " messages took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
    } else if (source == testCachePut) {
        CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
        // we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
        cw.update("akey", "hello");
        updateCacheInfo();
    } else if (source == testCachePut2) {
        // we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
        CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
        cw.update("akey", "world");
        updateCacheInfo();
    } else if (source == testSFUPerf) {
        // acquire a sync 1000x times (does internally a select-for-update on the database)
        int cnt = 1000;
        long start = System.nanoTime();
        for (int i = 0; i < cnt; i++) {
            CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {

                public void execute() {
                // empty
                }
            });
        }
        long stop = System.nanoTime();
        long dur = stop - start;
        double inmilis = dur / 1000000;
        double avg = dur / cnt;
        double avgmilis = avg / 1000000;
        getWindowControl().setInfo("acquiring " + cnt + " locks for syncing (using db's \"select for update\") took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
    } else if (source == releaseAllLocksFor) {
        // let a user search pop up
        usc = new UserSearchController(ureq, getWindowControl(), true);
        listenTo(usc);
        getWindowControl().pushAsModalDialog(usc.getInitialComponent());
    } else if ((source == nodeInfoVc) && (event.getCommand().equals("switchToNode"))) {
        String nodeIdStr = ureq.getHttpReq().getParameter("nodeId");
        if (nodeIdStr.length() == 1) {
            nodeIdStr = "0" + nodeIdStr;
        }
        Cookie[] cookies = ureq.getHttpReq().getCookies();
        for (int i = 0; i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            if ("JSESSIONID".equals(cookie.getName())) {
                String redirectedButInvalidSessionId = cookie.getValue();
                redirectedButInvalidSessionId = redirectedButInvalidSessionId.substring(0, redirectedButInvalidSessionId.length() - 2) + nodeIdStr;
                logInfo("redirecting session to node " + nodeIdStr + ", new sessionid=" + redirectedButInvalidSessionId, null);
                cookie.setValue(redirectedButInvalidSessionId);
                replaceCookie(ureq.getHttpReq(), ureq.getHttpResp(), cookie);
                // OLAT-5165: make sure we can always bypass the dmz reject mechanism (for 5min that is)
                Cookie newCookie = new Cookie("bypassdmzreject", String.valueOf(System.currentTimeMillis()));
                // 5min lifetime
                newCookie.setMaxAge(5 * 60);
                newCookie.setPath(WebappHelper.getServletContextPath());
                newCookie.setSecure(ureq.getHttpReq().isSecure());
                newCookie.setComment("cookie allowing olat admin users to bypass dmz rejects");
                ureq.getHttpResp().addCookie(newCookie);
                OncePanel oncePanel = new OncePanel("refresh");
                oncePanel.setContent(createVelocityContainer("refresh"));
                mainVc.put("refresh", oncePanel);
                break;
            }
        }
    } else if (source == toggleStartStop) {
        clusBus.resetStats();
        updatePerfInfos();
    } else if (source == resetStats) {
        clusBus.resetStats();
        updatePerfInfos();
    }
}
Also used : Cookie(javax.servlet.http.Cookie) CacheWrapper(org.olat.core.util.cache.CacheWrapper) OncePanel(org.olat.core.gui.components.panel.OncePanel) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) UserSearchController(org.olat.admin.user.UserSearchController) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 9 with UserSearchController

use of org.olat.admin.user.UserSearchController in project OpenOLAT by OpenOLAT.

the class TaxonomyLevelCompetenceController method doSearchUsersToAdd.

private void doSearchUsersToAdd(UserRequest ureq, TaxonomyCompetenceTypes comptenceType) {
    if (userSearchCtrl != null)
        return;
    userSearchCtrl = new UserSearchController(ureq, getWindowControl(), true, true, false);
    userSearchCtrl.setUserObject(comptenceType);
    listenTo(userSearchCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), userSearchCtrl.getInitialComponent(), true, translate("add.competence." + comptenceType.name()));
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) UserSearchController(org.olat.admin.user.UserSearchController)

Example 10 with UserSearchController

use of org.olat.admin.user.UserSearchController in project OpenOLAT by OpenOLAT.

the class EPShareListController method doSelectIdentity.

protected void doSelectIdentity(UserRequest ureq, EPSharePolicyWrapper wrapper) {
    removeAsListenerAndDispose(selectUserCtrl);
    selectUserCtrl = new UserSearchController(ureq, getWindowControl());
    selectUserCtrl.setUserObject(wrapper);
    listenTo(selectUserCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), selectUserCtrl.getInitialComponent(), true, translate("choose.identity"));
    cmc.activate();
    listenTo(cmc);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) UserSearchController(org.olat.admin.user.UserSearchController)

Aggregations

UserSearchController (org.olat.admin.user.UserSearchController)24 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 Component (org.olat.core.gui.components.Component)4 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NamingException (javax.naming.NamingException)2 LdapContext (javax.naming.ldap.LdapContext)2 Cookie (javax.servlet.http.Cookie)2 GroupRoles (org.olat.basesecurity.GroupRoles)2 UserRequest (org.olat.core.gui.UserRequest)2 OncePanel (org.olat.core.gui.components.panel.OncePanel)2 TextComponent (org.olat.core.gui.components.text.TextComponent)2 WindowControl (org.olat.core.gui.control.WindowControl)2 FloatingResizableDialogController (org.olat.core.gui.control.floatingresizabledialog.FloatingResizableDialogController)2 Step (org.olat.core.gui.control.generic.wizard.Step)2 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 Identity (org.olat.core.id.Identity)2