use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class InfoMessageFrontendManagerImpl method sendInfoMessage.
@Override
public boolean sendInfoMessage(InfoMessage infoMessage, MailFormatter mailFormatter, Locale locale, Identity from, List<Identity> tos) {
infoMessageManager.saveInfoMessage(infoMessage);
boolean send = false;
if (tos != null && !tos.isEmpty()) {
Set<Long> identityKeySet = new HashSet<Long>();
ContactList contactList = new ContactList("Infos");
for (Identity to : tos) {
if (identityKeySet.contains(to.getKey()))
continue;
contactList.add(to);
identityKeySet.add(to.getKey());
}
try {
String subject = null;
String body = null;
if (mailFormatter != null) {
subject = mailFormatter.getSubject(infoMessage);
body = mailFormatter.getBody(infoMessage);
}
if (!StringHelper.containsNonWhitespace(subject)) {
subject = infoMessage.getTitle();
}
if (!StringHelper.containsNonWhitespace(body)) {
body = infoMessage.getMessage();
}
File attachment = null;
if (StringHelper.containsNonWhitespace(infoMessage.getAttachmentPath())) {
File root = getStoragePath().getBasefile();
attachment = new File(root, infoMessage.getAttachmentPath());
}
MailContext context = new MailContextImpl(mailFormatter.getBusinessPath());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setFromId(from);
bundle.setContactList(contactList);
if (attachment != null) {
bundle.setContent(subject, body, attachment);
} else {
bundle.setContent(subject, body);
}
MailerResult result = mailManager.sendMessage(bundle);
send = result.isSuccessful();
} catch (Exception e) {
log.error("Cannot send info messages", e);
}
}
infoSubscriptionManager.markPublisherNews(infoMessage.getOLATResourceable(), infoMessage.getResSubPath());
MultiUserEvent mue = new MultiUserEvent("new_info_message");
coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mue, oresFrontend);
return send;
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class LanguageChooserController method formInnerEvent.
/**
* @see org.olat.core.gui.components.form.flexible.FormDefaultController#formInnerEvent(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.form.flexible.FormItem,
* org.olat.core.gui.components.form.flexible.FormEvent)
*/
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
Locale loc = I18nManager.getInstance().getLocaleOrDefault(getSelectedLanguage());
MultiUserEvent mue = new LanguageChangedEvent(loc, ureq);
ureq.getUserSession().setLocale(loc);
ureq.getUserSession().putEntry("negotiated-locale", loc);
I18nManager.updateLocaleInfoToThread(ureq.getUserSession());
OLATResourceable wrappedLocale = OresHelper.createOLATResourceableType(Locale.class);
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(mue, wrappedLocale);
// Update in velocity for flag
flc.contextPut("languageCode", loc.toString());
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class EditorMainController method launchPublishingWizard.
private void launchPublishingWizard(UserRequest ureq, ICourse course, boolean requestOnClose) {
// ignore enter
if (publishStepsController != null)
return;
/*
* start follwoing steps -> cancel wizardf does not touch data
* (M) Mandatory (O) Optional
* - (M)Step 00 -> show selection tree to choose changed nodes to be published
* ...........-> calculate errors & warnings
* ...........(next|finish) available if no errors or nothing to publish
* - (O)Step 00A -> review errors & warnings
* ...........(previous|next|finish) available
* - (O)Step 00B -> review publish changes that will happen
* ...........(previous|next|finish) available
* - (O)Step 01 -> change general access to course
* ...........(previous|finish) available
* - FinishCallback -> apply course nodes change set
* .................-> apply general access changes.
*/
Step start = new PublishStep00(ureq, cetm, course);
/*
* 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
boolean hasChanges = false;
PublishProcess publishManager = (PublishProcess) runContext.get("publishProcess");
PublishEvents publishEvents = publishManager.getPublishEvents();
if (runContext.containsKey("validPublish") && ((Boolean) runContext.get("validPublish")).booleanValue()) {
@SuppressWarnings("unchecked") Collection<String> selectedNodeIds = (Collection<String>) runContext.get("publishSetCreatedFor");
hasChanges = (selectedNodeIds != null) && (selectedNodeIds.size() > 0);
if (hasChanges) {
publishManager.applyPublishSet(ureq1.getIdentity(), ureq1.getLocale(), false);
}
}
if (runContext.containsKey("accessAndProperties")) {
CourseAccessAndProperties accessAndProperties = (CourseAccessAndProperties) runContext.get("accessAndProperties");
// fires an EntryChangedEvent for repository entry notifying
// about modification.
publishManager.changeAccessAndProperties(getIdentity(), accessAndProperties);
hasChanges = true;
}
CourseCatalog courseCatalog = (CourseCatalog) runContext.get("categories");
if (courseCatalog != null) {
publishManager.publishToCatalog(courseCatalog.getChoiceValue(), courseCatalog.getCategoryLabels());
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, ores);
}
}
// signal correct completion and tell if changes were made or not.
return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
}
};
publishStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("publish.wizard.title"), "o_sel_course_publish_wizard");
listenTo(publishStepsController);
publishStepsController.getRunContext().put("requestOnClose", requestOnClose);
getWindowControl().pushAsModalDialog(publishStepsController.getInitialComponent());
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class QuickPublishController method doAutoPublish.
private boolean doAutoPublish() {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
if (publishTreeModel.hasPublishableChanges()) {
List<String> nodeToPublish = new ArrayList<String>();
visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
// only add selection if changes were possible
for (Iterator<String> selectionIt = nodeToPublish.iterator(); selectionIt.hasNext(); ) {
String ident = selectionIt.next();
TreeNode node = publishProcess.getPublishTreeModel().getNodeById(ident);
if (!publishTreeModel.isSelectable(node)) {
selectionIt.remove();
}
}
publishProcess.createPublishSetFor(nodeToPublish);
PublishSetInformations set = publishProcess.testPublishSet(getLocale());
StatusDescription[] status = set.getWarnings();
// publish not possible when there are errors
StringBuilder errMsg = new StringBuilder();
for (int i = 0; i < status.length; i++) {
if (status[i].isError()) {
errMsg.append(status[i].getLongDescription(getLocale()));
logError("Status error by publish: " + status[i].getLongDescription(getLocale()), null);
}
}
if (errMsg.length() > 0) {
getWindowControl().setWarning(errMsg.toString());
return false;
}
PublishEvents publishEvents = publishProcess.getPublishEvents();
try {
publishProcess.applyPublishSet(getIdentity(), getLocale(), false);
} catch (Exception e) {
logError("", e);
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, courseOres);
}
}
}
return true;
}
use of org.olat.core.util.event.MultiUserEvent in project OpenOLAT by OpenOLAT.
the class AuthoringEditAccessController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == propPupForm) {
if (event == Event.DONE_EVENT) {
// inform user about inconsistent configuration: doesn't make sense to set a repositoryEntry canReference=true if it is only accessible to owners
if (!entry.getCanReference() && propPupForm.canReference() && (propPupForm.getAccess() < RepositoryEntry.ACC_OWNERS_AUTHORS && !propPupForm.isMembersOnly())) {
showError("warn.config.reference.no.access");
}
int access = propPupForm.getAccess();
int numOfBookingConfigs = acCtr.getNumOfBookingConfigurations();
entry = repositoryManager.setAccessAndProperties(entry, access, propPupForm.isMembersOnly(), propPupForm.canCopy(), propPupForm.canReference(), propPupForm.canDownload());
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
boolean managedBookings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.bookings);
if (access == RepositoryEntry.ACC_USERS || access == RepositoryEntry.ACC_USERS_GUESTS) {
if ((!managedBookings && acModule.isEnabled()) || numOfBookingConfigs > 0) {
editproptabpubVC.put("accesscontrol", acCtr.getInitialComponent());
editproptabpubVC.contextPut("isGuestAccess", Boolean.valueOf(access == RepositoryEntry.ACC_USERS_GUESTS));
}
} else {
editproptabpubVC.remove(acCtr.getInitialComponent());
}
// inform anybody interested about this change
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authoring");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (source == leaveForm) {
if (event == Event.DONE_EVENT) {
RepositoryEntryAllowToLeaveOptions leaveSetting = leaveForm.getSelectedLeaveSetting();
entry = repositoryManager.setLeaveSetting(entry, leaveSetting);
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authorings");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (acCtr == source) {
if (event == Event.CHANGED_EVENT) {
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
}
Aggregations