Search in sources :

Example 96 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.

the class BusinessGroupMembershipProcessorTest method testUnlinkRepositoryEntry.

@Test
public void testUnlinkRepositoryEntry() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    // create a group with members
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-1");
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-2");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");
    BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "mbr-proc-1", "mbr-proc-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(businessGroup, re);
    businessGroupRelationDao.addRole(id1, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(id2, businessGroup, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.owner.name());
    // create a publisher
    SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
    PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
    Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
    Assert.assertNotNull(publisher);
    dbInstance.commitAndCloseSession();
    // subscribe
    notificationManager.subscribe(coach, context, publisherData);
    notificationManager.subscribe(id1, context, publisherData);
    notificationManager.subscribe(id2, context, publisherData);
    dbInstance.commitAndCloseSession();
    // remove link between group and repository entry
    businessGroupService.removeResourceFrom(Collections.singletonList(businessGroup), re);
    dbInstance.commitAndCloseSession();
    // wait for the remove of subscription
    waitForCondition(new CheckUnsubscription(id1, context, dbInstance, notificationManager), 5000);
    waitForCondition(new CheckUnsubscription(id2, context, dbInstance, notificationManager), 5000);
    // check that subscription of id1 was deleted but not the ones of id2 and coach
    boolean subscribedId1 = notificationManager.isSubscribed(id1, context);
    Assert.assertFalse(subscribedId1);
    boolean subscribedId2 = notificationManager.isSubscribed(id2, context);
    Assert.assertFalse(subscribedId2);
    boolean subscribedCoach = notificationManager.isSubscribed(coach, context);
    Assert.assertTrue(subscribedCoach);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) Test(org.junit.Test)

Example 97 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.

the class HistoryController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (!ureq.getUserSession().getRoles().isGuestOnly()) {
        subsContext = new SubscriptionContext(PortfolioNotificationsHandler.TYPE_NAME, binder.getKey(), PortfolioNotificationsHandler.TYPE_NAME);
        if (subsContext != null) {
            String businessPath = "[Binder:" + binder.getKey() + "]";
            PublisherData data = new PublisherData(PortfolioNotificationsHandler.TYPE_NAME, null, businessPath);
            cSubscriptionCtrl = new ContextualSubscriptionController(ureq, getWindowControl(), subsContext, data);
            listenTo(cSubscriptionCtrl);
            flc.put("subscription", cSubscriptionCtrl.getInitialComponent());
        }
    }
    dateChooser = uifactory.addDateChooser("dateChooser", "changes.since", null, formLayout);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.set(Calendar.DATE, -8);
    dateChooser.setDate(cal.getTime());
    dateChooser.addActionListener(FormEvent.ONCHANGE);
}
Also used : ContextualSubscriptionController(org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController) Calendar(java.util.Calendar) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) PublisherData(org.olat.core.commons.services.notifications.PublisherData) Date(java.util.Date)

Example 98 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.

the class MailManagerImpl method getPublisherData.

@Override
public PublisherData getPublisherData() {
    String data = "";
    String businessPath = "[Inbox:0]";
    PublisherData publisherData = new PublisherData("Inbox", data, businessPath);
    return publisherData;
}
Also used : PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Example 99 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.

the class BCCourseNodeEditForm method updatePublisher.

private void updatePublisher(VFSContainer container) {
    File realFile = VFSManager.getRealFile(container);
    String relPath = new File(FolderConfig.getCanonicalRoot()).toPath().relativize(realFile.toPath()).toString();
    NotificationsManager notifManager = NotificationsManager.getInstance();
    SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(course.getCourseEnvironment(), node);
    Publisher publisher = notifManager.getPublisher(nodefolderSubContext);
    if (publisher != null) {
        String businessPath = getWindowControl().getBusinessControl().getAsString();
        String data = "/" + relPath;
        PublisherData pdata = new PublisherData(OresHelper.calculateTypeName(BCCourseNode.class), data, businessPath);
        notifManager.updatePublisherData(nodefolderSubContext, pdata);
    }
}
Also used : BCCourseNode(org.olat.course.nodes.BCCourseNode) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) File(java.io.File) PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Example 100 with PublisherData

use of org.olat.core.commons.services.notifications.PublisherData in project openolat by klemens.

the class AbstractTaskNotificationHandler method createContextualSubscriptionController.

public static ContextualSubscriptionController createContextualSubscriptionController(UserRequest ureq, WindowControl wControl, String folderPath, SubscriptionContext subsContext, Class<?> callerClass) {
    String businessPath = wControl.getBusinessControl().getAsString();
    PublisherData pdata = new PublisherData(OresHelper.calculateTypeName(callerClass), folderPath, businessPath);
    ContextualSubscriptionController contextualSubscriptionCtr = new ContextualSubscriptionController(ureq, wControl, subsContext, pdata);
    return contextualSubscriptionCtr;
}
Also used : ContextualSubscriptionController(org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController) PublisherData(org.olat.core.commons.services.notifications.PublisherData)

Aggregations

PublisherData (org.olat.core.commons.services.notifications.PublisherData)100 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)84 Test (org.junit.Test)64 Identity (org.olat.core.id.Identity)60 Publisher (org.olat.core.commons.services.notifications.Publisher)42 RepositoryEntry (org.olat.repository.RepositoryEntry)22 BusinessGroup (org.olat.group.BusinessGroup)20 HttpResponse (org.apache.http.HttpResponse)16 HttpGet (org.apache.http.client.methods.HttpGet)16 Subscriber (org.olat.core.commons.services.notifications.Subscriber)16 ArrayList (java.util.ArrayList)14 ContextualSubscriptionController (org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController)12 Forum (org.olat.modules.fo.Forum)12 UriBuilder (javax.ws.rs.core.UriBuilder)10 SubscriptionInfoVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO)8 SubscriptionListItemVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO)8 DBRuntimeException (org.olat.core.logging.DBRuntimeException)8 ICourse (org.olat.course.ICourse)8 File (java.io.File)6 URI (java.net.URI)6