Search in sources :

Example 6 with SubscriptionContext

use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.

the class MailManagerImpl method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    VFSContainer root = mailModule.getRootForAttachments();
    attachmentStorage = new FileStorage(root);
    PublisherData pdata = getPublisherData();
    SubscriptionContext scontext = getSubscriptionContext();
    notificationsManager.getOrCreatePublisher(scontext, pdata);
    Properties p = null;
    try {
        velocityEngine = new VelocityEngine();
        p = new Properties();
        p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
        p.setProperty(RuntimeConstants.RESOURCE_MANAGER_CACHE_CLASS, "org.olat.core.gui.render.velocity.InfinispanResourceCache");
        p.setProperty("runtime.log.logsystem.log4j.category", "syslog");
        velocityEngine.init(p);
    } catch (Exception e) {
        throw new RuntimeException("config error " + p.toString());
    }
}
Also used : VelocityEngine(org.apache.velocity.app.VelocityEngine) VFSContainer(org.olat.core.util.vfs.VFSContainer) FileStorage(org.olat.core.util.vfs.FileStorage) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Properties(java.util.Properties) PublisherData(org.olat.core.commons.services.notifications.PublisherData) SendFailedException(javax.mail.SendFailedException) ParseErrorException(org.apache.velocity.exception.ParseErrorException) IOException(java.io.IOException) ResourceNotFoundException(org.apache.velocity.exception.ResourceNotFoundException) MessagingException(javax.mail.MessagingException) MethodInvocationException(org.apache.velocity.exception.MethodInvocationException) AddressException(javax.mail.internet.AddressException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 7 with SubscriptionContext

use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method clearCalenderSubscriptions.

/**
 * Checks all learning group calendars and the course calendar for publishers (of subscriptions)
 * and sets their state to "1" which indicates that the ressource is deleted.
 */
private static void clearCalenderSubscriptions(OLATResourceable res, ICourse course) {
    // set Publisher state to 1 (= ressource is deleted) for all calendars of the course
    CalendarManager calMan = CoreSpringFactory.getImpl(CalendarManager.class);
    CalendarNotificationManager notificationManager = CoreSpringFactory.getImpl(CalendarNotificationManager.class);
    NotificationsManager nfm = NotificationsManager.getInstance();
    if (course != null) {
        CourseGroupManager courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
        List<BusinessGroup> learningGroups = courseGroupManager.getAllBusinessGroups();
        // all learning and right group calendars
        for (BusinessGroup bg : learningGroups) {
            KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
            SubscriptionContext subsContext = notificationManager.getSubscriptionContext(calRenderWrapper);
            Publisher pub = nfm.getPublisher(subsContext);
            if (pub != null) {
                // int 0 is OK -> all other is not OK
                pub.setState(1);
            }
        }
    }
    // the course calendar
    try {
        /**
         * TODO:gs 2010-01-26
         * OLAT-4947: if we do not have an repo entry we get an exception here.
         * This is normal in the case of courseimport and click canceling.
         */
        KalendarRenderWrapper courseCalendar = calMan.getCalendarForDeletion(res);
        if (courseCalendar != null) {
            SubscriptionContext subContext = notificationManager.getSubscriptionContext(courseCalendar, res);
            OLATResourceable oresToDelete = OresHelper.createOLATResourceableInstance(subContext.getResName(), subContext.getResId());
            nfm.deletePublishersOf(oresToDelete);
        }
    } catch (AssertException e) {
    // if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarNotificationManager(org.olat.commons.calendar.CalendarNotificationManager) AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) OLATResourceable(org.olat.core.id.OLATResourceable) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 8 with SubscriptionContext

use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.

the class AssessmentNotificationsHandler method getAssessmentSubscriptionContext.

/**
 * Returns the <code>SubscriptionContext</code> to use for assessment
 * notification about specified <code>ICourse</code>.<br>
 * <br>
 * <b>PRE CONDITIONS</b>
 * <ul>
 * <li> <code>course != null</code>
 * </ul>
 * If <code>ident == null</code>, the subscription context is (created and)
 * returned without authorization control
 *
 * @param ident the identity, if null, no subscription check will be made
 * @param course
 * @return the subscription context to use or <code>null</code> if the
 *         identity associated to the request is not allowed to be notified
 * @see #canSubscribeForAssessmentNotification(Identity, ICourse)
 */
public SubscriptionContext getAssessmentSubscriptionContext(Identity ident, ICourse course) {
    SubscriptionContext sctx = null;
    if (ident == null || canSubscribeForAssessmentNotification(ident, course)) {
        // Creates a new SubscriptionContext only if not found into cache
        if (sctx == null) {
            // a subscription context showing to the root node (the course's root
            // node is started when clicking such a notification)
            CourseNode cn = course.getRunStructure().getRootNode();
            Long resourceableId = course.getResourceableId();
            sctx = new SubscriptionContext(CourseModule.ORES_COURSE_ASSESSMENT, resourceableId, cn.getIdent());
        }
    }
    return sctx;
}
Also used : SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) CourseNode(org.olat.course.nodes.CourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode)

Example 9 with SubscriptionContext

use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method markPublisherNews.

public void markPublisherNews(Identity ident, OLATResource courseResource) {
    ICourse course = CourseFactory.loadCourse(courseResource);
    SubscriptionContext subsContext = getSubscriptionContext(course);
    if (subsContext != null) {
        notificationsManager.markPublisherNews(subsContext, ident, true);
    }
}
Also used : ICourse(org.olat.course.ICourse) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 10 with SubscriptionContext

use of org.olat.core.commons.services.notifications.SubscriptionContext in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method getSubscriptionContext.

@Override
public SubscriptionContext getSubscriptionContext(ICourse course) {
    CourseNode cn = course.getRunStructure().getRootNode();
    CourseEnvironment ce = course.getCourseEnvironment();
    SubscriptionContext ctxt = new SubscriptionContext(ORES_CERTIFICATE, ce.getCourseResourceableId(), cn.getIdent());
    return ctxt;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) CourseNode(org.olat.course.nodes.CourseNode) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Aggregations

SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)204 PublisherData (org.olat.core.commons.services.notifications.PublisherData)84 Identity (org.olat.core.id.Identity)72 Test (org.junit.Test)66 Publisher (org.olat.core.commons.services.notifications.Publisher)58 RepositoryEntry (org.olat.repository.RepositoryEntry)38 VFSContainer (org.olat.core.util.vfs.VFSContainer)32 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)28 BusinessGroup (org.olat.group.BusinessGroup)28 ArrayList (java.util.ArrayList)20 Subscriber (org.olat.core.commons.services.notifications.Subscriber)20 HttpResponse (org.apache.http.HttpResponse)18 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)18 Forum (org.olat.modules.fo.Forum)18 File (java.io.File)16 HttpGet (org.apache.http.client.methods.HttpGet)16 CollaborationTools (org.olat.collaboration.CollaborationTools)14 OLATResourceable (org.olat.core.id.OLATResourceable)14 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)14 Roles (org.olat.core.id.Roles)12