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);
}
}
}
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations