Search in sources :

Example 46 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class DirectDeleteController method deleteIdentities.

private void deleteIdentities(List<Identity> toDeleteIdentities) {
    for (int i = 0; i < toDeleteIdentities.size(); i++) {
        Identity identity = toDeleteIdentities.get(i);
        UserDeletionManager.getInstance().deleteIdentity(identity);
        DBFactory.getInstance().intermediateCommit();
    }
}
Also used : Identity(org.olat.core.id.Identity)

Example 47 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class SelectionForm method handleEmailButtonEvent.

private void handleEmailButtonEvent(UserRequest ureq, TableMultiSelectEvent tmse) {
    List<Identity> identities = tdm.getObjects(tmse.getSelection());
    if (identities.size() > 0) {
        selectedIdentities = identities;
        MailTemplate deleteMailTemplate = createMailTemplate(translate(KEY_EMAIL_SUBJECT), translate(KEY_EMAIL_BODY));
        deleteMailTemplate.setCpfrom(Boolean.FALSE);
        deleteMailTemplate.addToContext("lastloginduration", Integer.toString(UserDeletionManager.getInstance().getLastLoginDuration()));
        deleteMailTemplate.addToContext("durationdeleteemail", Integer.toString(UserDeletionManager.getInstance().getDeleteEmailDuration()));
        removeAsListenerAndDispose(deleteUserMailCtr);
        deleteUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, deleteMailTemplate, true, false, false);
        listenTo(deleteUserMailCtr);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), deleteUserMailCtr.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
    } else {
        showWarning("nothing.selected.msg");
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 48 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class SelectionForm method initializeTableController.

private void initializeTableController(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
    removeAsListenerAndDispose(tableCtr);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), propertyHandlerTranslator);
    listenTo(tableCtr);
    List<Identity> l = UserDeletionManager.getInstance().getDeletableIdentities(UserDeletionManager.getInstance().getLastLoginDuration());
    tdm = new UserDeleteTableModel(l, ureq.getLocale(), isAdministrativeUser);
    tdm.addColumnDescriptors(tableCtr, null);
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
    tableCtr.addMultiSelectAction("action.delete.selection", ACTION_MULTISELECT_CHOOSE);
    tableCtr.setMultiSelect(true);
    tableCtr.setTableDataModel(tdm);
}
Also used : TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity)

Example 49 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class GroupController method doRemoveIdentitiesFromGroup.

private void doRemoveIdentitiesFromGroup(UserRequest ureq, List<Identity> toBeRemoved, MailTemplate mailTemplate) {
    fireEvent(ureq, new IdentitiesRemoveEvent(toBeRemoved));
    identitiesTableModel.remove(toBeRemoved);
    if (tableCtr != null) {
        // can be null in the follwoing case.
        // the user which does the removal is also in the list of toBeRemoved
        // hence the fireEvent does trigger a disposal of a GroupController, which
        // in turn nullifies the tableCtr... see also OLAT-3331
        tableCtr.modelChanged();
    }
    // send the notification mail
    if (mailTemplate != null) {
        // means no sender in footer
        Identity sender = null;
        if (showSenderInRemovMailFooter) {
            sender = ureq.getIdentity();
        }
        String metaId = UUID.randomUUID().toString();
        MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
        MailerResult result = new MailerResult();
        MailBundle[] bundles = mailManager.makeMailBundles(context, toBeRemoved, mailTemplate, sender, metaId, result);
        result.append(mailManager.sendMessage(bundles));
        if (mailTemplate.getCpfrom()) {
            MailBundle ccBundle = mailManager.makeMailBundle(context, ureq.getIdentity(), mailTemplate, sender, metaId, result);
            result.append(mailManager.sendMessage(ccBundle));
        }
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 50 with Identity

use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.

the class UserImportController method doOpenImportWizard.

private void doOpenImportWizard(UserRequest ureq) {
    // use fallback translator for user property translation
    setTranslator(um.getPropertyHandlerTranslator(getTranslator()));
    userPropertyHandlers = um.getUserPropertyHandlersFor(usageIdentifyer, true);
    Step start = new ImportStep00(ureq, canCreateOLATPassword);
    // callback executed in case wizard is finished.
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest ureq1, WindowControl wControl1, StepsRunContext runContext) {
            // all information to do now is within the runContext saved
            ImportReport report = new ImportReport();
            runContext.put("report", report);
            try {
                if (runContext.containsKey("validImport") && ((Boolean) runContext.get("validImport")).booleanValue()) {
                    // create new users and persist
                    int count = 0;
                    @SuppressWarnings("unchecked") List<TransientIdentity> newIdents = (List<TransientIdentity>) runContext.get("newIdents");
                    Map<TransientIdentity, Identity> newPersistedIdentities = new HashMap<>();
                    for (TransientIdentity newIdent : newIdents) {
                        Identity newIdentity = doCreateAndPersistIdentity(newIdent, report);
                        if (newIdentity != null) {
                            newPersistedIdentities.put(newIdent, newIdentity);
                        }
                        if (++count % 10 == 0) {
                            dbInstance.commitAndCloseSession();
                        }
                    }
                    dbInstance.commitAndCloseSession();
                    Boolean updateUsers = (Boolean) runContext.get("updateUsers");
                    Boolean updatePasswords = (Boolean) runContext.get("updatePasswords");
                    @SuppressWarnings("unchecked") List<UpdateIdentity> updateIdents = (List<UpdateIdentity>) runContext.get("updateIdents");
                    for (UpdateIdentity updateIdent : updateIdents) {
                        doUpdateIdentity(updateIdent, updateUsers, updatePasswords, report);
                        if (++count % 10 == 0) {
                            dbInstance.commitAndCloseSession();
                        }
                    }
                    dbInstance.commitAndCloseSession();
                    @SuppressWarnings("unchecked") List<Long> ownGroups = (List<Long>) runContext.get("ownerGroups");
                    @SuppressWarnings("unchecked") List<Long> partGroups = (List<Long>) runContext.get("partGroups");
                    if ((ownGroups != null && ownGroups.size() > 0) || (partGroups != null && partGroups.size() > 0)) {
                        @SuppressWarnings("unchecked") List<Identity> allIdents = (List<Identity>) runContext.get("idents");
                        Boolean sendMailObj = (Boolean) runContext.get("sendMail");
                        boolean sendmail = sendMailObj == null ? true : sendMailObj.booleanValue();
                        processGroupAdditionForAllIdents(allIdents, ownGroups, partGroups, sendmail);
                    } else {
                        Boolean sendMailObj = (Boolean) runContext.get("sendMail");
                        if (sendMailObj != null && sendMailObj) {
                            sendMailToNewIdentities(newPersistedIdentities);
                        }
                    }
                    report.setHasChanges(true);
                }
            } catch (Exception any) {
                logError("", any);
                report.addError("Unexpected error, see log files or call your system administrator");
            }
            // signal correct completion and tell if changes were made or not.
            return report.isHasChanges() ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
        }
    };
    importStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("title"), "o_sel_user_import_wizard");
    listenTo(importStepsController);
    getWindowControl().pushAsModalDialog(importStepsController.getInitialComponent());
}
Also used : HashMap(java.util.HashMap) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Identity(org.olat.core.id.Identity) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

Identity (org.olat.core.id.Identity)3749 Test (org.junit.Test)1956 RepositoryEntry (org.olat.repository.RepositoryEntry)898 BusinessGroup (org.olat.group.BusinessGroup)560 ArrayList (java.util.ArrayList)550 Date (java.util.Date)312 URI (java.net.URI)272 ICourse (org.olat.course.ICourse)266 HttpResponse (org.apache.http.HttpResponse)260 File (java.io.File)211 AssessmentManager (org.olat.course.assessment.AssessmentManager)210 Path (javax.ws.rs.Path)182 OLATResource (org.olat.resource.OLATResource)172 OLATResourceable (org.olat.core.id.OLATResourceable)156 Roles (org.olat.core.id.Roles)154 HashMap (java.util.HashMap)151 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)142 HashSet (java.util.HashSet)136 List (java.util.List)132 Produces (javax.ws.rs.Produces)130