Search in sources :

Example 16 with Identity

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

the class MailManagerImpl method appendRecipients.

private void appendRecipients(DBMailImpl mail, List<ContactList> ccLists, List<Address> toAddress, List<Address> ccAddress, boolean visible, boolean makeRealMail, MailerResult result) throws AddressException {
    // append cc/bcc recipients
    if (ccLists != null && !ccLists.isEmpty()) {
        for (ContactList contactList : ccLists) {
            if (makeRealMail && StringHelper.containsNonWhitespace(contactList.getName())) {
                Address[] groupAddress = InternetAddress.parse(contactList.getRFC2822Name() + ";");
                if (groupAddress != null && groupAddress.length > 0) {
                    for (Address groupAdd : groupAddress) {
                        toAddress.add(groupAdd);
                    }
                }
            }
            for (String email : contactList.getStringEmails().values()) {
                DBMailRecipient recipient = new DBMailRecipient();
                recipient.setEmailAddress(email);
                recipient.setGroup(contactList.getName());
                recipient.setVisible(visible);
                recipient.setDeleted(Boolean.FALSE);
                recipient.setMarked(Boolean.FALSE);
                recipient.setRead(Boolean.FALSE);
                mail.getRecipients().add(recipient);
                if (makeRealMail) {
                    createAddress(ccAddress, recipient, false, result, false);
                }
            }
            for (Identity identityEmail : contactList.getIdentiEmails().values()) {
                DBMailRecipient recipient = new DBMailRecipient();
                if (identityEmail instanceof IdentityImpl) {
                    recipient.setRecipient(identityEmail);
                } else {
                    recipient.setEmailAddress(identityEmail.getUser().getProperty(UserConstants.EMAIL, null));
                }
                recipient.setGroup(contactList.getName());
                recipient.setVisible(visible);
                recipient.setDeleted(Boolean.FALSE);
                recipient.setMarked(Boolean.FALSE);
                recipient.setRead(Boolean.FALSE);
                mail.getRecipients().add(recipient);
                if (makeRealMail) {
                    createAddress(ccAddress, recipient, false, result, false);
                }
            }
        }
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) Address(javax.mail.Address) IdentityImpl(org.olat.basesecurity.IdentityImpl) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) DBMailRecipient(org.olat.core.util.mail.model.DBMailRecipient)

Example 17 with Identity

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

the class SendDocumentsByEMailController method addIdentity.

private void addIdentity(SingleIdentityChosenEvent foundEvent) {
    Identity chosenIdentity = foundEvent.getChosenIdentity();
    if (chosenIdentity != null) {
        addIdentity(chosenIdentity);
    }
    userListBox.setDirty(true);
}
Also used : Identity(org.olat.core.id.Identity)

Example 18 with Identity

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

the class ModifyCourseEvent method archiveCourse.

/**
 * visit all nodes in the specified course and make them archiving any data
 * into the identity's export directory.
 *
 * @param res
 * @param charset
 * @param locale
 * @param identity
 */
public static void archiveCourse(Identity archiveOnBehalfOf, ICourse course, String charset, Locale locale, File exportDirectory, boolean isOLATAdmin, boolean... oresRights) {
    // archive course results overview
    List<Identity> users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment());
    List<AssessableCourseNode> nodes = ScoreAccountingHelper.loadAssessableNodes(course.getCourseEnvironment());
    String fileName = ExportUtil.createFileNameWithTimeStamp(course.getCourseTitle(), "zip");
    try (OutputStream out = new FileOutputStream(new File(exportDirectory, fileName));
        ZipOutputStream zout = new ZipOutputStream(out)) {
        ScoreAccountingHelper.createCourseResultsOverview(users, nodes, course, locale, zout);
    } catch (IOException e) {
        log.error("", e);
    }
    // archive all nodes content
    Visitor archiveV = new NodeArchiveVisitor(locale, course, exportDirectory, charset);
    TreeVisitor tv = new TreeVisitor(archiveV, course.getRunStructure().getRootNode(), true);
    tv.visitAll();
    // archive all course log files
    // OLATadmin gets all logfiles independent of the visibility configuration
    boolean isOresOwner = (oresRights.length > 0) ? oresRights[0] : false;
    boolean isOresInstitutionalManager = (oresRights.length > 1) ? oresRights[1] : false;
    boolean aLogV = isOresOwner || isOresInstitutionalManager || isOLATAdmin;
    boolean uLogV = isOLATAdmin;
    boolean sLogV = isOresOwner || isOresInstitutionalManager || isOLATAdmin;
    // make an intermediate commit here to make sure long running course log export doesn't
    // cause db connection timeout to be triggered
    // @TODO transactions/backgroundjob:
    // rework when backgroundjob infrastructure exists
    DBFactory.getInstance().intermediateCommit();
    AsyncExportManager.getInstance().asyncArchiveCourseLogFiles(archiveOnBehalfOf, new Runnable() {

        @Override
        public void run() {
        // that's fine, I dont need to do anything here
        }
    }, course.getResourceableId(), exportDirectory.getPath(), null, null, aLogV, uLogV, sLogV, charset, null, null);
    course.getCourseEnvironment().getCourseGroupManager().archiveCourseGroups(exportDirectory);
    CoreSpringFactory.getImpl(ChatLogHelper.class).archive(course, exportDirectory);
}
Also used : ChatLogHelper(org.olat.instantMessaging.manager.ChatLogHelper) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) TreeVisitor(org.olat.core.util.tree.TreeVisitor) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) Identity(org.olat.core.id.Identity) File(java.io.File)

Example 19 with Identity

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

the class ScoreAccountingArchiveController method doStartExport.

private void doStartExport() {
    ICourse course = CourseFactory.loadCourse(ores);
    List<Identity> users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment());
    List<AssessableCourseNode> nodes = ScoreAccountingHelper.loadAssessableNodes(course.getCourseEnvironment());
    String courseTitle = course.getCourseTitle();
    String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "zip");
    // location for data export
    File exportDirectory = CourseFactory.getOrCreateDataExportDirectory(getIdentity(), courseTitle);
    File downloadFile = new File(exportDirectory, fileName);
    try (OutputStream fOut = new FileOutputStream(downloadFile);
        ZipOutputStream zout = new ZipOutputStream(fOut)) {
        ScoreAccountingHelper.createCourseResultsOverview(users, nodes, course, getLocale(), zout);
    } catch (IOException e) {
        logError("", e);
    }
    vcFeedback = createVelocityContainer("feedback");
    vcFeedback.contextPut("body", translate("course.res.feedback", new String[] { downloadFile.getName() }));
    downloadButton = LinkFactory.createButtonSmall("cmd.download", vcFeedback, this);
    downloadButton.setUserObject(downloadFile);
    myPanel.setContent(vcFeedback);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ICourse(org.olat.course.ICourse) IOException(java.io.IOException) Identity(org.olat.core.id.Identity) File(java.io.File)

Example 20 with Identity

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

the class VersionsFileManager method delete.

@Override
public boolean delete(VFSItem item, boolean force) {
    if (item instanceof VFSContainer) {
        if (force) {
            VFSContainer container = (VFSContainer) item;
            VFSContainer versionContainer = getCanonicalVersionFolder(container, false);
            if (versionContainer == null) {
                return true;
            }
            return VFSConstants.YES.equals(versionContainer.delete());
        }
        return true;
    } else if (item instanceof VFSLeaf && item instanceof Versionable) {
        VFSLeaf leaf = (VFSLeaf) item;
        if (force || isTemporaryFile(leaf)) {
            cleanUp(leaf);
        } else {
            Identity identity = ThreadLocalUserActivityLogger.getLoggedIdentity();
            addToRevisions((Versionable) leaf, identity, null);
        }
    }
    return false;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) Identity(org.olat.core.id.Identity)

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