use of org.olat.core.commons.services.notifications.SubscriptionContext in project openolat by klemens.
the class DocumentPoolMainController method doSelectTaxonomyLevel.
private DocumentPoolLevelController doSelectTaxonomyLevel(UserRequest ureq, TaxonomyTreeNode node) {
if (isTaxonomyAdmin || node.isCanRead() || node.isCanWrite()) {
TaxonomyLevel level = node.getTaxonomyLevel();
SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(node, subscriptionCtx);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("TaxonomyLevel", node.getTaxonomyLevel().getKey());
WindowControl bwControl = addToHistory(ureq, ores, null);
DocumentPoolLevelController levelCtrl = new DocumentPoolLevelController(ureq, bwControl, level, node, secCallback);
listenTo(levelCtrl);
String displayName = level.getDisplayName();
content.popUpToRootController(ureq);
List<TreeNode> parentLines = TreeHelper.getTreePath(node);
for (int i = 1; i < parentLines.size() - 1; i++) {
TreeNode parent = parentLines.get(i);
content.pushController(parent.getTitle(), null, parent);
}
content.pushController(displayName, levelCtrl);
return levelCtrl;
}
return null;
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project openolat by klemens.
the class BusinessGroupMembershipProcessorTest method testUnlinkMemberOfBusinessGroup.
@Test
public void testUnlinkMemberOfBusinessGroup() {
// 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.addRole(id1, businessGroup, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id2, businessGroup, GroupRoles.participant.name());
// create a publisher
SubscriptionContext context = new SubscriptionContext(businessGroup, "");
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 id1 and check subscription
MailPackage mailing = new MailPackage(false);
List<Identity> identitiesToRemove = Collections.singletonList(id1);
businessGroupService.removeParticipants(coach, identitiesToRemove, businessGroup, mailing);
// wait for the remove of subscription
waitForCondition(new CheckUnsubscription(id1, 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.assertTrue(subscribedId2);
boolean subscribedCoach = notificationManager.isSubscribed(coach, context);
Assert.assertTrue(subscribedCoach);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project openolat by klemens.
the class BusinessGroupMembershipProcessorTest method testUnlinkMemberOfBusinessGroup_with2Roles.
@Test
public void testUnlinkMemberOfBusinessGroup_with2Roles() {
// create a group with members
Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-4");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(member, "mbr-proc-2", "mbr-proc-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(member, businessGroup, GroupRoles.participant.name());
// create a publisher
SubscriptionContext context = new SubscriptionContext(businessGroup, "");
PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
notificationManager.getOrCreatePublisher(context, publisherData);
notificationManager.subscribe(member, context, publisherData);
dbInstance.commitAndCloseSession();
// remove id1 as participant and check subscription
businessGroupRelationDao.removeRole(member, businessGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// manually trigger the event
businessGroupMembershipProcessor.event(new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, businessGroup, member));
dbInstance.commitAndCloseSession();
// check that subscription of member was not deleted because it's still coach
boolean subscribed = notificationManager.isSubscribed(member, context);
Assert.assertTrue(subscribed);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project openolat by klemens.
the class InfoSubscriptionManagerImpl method subscribe.
@Override
public void subscribe(OLATResourceable resource, String resSubPath, String businessPath, Identity identity) {
PublisherData data = getInfoPublisherData(resource, businessPath);
SubscriptionContext context = getInfoSubscriptionContext(resource, resSubPath);
notificationsManager.subscribe(identity, context, data);
}
use of org.olat.core.commons.services.notifications.SubscriptionContext in project openolat by klemens.
the class InfoSubscriptionManagerImpl method markPublisherNews.
@Override
public void markPublisherNews(OLATResourceable resource, String subPath) {
SubscriptionContext context = getInfoSubscriptionContext(resource, subPath);
notificationsManager.markPublisherNews(context, null, true);
}
Aggregations